@elmethis/core 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,170 @@
1
+ //#region src/style/token.ts
2
+ const PRIMITIVE_VALUES = {
3
+ color: {
4
+ red: {
5
+ 100: "#e9dddd",
6
+ 500: "#ae6e6e",
7
+ 900: "#291313"
8
+ },
9
+ orange: {
10
+ 100: "#ebdfdb",
11
+ 500: "#b8816e",
12
+ 900: "#3f251c"
13
+ },
14
+ yellow: {
15
+ 100: "#ebe6db",
16
+ 500: "#b09a66",
17
+ 900: "#332b19"
18
+ },
19
+ green: {
20
+ 100: "#dde9e2",
21
+ 500: "#659878",
22
+ 900: "#15281d"
23
+ },
24
+ cyan: {
25
+ 100: "#dde9e7",
26
+ 500: "#6091a0",
27
+ 900: "#203b37"
28
+ },
29
+ blue: {
30
+ 100: "#dde2e9",
31
+ 500: "#68779f",
32
+ 900: "#242d3e"
33
+ },
34
+ purple: {
35
+ 100: "#e3dde9",
36
+ 500: "#8d799f",
37
+ 900: "#271836"
38
+ },
39
+ magenta: {
40
+ 100: "#eadce4",
41
+ 500: "#b17396",
42
+ 900: "#3c1f2f"
43
+ },
44
+ slate: {
45
+ 100: "#d7d9e1",
46
+ 200: "#b0b5be",
47
+ 300: "#949ba7",
48
+ 400: "#6c7483",
49
+ 500: "#555b67",
50
+ 600: "#40444c",
51
+ 700: "#393e46",
52
+ 800: "#31353a",
53
+ 900: "#242629"
54
+ },
55
+ gold: {
56
+ 100: "#f7f5f4",
57
+ 200: "#efecea",
58
+ 300: "#d9d3cc",
59
+ 400: "#cabfb2",
60
+ 500: "#c6b5a2",
61
+ 600: "#bda68b",
62
+ 700: "#a68c70",
63
+ 800: "#8e7356",
64
+ 900: "#6e583f"
65
+ }
66
+ },
67
+ font: { family: {
68
+ sans: "\"DM Sans\", \"Zen Kaku Gothic New\", -apple-system, BlinkMacSystemFont, \"Hiragino Kaku Gothic ProN\", Meiryo, sans-serif",
69
+ monospace: "\"DM Mono\", \"Source Code Pro\", Menlo, Consolas, \"DejaVu Sans Mono\", \"Zen Kaku Gothic New\", monospace"
70
+ } }
71
+ };
72
+ const makePrimitive = (path, value) => {
73
+ const property = `--elmethis-primitive-${path.join("-")}`;
74
+ return {
75
+ property,
76
+ value,
77
+ ref: `var(${property})`
78
+ };
79
+ };
80
+ const buildPrimitives = (values, path) => {
81
+ const out = {};
82
+ for (const [key, value] of Object.entries(values)) {
83
+ const next = [...path, key];
84
+ out[key] = typeof value === "string" ? makePrimitive(next, value) : buildPrimitives(value, next);
85
+ }
86
+ return out;
87
+ };
88
+ /** Primitive tokens, addressable as `primitive.color.blue[500]`. */
89
+ const primitive = buildPrimitives(PRIMITIVE_VALUES, []);
90
+ const resolve = (ref) => typeof ref === "string" ? ref : ref.ref;
91
+ /** A theme-independent semantic value. */
92
+ const common = (ref) => ({ common: resolve(ref) });
93
+ /** A native `light-dark()` semantic value. */
94
+ const theme = (light, dark) => ({
95
+ light: resolve(light),
96
+ dark: resolve(dark)
97
+ });
98
+ const { color, font } = primitive;
99
+ /**
100
+ * Semantic tokens, keyed by the full kebab suffix that follows `--elmethis-`
101
+ * (so `"color-accent-info-surface"` emits `--elmethis-color-accent-info-surface`).
102
+ *
103
+ * Flat keys keep a 1:1 mapping to the emitted CSS and sidestep the
104
+ * leaf-vs-group ambiguity a nested tree creates for base/variant pairs — e.g.
105
+ * `color-neutral` coexisting with `color-neutral-weak`. References to the
106
+ * primitive layer are symbolic (`PrimitiveToken.ref`), never resolved values.
107
+ */
108
+ const semanticTokens = {
109
+ /**
110
+ * Vertical rhythm between stacked blocks. Applied as `gap` on an explicit
111
+ * flex-column "stack" container (e.g. each framework's `ElmA2ui` surface,
112
+ * `ElmMarkdown`, and container child slots like Callout/BlockQuote/Toggle/
113
+ * TabPanel) — never as a leading margin on individual leaf components.
114
+ * `gap` only ever applies between items, so there's no first-child case to
115
+ * special-case and no risk of a standalone/nested component floating an
116
+ * unexplained gap above it.
117
+ */
118
+ "stack-gap": common("2rem"),
119
+ "box-shadow-small": common("0 0 1px var(--elmethis-color-box-shadow)"),
120
+ "box-shadow-medium": common("0 0 2px var(--elmethis-color-box-shadow)"),
121
+ "box-shadow-large": common("0 0 4px var(--elmethis-color-box-shadow)"),
122
+ "font-family-sans": common(font.family.sans),
123
+ "font-family-monospace": common(font.family.monospace),
124
+ "color-box-shadow": theme("oklch(from #3e434b l c h / 0.25)", color.slate[900]),
125
+ "color-accent-link-surface": theme(color.blue[100], color.blue[900]),
126
+ "color-accent-link": common(color.blue[500]),
127
+ "color-accent-link-visited": common(color.purple[500]),
128
+ "color-accent-link-surface-visited": theme(color.purple[100], color.purple[900]),
129
+ "color-accent-info": common(color.blue[500]),
130
+ "color-accent-info-surface": theme(color.blue[100], color.blue[900]),
131
+ "color-accent-success": common(color.green[500]),
132
+ "color-accent-success-surface": theme(color.green[100], color.green[900]),
133
+ "color-accent-important": common(color.purple[500]),
134
+ "color-accent-important-surface": theme(color.purple[100], color.purple[900]),
135
+ "color-accent-warning": common(color.yellow[500]),
136
+ "color-accent-warning-surface": theme(color.yellow[100], color.yellow[900]),
137
+ "color-accent-error": common(color.red[500]),
138
+ "color-accent-error-surface": theme(color.red[100], color.red[900]),
139
+ "color-divider": theme(color.gold[300], color.slate[800]),
140
+ "color-modal-backdrop": common("oklch(from black l c h / 50%)"),
141
+ "color-surface-sunken": theme(color.gold[300], color.slate[800]),
142
+ "color-surface-base": theme(color.gold[200], color.slate[700]),
143
+ "color-surface-raised": theme(color.gold[100], color.slate[600]),
144
+ "color-neutral": theme(color.slate[400], color.slate[200]),
145
+ "color-neutral-weak": common(color.slate[300]),
146
+ "color-neutral-strong": theme(color.slate[500], color.slate[100]),
147
+ "color-primary": theme(color.gold[700], color.gold[500]),
148
+ "color-primary-weak": common(color.gold[600]),
149
+ "color-primary-strong": theme(color.gold[800], color.gold[400]),
150
+ "color-primary-hover": common("oklch(from var(--elmethis-color-primary) l c h / 15%)"),
151
+ "color-selection": common("oklch(from var(--elmethis-color-primary) l c h / 25%)"),
152
+ "color-display-red": common(color.red[500]),
153
+ "color-display-red-surface": theme(color.red[100], color.red[900]),
154
+ "color-display-orange": common(color.orange[500]),
155
+ "color-display-orange-surface": theme(color.orange[100], color.orange[900]),
156
+ "color-display-yellow": common(color.yellow[500]),
157
+ "color-display-yellow-surface": theme(color.yellow[100], color.yellow[900]),
158
+ "color-display-green": common(color.green[500]),
159
+ "color-display-green-surface": theme(color.green[100], color.green[900]),
160
+ "color-display-cyan": common(color.cyan[500]),
161
+ "color-display-cyan-surface": theme(color.cyan[100], color.cyan[900]),
162
+ "color-display-blue": common(color.blue[500]),
163
+ "color-display-blue-surface": theme(color.blue[100], color.blue[900]),
164
+ "color-display-purple": common(color.purple[500]),
165
+ "color-display-purple-surface": theme(color.purple[100], color.purple[900]),
166
+ "color-display-magenta": common(color.magenta[500]),
167
+ "color-display-magenta-surface": theme(color.magenta[100], color.magenta[900])
168
+ };
169
+ //#endregion
170
+ export { primitive, semanticTokens };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elmethis/core",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "author": {
5
5
  "name": "Ikuma Yamashita",
