feat: initial commit
This commit is contained in:
commit
e9389c5666
28
.editorconfig
Normal file
28
.editorconfig
Normal file
|
@ -0,0 +1,28 @@
|
|||
root = true
|
||||
["*"]
|
||||
charset = "utf-8"
|
||||
curly_bracket_next_line = true
|
||||
end_of_line = "lf"
|
||||
indent_brace_style = "K&R"
|
||||
indent_size = 4
|
||||
indent_style = "space"
|
||||
insert_final_newline = true
|
||||
max_line_length = 80
|
||||
tab_width = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
["*.md"]
|
||||
max_line_length = "off"
|
||||
|
||||
["package.json"]
|
||||
indent_size = 2
|
||||
indent_style = "space"
|
||||
tab_width = 2
|
||||
|
||||
["{LICENSES/**,LICENSE}"]
|
||||
charset = "unset"
|
||||
end_of_line = "unset"
|
||||
indent_size = "unset"
|
||||
indent_style = "unset"
|
||||
insert_final_newline = "unset"
|
||||
trim_trailing_whitespace = "unset"
|
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
*.tgz
|
||||
/*.css
|
||||
|
||||
.direnv/
|
||||
node_modules/
|
||||
examples/style.css
|
||||
|
||||
# nixago: ignore-linked-files
|
||||
/treefmt.toml
|
||||
/.prettierrc.json
|
||||
/lefthook.yml
|
||||
/.conform.yaml
|
9
.npmignore
Normal file
9
.npmignore
Normal file
|
@ -0,0 +1,9 @@
|
|||
Justfile
|
||||
|
||||
flake.*
|
||||
.??*
|
||||
*.md
|
||||
*.tgz
|
||||
|
||||
src
|
||||
examples
|
133
CODE_OF_CONDUCT.md
Normal file
133
CODE_OF_CONDUCT.md
Normal file
|
@ -0,0 +1,133 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
- Demonstrating empathy and kindness toward other people
|
||||
- Being respectful of differing opinions, viewpoints, and experiences
|
||||
- Giving and gracefully accepting constructive feedback
|
||||
- Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
- Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
- The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
- Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official email address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
contact@mfgames.com.
|
||||
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
33
DCO.md
Normal file
33
DCO.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
Developer Certificate of Origin
|
||||
Version 1.1
|
||||
|
||||
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
(a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
(b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
(c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
(d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
21
Justfile
Normal file
21
Justfile
Normal file
|
@ -0,0 +1,21 @@
|
|||
@default:
|
||||
just --choose
|
||||
|
||||
# Format all the source code
|
||||
format:
|
||||
treefmt
|
||||
just --fmt --unstable
|
||||
|
||||
# Generate all the files
|
||||
build: examples
|
||||
|
||||
# Generate examples/style.css
|
||||
examples: format
|
||||
node src/cli.js build \
|
||||
--output examples/style.css \
|
||||
--light examples/light.css \
|
||||
--light-more-contrast examples/light-more-contrast.css \
|
||||
--light-less-contrast examples/light-less-contrast.css \
|
||||
--dark examples/dark.css \
|
||||
--dark-more-contrast examples/dark-more-contrast.css \
|
||||
--dark-less-contrast examples/dark-less-contrast.css
|
3
examples/dark-less-contrast.css
Normal file
3
examples/dark-less-contrast.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
:theme {
|
||||
color: #999;
|
||||
}
|
3
examples/dark-more-contrast.css
Normal file
3
examples/dark-more-contrast.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
:theme {
|
||||
color: white;
|
||||
}
|
4
examples/dark.css
Normal file
4
examples/dark.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
:theme {
|
||||
background-color: black;
|
||||
color: #ccc;
|
||||
}
|
118
examples/index.html
Normal file
118
examples/index.html
Normal file
|
@ -0,0 +1,118 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Ideas</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" rel="noopener" target="_blank" href="./style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>prefers-color-scheme</h1>
|
||||
|
||||
<div class="controls">
|
||||
<div id="color-scheme-selector">
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="auto-color-scheme"
|
||||
name="color-scheme"
|
||||
value="auto"
|
||||
checked
|
||||
/>
|
||||
<label for="auto-color-scheme">Auto</label>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="light-color-scheme"
|
||||
name="color-scheme"
|
||||
value="light"
|
||||
/>
|
||||
<label for="light-color-scheme">Light</label>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="dark-color-scheme"
|
||||
name="color-scheme"
|
||||
value="dark"
|
||||
/>
|
||||
<label for="dark-color-scheme">Dark</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1>prefers-contrast</h1>
|
||||
|
||||
<div id="prefers-contrast-selector">
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="auto-contrast-selector"
|
||||
name="contrast"
|
||||
value="auto"
|
||||
checked
|
||||
/>
|
||||
<label for="auto-contrast-selector">Auto</label>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="more-contrast-selector"
|
||||
name="contrast"
|
||||
value="more"
|
||||
/>
|
||||
<label for="more-contrast-selector">More</label>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
id="less-contrast-selector"
|
||||
name="contrast"
|
||||
value="less"
|
||||
/>
|
||||
<label for="less-contrast-selector">Less</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
// Color Theme
|
||||
var autoColorTheme = document.getElementById("auto-color-scheme");
|
||||
var lightColorTheme = document.getElementById("light-color-scheme");
|
||||
var darkColorTheme = document.getElementById("dark-color-scheme");
|
||||
|
||||
autoColorTheme.onclick = function () {
|
||||
document.documentElement.removeAttribute("data-prefers-color-scheme");
|
||||
};
|
||||
|
||||
lightColorTheme.onclick = function () {
|
||||
document.documentElement.setAttribute(
|
||||
"data-prefers-color-scheme",
|
||||
"light",
|
||||
);
|
||||
};
|
||||
|
||||
darkColorTheme.onclick = function () {
|
||||
document.documentElement.setAttribute(
|
||||
"data-prefers-color-scheme",
|
||||
"dark",
|
||||
);
|
||||
};
|
||||
|
||||
// Prefers Contrast
|
||||
var autoContrast = document.getElementById("auto-contrast-selector");
|
||||
var moreContrast = document.getElementById("more-contrast-selector");
|
||||
var lessContrast = document.getElementById("less-contrast-selector");
|
||||
|
||||
autoContrast.onclick = function () {
|
||||
document.documentElement.removeAttribute("data-prefers-contrast");
|
||||
};
|
||||
|
||||
moreContrast.onclick = function () {
|
||||
document.documentElement.setAttribute("data-prefers-contrast", "more");
|
||||
};
|
||||
|
||||
lessContrast.onclick = function () {
|
||||
document.documentElement.setAttribute("data-prefers-contrast", "less");
|
||||
};
|
||||
</script>
|
||||
</html>
|
3
examples/light-less-contrast.css
Normal file
3
examples/light-less-contrast.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
:theme {
|
||||
color: #666;
|
||||
}
|
3
examples/light-more-contrast.css
Normal file
3
examples/light-more-contrast.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
:theme {
|
||||
color: black;
|
||||
}
|
4
examples/light.css
Normal file
4
examples/light.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
:theme {
|
||||
background: white;
|
||||
color: #333;
|
||||
}
|
418
flake.lock
Normal file
418
flake.lock
Normal file
|
@ -0,0 +1,418 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_3": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_4": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_5": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_6": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_7": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_8": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_9": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"mfgames-project-setup": {
|
||||
"inputs": {
|
||||
"nixago": "nixago",
|
||||
"nixago-exts": "nixago-exts_3",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1707180400,
|
||||
"narHash": "sha256-Gt+a0EoeMWYFo8Xoct4ToTGuFOV8mxeA8F9QGtbtKjk=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "9b8c86005fbb122134fc247200de8c30724faaef",
|
||||
"revCount": 14,
|
||||
"type": "git",
|
||||
"url": "https://src.mfgames.com/nixos-contrib/mfgames-project-setup-flake.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://src.mfgames.com/nixos-contrib/mfgames-project-setup-flake.git"
|
||||
}
|
||||
},
|
||||
"nixago": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixago-exts": "nixago-exts",
|
||||
"nixpkgs": [
|
||||
"mfgames-project-setup",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1687381756,
|
||||
"narHash": "sha256-IUMIlYfrvj7Yli4H2vvyig8HEPpfCeMaE6+kBGPzFyk=",
|
||||
"owner": "jmgilman",
|
||||
"repo": "nixago",
|
||||
"rev": "dacceb10cace103b3e66552ec9719fa0d33c0dc9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "jmgilman",
|
||||
"repo": "nixago",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago-exts": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixago": "nixago_2",
|
||||
"nixpkgs": [
|
||||
"mfgames-project-setup",
|
||||
"nixago",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1676070308,
|
||||
"narHash": "sha256-QaJ65oc2l8iwQIGWUJ0EKjCeSuuCM/LqR8RauxZUUkc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago-extensions",
|
||||
"rev": "e5380cb0456f4ea3c86cf94e3039eb856bf07d0b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago-extensions",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago-exts_2": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_4",
|
||||
"nixago": "nixago_3",
|
||||
"nixpkgs": [
|
||||
"mfgames-project-setup",
|
||||
"nixago",
|
||||
"nixago-exts",
|
||||
"nixago",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1655508669,
|
||||
"narHash": "sha256-BDDdo5dZQMmwNH/GNacy33nPBnCpSIydWFPZs0kkj/g=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago-extensions",
|
||||
"rev": "3022a932ce109258482ecc6568c163e8d0b426aa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago-extensions",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago-exts_3": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_6",
|
||||
"nixago": "nixago_4",
|
||||
"nixpkgs": [
|
||||
"mfgames-project-setup",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1676070308,
|
||||
"narHash": "sha256-QaJ65oc2l8iwQIGWUJ0EKjCeSuuCM/LqR8RauxZUUkc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago-extensions",
|
||||
"rev": "e5380cb0456f4ea3c86cf94e3039eb856bf07d0b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago-extensions",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago-exts_4": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_8",
|
||||
"nixago": "nixago_5",
|
||||
"nixpkgs": [
|
||||
"mfgames-project-setup",
|
||||
"nixago-exts",
|
||||
"nixago",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1655508669,
|
||||
"narHash": "sha256-BDDdo5dZQMmwNH/GNacy33nPBnCpSIydWFPZs0kkj/g=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago-extensions",
|
||||
"rev": "3022a932ce109258482ecc6568c163e8d0b426aa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago-extensions",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago_2": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixago-exts": "nixago-exts_2",
|
||||
"nixpkgs": [
|
||||
"mfgames-project-setup",
|
||||
"nixago",
|
||||
"nixago-exts",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1676070010,
|
||||
"narHash": "sha256-iYzJIWptE1EUD8VINAg66AAMUajizg8JUYN3oBmb8no=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"rev": "d480ba6c0c16e2c5c0bd2122852d6a0c9ad1ed0e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "rename-config-data",
|
||||
"repo": "nixago",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago_3": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_5",
|
||||
"nixpkgs": [
|
||||
"mfgames-project-setup",
|
||||
"nixago",
|
||||
"nixago-exts",
|
||||
"nixago",
|
||||
"nixago-exts",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1655405483,
|
||||
"narHash": "sha256-Crd49aZWNrpczlRTOwWGfwBMsTUoG9vlHDKQC7cx264=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"rev": "e6a9566c18063db5b120e69e048d3627414e327d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago_4": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_7",
|
||||
"nixago-exts": "nixago-exts_4",
|
||||
"nixpkgs": [
|
||||
"mfgames-project-setup",
|
||||
"nixago-exts",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1676070010,
|
||||
"narHash": "sha256-iYzJIWptE1EUD8VINAg66AAMUajizg8JUYN3oBmb8no=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"rev": "d480ba6c0c16e2c5c0bd2122852d6a0c9ad1ed0e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "rename-config-data",
|
||||
"repo": "nixago",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago_5": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_9",
|
||||
"nixpkgs": [
|
||||
"mfgames-project-setup",
|
||||
"nixago-exts",
|
||||
"nixago",
|
||||
"nixago-exts",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1655405483,
|
||||
"narHash": "sha256-Crd49aZWNrpczlRTOwWGfwBMsTUoG9vlHDKQC7cx264=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"rev": "e6a9566c18063db5b120e69e048d3627414e327d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1706098335,
|
||||
"narHash": "sha256-r3dWjT8P9/Ah5m5ul4WqIWD8muj5F+/gbCdjiNVBKmU=",
|
||||
"rev": "a77ab169a83a4175169d78684ddd2e54486ac651",
|
||||
"revCount": 554858,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2311.554858%2Brev-a77ab169a83a4175169d78684ddd2e54486ac651/018d46f0-798f-71dc-a8c5-4689c46f7d12/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1708161998,
|
||||
"narHash": "sha256-6KnemmUorCvlcAvGziFosAVkrlWZGIc6UNT9GUYr0jQ=",
|
||||
"rev": "84d981bae8b5e783b3b548de505b22880559515f",
|
||||
"revCount": 555825,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2311.555825%2Brev-84d981bae8b5e783b3b548de505b22880559515f/018dbaaf-4db4-7aaa-85f3-0cf000e0264b/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"mfgames-project-setup": "mfgames-project-setup",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
45
flake.nix
Normal file
45
flake.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz";
|
||||
mfgames-project-setup.url = "git+https://src.mfgames.com/nixos-contrib/mfgames-project-setup-flake.git";
|
||||
};
|
||||
|
||||
outputs = inputs @ { self, nixpkgs, mfgames-project-setup, ... }:
|
||||
let
|
||||
# Helpers for producing system-specific outputs
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
|
||||
inherit system;
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
});
|
||||
in
|
||||
rec
|
||||
{
|
||||
# Set up the developer shell.
|
||||
devShells = forEachSupportedSystem ({ system, pkgs }:
|
||||
let
|
||||
project-config = mfgames-project-setup.lib.mkConfig {
|
||||
inherit system pkgs;
|
||||
contributorCovenant.enable = true;
|
||||
contributorCovenant.contact = "contact@mfgames.com";
|
||||
developerCertificateOfOrigin.enable = true;
|
||||
};
|
||||
in
|
||||
{
|
||||
# Shell
|
||||
default = pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.just
|
||||
pkgs.nodejs_20
|
||||
pkgs.nodePackages.prettier
|
||||
]
|
||||
++ project-config.packages;
|
||||
|
||||
shellHook = project-config.shellHook;
|
||||
};
|
||||
});
|
||||
|
||||
# Formatting for the Nix files
|
||||
formatter = forEachSupportedSystem ({ pkgs, ... }: pkgs.nixpkgs-fmt);
|
||||
};
|
||||
}
|
162
package-lock.json
generated
Normal file
162
package-lock.json
generated
Normal file
|
@ -0,0 +1,162 @@
|
|||
{
|
||||
"name": "@priduck-color-theme/theme",
|
||||
"version": "0.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@priduck-color-theme/theme",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"yargs": "^17.7.2"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-regex": {
|
||||
"version": "5.0.1",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/cliui": {
|
||||
"version": "8.0.1",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^4.2.0",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"wrap-ansi": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/color-name": {
|
||||
"version": "1.1.4",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
"version": "3.1.2",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/get-caller-file": {
|
||||
"version": "2.0.5",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "6.* || 8.* || >= 10.*"
|
||||
}
|
||||
},
|
||||
"node_modules/is-fullwidth-code-point": {
|
||||
"version": "3.0.0",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "4.2.3",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^8.0.0",
|
||||
"is-fullwidth-code-point": "^3.0.0",
|
||||
"strip-ansi": "^6.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/strip-ansi": {
|
||||
"version": "6.0.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/wrap-ansi": {
|
||||
"version": "7.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.0.0",
|
||||
"string-width": "^4.1.0",
|
||||
"strip-ansi": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/y18n": {
|
||||
"version": "5.0.8",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs": {
|
||||
"version": "17.7.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
|
||||
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
|
||||
"dependencies": {
|
||||
"cliui": "^8.0.1",
|
||||
"escalade": "^3.1.1",
|
||||
"get-caller-file": "^2.0.5",
|
||||
"require-directory": "^2.1.1",
|
||||
"string-width": "^4.2.3",
|
||||
"y18n": "^5.0.5",
|
||||
"yargs-parser": "^21.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs-parser": {
|
||||
"version": "21.1.1",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
20
package.json
Normal file
20
package.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "@priduck-color-theme/theme",
|
||||
"version": "0.0.0",
|
||||
"description": "Style builder files for themes that use `prefers-contrast` and `prefers-color-theme`.",
|
||||
"bin": {
|
||||
"priduck-color-theme": "src/cli.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://src.mfgames.com/priduck-color-theme/priduck-color-theme-theme-js.git"
|
||||
},
|
||||
"keywords": [
|
||||
"css"
|
||||
],
|
||||
"author": "D. Moonfire",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"yargs": "^17.7.2"
|
||||
}
|
||||
}
|
150
src/cli.js
Executable file
150
src/cli.js
Executable file
|
@ -0,0 +1,150 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const fs = require("fs");
|
||||
|
||||
require("yargs")
|
||||
.scriptName("priduck-color-theme")
|
||||
.usage("$0 <cmd> [--color-theme-dark=FILE]")
|
||||
.command(
|
||||
"build [--color-theme-dark=FILE]",
|
||||
"Generate a CSS file that expands on the various common patterns for themes",
|
||||
(yargs) => {
|
||||
yargs
|
||||
.option("default", {
|
||||
type: "string",
|
||||
choices: ["light", "dark"],
|
||||
default: "light",
|
||||
describe: "The default theme if none are provided",
|
||||
})
|
||||
.option("light", {
|
||||
type: "string",
|
||||
describe: "The path to CSS that provides the base light theme",
|
||||
})
|
||||
.option("light-more-contrast", {
|
||||
type: "string",
|
||||
describe:
|
||||
"The path to CSS that provides more contrast for light theme",
|
||||
})
|
||||
.option("light-less-contrast", {
|
||||
type: "string",
|
||||
describe:
|
||||
"The path to CSS that provides less contrast for light theme",
|
||||
})
|
||||
.option("dark", {
|
||||
type: "string",
|
||||
describe: "The path to CSS that provides the base dark theme",
|
||||
})
|
||||
.option("dark-more-contrast", {
|
||||
type: "string",
|
||||
describe:
|
||||
"The path to CSS that provides more contrast for dark theme",
|
||||
})
|
||||
.option("dark-less-contrast", {
|
||||
type: "string",
|
||||
describe:
|
||||
"The path to CSS that provides less contrast for dark theme",
|
||||
})
|
||||
.option("output", {
|
||||
type: "string",
|
||||
demandOption: true,
|
||||
describe: "The path to the resulting CSS file",
|
||||
});
|
||||
},
|
||||
build,
|
||||
)
|
||||
.help().argv;
|
||||
|
||||
function build(argv) {
|
||||
// Load in all the files.
|
||||
let light = load(argv, "light");
|
||||
let lightMoreContrast = load(argv, "light-more-contrast");
|
||||
let lightLessContrast = load(argv, "light-less-contrast");
|
||||
let dark = load(argv, "dark");
|
||||
let darkMoreContrast = load(argv, "dark-more-contrast");
|
||||
let darkLessContrast = load(argv, "dark-less-contrast");
|
||||
|
||||
// Figure out the default.
|
||||
let auto = argv.default === "light" ? light : dark;
|
||||
|
||||
let autoMoreContrast =
|
||||
argv.default === "light" ? lightMoreContrast : darkMoreContrast;
|
||||
|
||||
let autoLessContrast =
|
||||
argv.default === "light" ? lightLessContrast : darkLessContrast;
|
||||
|
||||
// Build up the components of the style.
|
||||
let lines = [
|
||||
block(":root", auto),
|
||||
block('[data-prefers-contrast="more"]', autoMoreContrast),
|
||||
block('[data-prefers-contrast="less"]', autoLessContrast),
|
||||
block(
|
||||
"@media (prefers-color-scheme: light)",
|
||||
light,
|
||||
block('[data-prefers-contrast="more"]', lightMoreContrast),
|
||||
block('[data-prefers-contrast="less"]', lightLessContrast),
|
||||
),
|
||||
block(
|
||||
"@media (prefers-color-scheme: dark)",
|
||||
dark,
|
||||
block('[data-prefers-contrast="more"]', darkMoreContrast),
|
||||
block('[data-prefers-contrast="less"]', darkLessContrast),
|
||||
),
|
||||
block('[data-prefers-color-scheme="light"]', light),
|
||||
block(
|
||||
'[data-prefers-color-scheme="light"][data-prefers-contrast="more"]',
|
||||
lightMoreContrast,
|
||||
),
|
||||
block(
|
||||
'[data-prefers-color-scheme="light"][data-prefers-contrast="less"]',
|
||||
lightLessContrast,
|
||||
),
|
||||
block('[data-prefers-color-scheme="dark"]', dark),
|
||||
block(
|
||||
'[data-prefers-color-scheme="dark"][data-prefers-contrast="more"]',
|
||||
darkMoreContrast,
|
||||
),
|
||||
block(
|
||||
'[data-prefers-color-scheme="dark"][data-prefers-contrast="less"]',
|
||||
darkLessContrast,
|
||||
),
|
||||
];
|
||||
|
||||
// Write out the file.
|
||||
console.log("writing to --output=", argv.output);
|
||||
fs.writeFileSync(argv.output, Buffer.from(lines.join("\n")));
|
||||
}
|
||||
|
||||
function block(selector, ...lines) {
|
||||
if (!lines) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let blockLines = [selector + " {"];
|
||||
|
||||
for (const line of lines) {
|
||||
blockLines.push(line);
|
||||
}
|
||||
|
||||
blockLines.push("}");
|
||||
|
||||
return blockLines.join("\n");
|
||||
}
|
||||
|
||||
function load(argv, key) {
|
||||
const value = argv[key];
|
||||
|
||||
if (!value || value.trim() === "") {
|
||||
console.log(`no value provided for --${key}`);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
console.log(`reading --${key}=${argv[key]}`);
|
||||
|
||||
return fs
|
||||
.readFileSync(argv[key])
|
||||
.toString()
|
||||
.replace(/:theme\s+\{/, "")
|
||||
.replace(/\s*\}\s*$/, "")
|
||||
.trim();
|
||||
}
|
Loading…
Reference in a new issue