Skip to content

Commit

Permalink
feat: add theme var
Browse files Browse the repository at this point in the history
  • Loading branch information
Daydreamer-riri committed Jan 1, 2024
1 parent b5dc565 commit a1aaf72
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 27 deletions.
4 changes: 4 additions & 0 deletions bin/material3-style.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
'use strict'

import '../dist/cli.mjs'
1 change: 1 addition & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineBuildConfig } from 'unbuild'
export default defineBuildConfig({
entries: [
'src/index',
'src/cli',
],
declaration: true,
clean: true,
Expand Down
125 changes: 124 additions & 1 deletion color/_var.scss
Original file line number Diff line number Diff line change
@@ -1 +1,124 @@
@use '../typography';
/** Don't edit this file directly. It is generated by `material3-style color`. */

@mixin theme-light {
--md-sys-color-primary: #6f43c0;
--md-sys-color-on-primary: #ffffff;
--md-sys-color-primary-container: #ebddff;
--md-sys-color-on-primary-container: #250059;
--md-sys-color-secondary: #635b70;
--md-sys-color-on-secondary: #ffffff;
--md-sys-color-secondary-container: #e9def8;
--md-sys-color-on-secondary-container: #1f182b;
--md-sys-color-tertiary: #7e525d;
--md-sys-color-on-tertiary: #ffffff;
--md-sys-color-tertiary-container: #ffd9e1;
--md-sys-color-on-tertiary-container: #31101b;
--md-sys-color-error: #ba1a1a;
--md-sys-color-on-error: #ffffff;
--md-sys-color-error-container: #ffdad6;
--md-sys-color-on-error-container: #410002;
--md-sys-color-background: #fffbff;
--md-sys-color-on-background: #1d1b1e;
--md-sys-color-surface: #fffbff;
--md-sys-color-on-surface: #1d1b1e;
--md-sys-color-surface-variant: #e7e0eb;
--md-sys-color-on-surface-variant: #49454e;
--md-sys-color-outline: #7a757f;
--md-sys-color-outline-variant: #cbc4cf;
--md-sys-color-shadow: #000000;
--md-sys-color-scrim: #000000;
--md-sys-color-inverse-surface: #323033;
--md-sys-color-inverse-on-surface: #f5eff4;
--md-sys-color-inverse-primary: #d3bbff;
--m3-color-primary: var(--md-sys-color-primary);
--m3-color-on-primary: var(--md-sys-color-on-primary);
--m3-color-primary-container: var(--md-sys-color-primary-container);
--m3-color-on-primary-container: var(--md-sys-color-on-primary-container);
--m3-color-secondary: var(--md-sys-color-secondary);
--m3-color-on-secondary: var(--md-sys-color-on-secondary);
--m3-color-secondary-container: var(--md-sys-color-secondary-container);
--m3-color-on-secondary-container: var(--md-sys-color-on-secondary-container);
--m3-color-tertiary: var(--md-sys-color-tertiary);
--m3-color-on-tertiary: var(--md-sys-color-on-tertiary);
--m3-color-tertiary-container: var(--md-sys-color-tertiary-container);
--m3-color-on-tertiary-container: var(--md-sys-color-on-tertiary-container);
--m3-color-error: var(--md-sys-color-error);
--m3-color-on-error: var(--md-sys-color-on-error);
--m3-color-error-container: var(--md-sys-color-error-container);
--m3-color-on-error-container: var(--md-sys-color-on-error-container);
--m3-color-background: var(--md-sys-color-background);
--m3-color-on-background: var(--md-sys-color-on-background);
--m3-color-surface: var(--md-sys-color-surface);
--m3-color-on-surface: var(--md-sys-color-on-surface);
--m3-color-surface-variant: var(--md-sys-color-surface-variant);
--m3-color-on-surface-variant: var(--md-sys-color-on-surface-variant);
--m3-color-outline: var(--md-sys-color-outline);
--m3-color-outline-variant: var(--md-sys-color-outline-variant);
--m3-color-shadow: var(--md-sys-color-shadow);
--m3-color-scrim: var(--md-sys-color-scrim);
--m3-color-inverse-surface: var(--md-sys-color-inverse-surface);
--m3-color-inverse-on-surface: var(--md-sys-color-inverse-on-surface);
--m3-color-inverse-primary: var(--md-sys-color-inverse-primary);
}

@mixin theme-dark {
--md-sys-color-primary: #d3bbff;
--md-sys-color-on-primary: #3f008d;
--md-sys-color-primary-container: #5727a6;
--md-sys-color-on-primary-container: #ebddff;
--md-sys-color-secondary: #cdc2db;
--md-sys-color-on-secondary: #342d40;
--md-sys-color-secondary-container: #4b4358;
--md-sys-color-on-secondary-container: #e9def8;
--md-sys-color-tertiary: #f0b7c5;
--md-sys-color-on-tertiary: #4a2530;
--md-sys-color-tertiary-container: #643b46;
--md-sys-color-on-tertiary-container: #ffd9e1;
--md-sys-color-error: #ffb4ab;
--md-sys-color-on-error: #690005;
--md-sys-color-error-container: #93000a;
--md-sys-color-on-error-container: #ffb4ab;
--md-sys-color-background: #1d1b1e;
--md-sys-color-on-background: #e6e1e6;
--md-sys-color-surface: #1d1b1e;
--md-sys-color-on-surface: #e6e1e6;
--md-sys-color-surface-variant: #49454e;
--md-sys-color-on-surface-variant: #cbc4cf;
--md-sys-color-outline: #948f99;
--md-sys-color-outline-variant: #49454e;
--md-sys-color-shadow: #000000;
--md-sys-color-scrim: #000000;
--md-sys-color-inverse-surface: #e6e1e6;
--md-sys-color-inverse-on-surface: #323033;
--md-sys-color-inverse-primary: #6f43c0;
--m3-color-primary: var(--md-sys-color-primary);
--m3-color-on-primary: var(--md-sys-color-on-primary);
--m3-color-primary-container: var(--md-sys-color-primary-container);
--m3-color-on-primary-container: var(--md-sys-color-on-primary-container);
--m3-color-secondary: var(--md-sys-color-secondary);
--m3-color-on-secondary: var(--md-sys-color-on-secondary);
--m3-color-secondary-container: var(--md-sys-color-secondary-container);
--m3-color-on-secondary-container: var(--md-sys-color-on-secondary-container);
--m3-color-tertiary: var(--md-sys-color-tertiary);
--m3-color-on-tertiary: var(--md-sys-color-on-tertiary);
--m3-color-tertiary-container: var(--md-sys-color-tertiary-container);
--m3-color-on-tertiary-container: var(--md-sys-color-on-tertiary-container);
--m3-color-error: var(--md-sys-color-error);
--m3-color-on-error: var(--md-sys-color-on-error);
--m3-color-error-container: var(--md-sys-color-error-container);
--m3-color-on-error-container: var(--md-sys-color-on-error-container);
--m3-color-background: var(--md-sys-color-background);
--m3-color-on-background: var(--md-sys-color-on-background);
--m3-color-surface: var(--md-sys-color-surface);
--m3-color-on-surface: var(--md-sys-color-on-surface);
--m3-color-surface-variant: var(--md-sys-color-surface-variant);
--m3-color-on-surface-variant: var(--md-sys-color-on-surface-variant);
--m3-color-outline: var(--md-sys-color-outline);
--m3-color-outline-variant: var(--md-sys-color-outline-variant);
--m3-color-shadow: var(--md-sys-color-shadow);
--m3-color-scrim: var(--md-sys-color-scrim);
--m3-color-inverse-surface: var(--md-sys-color-inverse-surface);
--m3-color-inverse-on-surface: var(--md-sys-color-inverse-on-surface);
--m3-color-inverse-primary: var(--md-sys-color-inverse-primary);
}

5 changes: 5 additions & 0 deletions color/style/theme-dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use '../var';

:root {
@include var.theme-dark();
}
5 changes: 5 additions & 0 deletions color/style/theme-light.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use '../var';

:root {
@include var.theme-light();
}
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default ririd(
formatters: true,
ignores: [
'**/*.css',
'color/_var.scss',
],
},
)
9 changes: 9 additions & 0 deletions example/color-demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "color-demo",
"scripts": {
"color-gen": "material3-style color"
},
"dependencies": {
"material3-style": "workspace:*"
}
}
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,32 @@
]
}
},
"bin": {
"material3-style": "./bin/material3-style.mjs"
},
"files": [
"dist"
],
"scripts": {
"build": "unbuild",
"build:sass": "sass --style=compressed typography/style.scss:typography/css/index.css",
"build:sass": "npm run build:typo | npm run build:color",
"build:typo": "sass --style=compressed typography/style.scss:typography/css/index.css",
"build:color": "sass --style=compressed color/style:color/css",
"dev": "unbuild --stub",
"lint": "eslint .",
"prepublishOnly": "nr build",
"release": "bumpp && npm publish",
"start": "esno src/index.ts",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@material/material-color-utilities": "^0.2.7",
"yargs": "^17.7.2"
},
"devDependencies": {
"@ririd/eslint-config": "^1.0.3",
"@types/node": "^18.15.11",
"@types/yargs": "^17.0.32",
"bumpp": "^9.2.1",
"eslint": "^8.56.0",
"esno": "^4.0.0",
Expand Down
Loading

0 comments on commit a1aaf72

Please sign in to comment.