6
6
  "url": "https://www.ikuma.cloud/"
@@ -24,6 +24,26 @@
24
24
  "default": "./dist/index.cjs"
25
25
  }
26
26
  },
27
+ "./tokens": {
28
+ "import": {
29
+ "types": "./dist/tokens.d.mts",
30
+ "default": "./dist/tokens.mjs"
31
+ },
32
+ "require": {
33
+ "types": "./dist/tokens.d.cts",
34
+ "default": "./dist/tokens.cjs"
35
+ }
36
+ },
37
+ "./stylelint": {
38
+ "import": {
39
+ "types": "./dist/stylelint.d.mts",
40
+ "default": "./dist/stylelint.mjs"
41
+ },
42
+ "require": {
43
+ "types": "./dist/stylelint.d.cts",
44
+ "default": "./dist/stylelint.cjs"
45
+ }
46
+ },
27
47
  "./tokens.css": "./dist/tokens.css"
28
48
  },
29
49
  "files": [
@@ -40,13 +60,16 @@
40
60
  "zod": "^3"
41
61
  },
42
62
  "dependencies": {
63
+ "stylelint-config-css-modules": "^4.6.0",
64
+ "stylelint-config-standard": "^40.0.0",
65
+ "stylelint-value-no-unknown-custom-properties": "^6.1.1",
43
66
  "zod-to-json-schema": "^3.25.2"
44
67
  },
45
68
  "devDependencies": {
46
69
  "@a2ui/web_core": "^0.10.5",
47
70
  "@eslint/js": "latest",
48
- "@types/node": "26.1.1",
49
- "@vanilla-extract/css": "^1.21.1",
71
+ "@types/node": "26.1.2",
72
+ "@vanilla-extract/css": "^1.21.2",
50
73
  "@vanilla-extract/esbuild-plugin": "^2.3.22",
51
74
  "@vitest/coverage-v8": "^4.1.10",
52
75
  "ajv": "^8.17.1",