@rokkit/core 1.0.0-next.163 → 1.0.0-next.164

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/theme.ts +29 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/core",
3
- "version": "1.0.0-next.163",
3
+ "version": "1.0.0-next.164",
4
4
  "description": "Contains core utility functions and classes that can be used in various components.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,6 +46,6 @@
46
46
  "ramda": "^0.32.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@rokkit/icons": "1.0.0-next.163"
49
+ "@rokkit/icons": "1.0.0-next.164"
50
50
  }
51
51
  }
package/src/theme.ts CHANGED
@@ -211,4 +211,33 @@ export class Theme {
211
211
  getShortcuts(name) {
212
212
  return [...semanticShortcuts(name), ...contrastShortcuts(name)]
213
213
  }
214
+
215
+ /**
216
+ * Generates CSS custom property declarations for the semantic z0–z10 tone scale.
217
+ *
218
+ * Returns a CSS string with two blocks:
219
+ * - `:root` — light-mode aliases (z0=50 … z10=950)
220
+ * - `[data-mode="dark"]` — dark-mode aliases (z0=950 … z10=50)
221
+ *
222
+ * These let consumers write `var(--color-primary-z5)` instead of hardcoding
223
+ * numeric shades, and the value automatically adapts to the active mode.
224
+ */
225
+ getZScaleCSS() {
226
+ const names = Object.keys(this.#mapping)
227
+
228
+ const lightLines = names.flatMap((name) =>
229
+ Object.entries(TONE_MAP).map(
230
+ ([zone, light]) => ` --color-${name}-${zone}: var(--color-${name}-${light});`
231
+ )
232
+ )
233
+
234
+ const darkLines = names.flatMap((name) =>
235
+ Object.entries(TONE_MAP).map(([zone, light]) => {
236
+ const dark = 1000 - light
237
+ return ` --color-${name}-${zone}: var(--color-${name}-${dark});`
238
+ })
239
+ )
240
+
241
+ return `:root {\n${lightLines.join('\n')}\n}\n[data-mode="dark"] {\n${darkLines.join('\n')}\n}`
242
+ }
214
243
  }