@lmring/theme 1.0.0 → 1.1.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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2025] [lmring]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmring/theme",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "LMRing theme engine, tokens, presets, and CSS variable generation utilities.",
5
5
  "license": "Apache-2.0",
6
6
  "private": false,
@@ -34,21 +34,21 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/llm-ring/lmring/issues"
36
36
  },
37
- "scripts": {
38
- "build": "tsdown",
39
- "dev": "tsdown --watch",
40
- "test": "vitest run"
41
- },
42
37
  "dependencies": {
43
38
  "culori": "^4.0.1"
44
39
  },
45
40
  "devDependencies": {
46
- "@lmring/typescript-config": "workspace:*",
47
- "@lmring/vitest-config": "workspace:*",
48
- "@vitest/coverage-v8": "^4.1.0",
41
+ "@vitest/coverage-v8": "^4.1.2",
49
42
  "fast-check": "^4.6.0",
50
- "tsdown": "0.21.4",
51
- "typescript": "^5.9.3",
52
- "vitest": "^4.1.0"
43
+ "tsdown": "0.21.6",
44
+ "typescript": "^6.0.2",
45
+ "vitest": "^4.1.2",
46
+ "@lmring/typescript-config": "1.5.0",
47
+ "@lmring/vitest-config": "1.5.0"
48
+ },
49
+ "scripts": {
50
+ "build": "tsdown",
51
+ "dev": "tsdown --watch",
52
+ "test": "vitest run"
53
53
  }
54
- }
54
+ }
package/src/theme.css CHANGED
@@ -1,89 +1,89 @@
1
- /* @lmring/theme static design tokens. */
2
-
3
- @theme {
4
- /* Spacing scale (4px grid). */
5
- --spacing-0: 0px;
6
- --spacing-1: 4px;
7
- --spacing-2: 8px;
8
- --spacing-3: 12px;
9
- --spacing-4: 16px;
10
- --spacing-5: 20px;
11
- --spacing-6: 24px;
12
- --spacing-8: 32px;
13
- --spacing-10: 40px;
14
- --spacing-12: 48px;
15
- --spacing-16: 64px;
16
-
17
- /* Radius scale. */
18
- --radius: 0.625rem;
19
- --radius-sm: calc(var(--radius) - 4px);
20
- --radius-md: calc(var(--radius) - 2px);
21
- --radius-lg: var(--radius);
22
- --radius-xl: calc(var(--radius) + 4px);
23
- --radius-2xl: calc(var(--radius) + 8px);
24
-
25
- /* Shadow levels. */
26
- --shadow-sm: 0 1px 2px oklch(0 0 0 / 3%), 0 1px 3px oklch(0 0 0 / 2%);
27
- --shadow-md:
28
- 0 2px 4px oklch(0 0 0 / 3%),
29
- 0 4px 8px oklch(0 0 0 / 3%),
30
- 0 8px 16px oklch(0 0 0 / 2%);
31
- --shadow-lg:
32
- 0 4px 8px oklch(0 0 0 / 3%),
33
- 0 8px 16px oklch(0 0 0 / 3%),
34
- 0 16px 32px oklch(0 0 0 / 4%),
35
- 0 32px 64px oklch(0 0 0 / 2%);
36
-
37
- /* Typography scale. */
38
- --text-xs: 0.75rem;
39
- --text-sm: 0.875rem;
40
- --text-base: 1rem;
41
- --text-lg: 1.125rem;
42
- --text-xl: 1.25rem;
43
- --text-2xl: 1.5rem;
44
- --text-3xl: 1.875rem;
45
- --text-4xl: 2.25rem;
46
-
47
- /* Line-height scale. */
48
- --leading-tight: 1.25;
49
- --leading-snug: 1.375;
50
- --leading-normal: 1.5;
51
- --leading-relaxed: 1.625;
52
- --leading-loose: 1.75;
53
-
54
- /* Motion tokens. */
55
- --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
56
- --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
57
- --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
58
-
59
- --duration-fast: 150ms;
60
- --duration-normal: 200ms;
61
- --duration-slow: 300ms;
62
- --duration-slower: 500ms;
63
- }
64
-
65
- :root {
66
- /* Surface layer tokens for light mode. */
67
- --surface: oklch(1 0 0);
68
- --elevated: oklch(0.99 0.002 264);
69
- --overlay: oklch(0.97 0.005 264);
70
- }
71
-
72
- .dark {
73
- /* Surface layer tokens for dark mode. */
74
- --surface: oklch(0.18 0.01 264);
75
- --elevated: oklch(0.22 0.01 264);
76
- --overlay: oklch(0.28 0.01 264);
77
-
78
- /* Dark-mode shadow variants. */
79
- --shadow-sm: 0 1px 2px oklch(0 0 0 / 20%), 0 1px 3px oklch(0 0 0 / 15%);
80
- --shadow-md:
81
- 0 2px 4px oklch(0 0 0 / 24%),
82
- 0 4px 8px oklch(0 0 0 / 20%),
83
- 0 8px 16px oklch(0 0 0 / 16%);
84
- --shadow-lg:
85
- 0 4px 8px oklch(0 0 0 / 28%),
86
- 0 8px 16px oklch(0 0 0 / 24%),
87
- 0 16px 32px oklch(0 0 0 / 20%),
88
- 0 32px 64px oklch(0 0 0 / 16%);
89
- }
1
+ /* @lmring/theme static design tokens. */
2
+
3
+ @theme {
4
+ /* Spacing scale (4px grid). */
5
+ --spacing-0: 0px;
6
+ --spacing-1: 4px;
7
+ --spacing-2: 8px;
8
+ --spacing-3: 12px;
9
+ --spacing-4: 16px;
10
+ --spacing-5: 20px;
11
+ --spacing-6: 24px;
12
+ --spacing-8: 32px;
13
+ --spacing-10: 40px;
14
+ --spacing-12: 48px;
15
+ --spacing-16: 64px;
16
+
17
+ /* Radius scale. */
18
+ --radius: 0.625rem;
19
+ --radius-sm: calc(var(--radius) - 4px);
20
+ --radius-md: calc(var(--radius) - 2px);
21
+ --radius-lg: var(--radius);
22
+ --radius-xl: calc(var(--radius) + 4px);
23
+ --radius-2xl: calc(var(--radius) + 8px);
24
+
25
+ /* Shadow levels. */
26
+ --shadow-sm: 0 1px 2px oklch(0 0 0 / 3%), 0 1px 3px oklch(0 0 0 / 2%);
27
+ --shadow-md:
28
+ 0 2px 4px oklch(0 0 0 / 3%),
29
+ 0 4px 8px oklch(0 0 0 / 3%),
30
+ 0 8px 16px oklch(0 0 0 / 2%);
31
+ --shadow-lg:
32
+ 0 4px 8px oklch(0 0 0 / 3%),
33
+ 0 8px 16px oklch(0 0 0 / 3%),
34
+ 0 16px 32px oklch(0 0 0 / 4%),
35
+ 0 32px 64px oklch(0 0 0 / 2%);
36
+
37
+ /* Typography scale. */
38
+ --text-xs: 0.75rem;
39
+ --text-sm: 0.875rem;
40
+ --text-base: 1rem;
41
+ --text-lg: 1.125rem;
42
+ --text-xl: 1.25rem;
43
+ --text-2xl: 1.5rem;
44
+ --text-3xl: 1.875rem;
45
+ --text-4xl: 2.25rem;
46
+
47
+ /* Line-height scale. */
48
+ --leading-tight: 1.25;
49
+ --leading-snug: 1.375;
50
+ --leading-normal: 1.5;
51
+ --leading-relaxed: 1.625;
52
+ --leading-loose: 1.75;
53
+
54
+ /* Motion tokens. */
55
+ --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
56
+ --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
57
+ --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
58
+
59
+ --duration-fast: 150ms;
60
+ --duration-normal: 200ms;
61
+ --duration-slow: 300ms;
62
+ --duration-slower: 500ms;
63
+ }
64
+
65
+ :root {
66
+ /* Surface layer tokens for light mode. */
67
+ --surface: oklch(1 0 0);
68
+ --elevated: oklch(0.99 0.002 264);
69
+ --overlay: oklch(0.97 0.005 264);
70
+ }
71
+
72
+ .dark {
73
+ /* Surface layer tokens for dark mode. */
74
+ --surface: oklch(0.18 0.01 264);
75
+ --elevated: oklch(0.22 0.01 264);
76
+ --overlay: oklch(0.28 0.01 264);
77
+
78
+ /* Dark-mode shadow variants. */
79
+ --shadow-sm: 0 1px 2px oklch(0 0 0 / 20%), 0 1px 3px oklch(0 0 0 / 15%);
80
+ --shadow-md:
81
+ 0 2px 4px oklch(0 0 0 / 24%),
82
+ 0 4px 8px oklch(0 0 0 / 20%),
83
+ 0 8px 16px oklch(0 0 0 / 16%);
84
+ --shadow-lg:
85
+ 0 4px 8px oklch(0 0 0 / 28%),
86
+ 0 8px 16px oklch(0 0 0 / 24%),
87
+ 0 16px 32px oklch(0 0 0 / 20%),
88
+ 0 32px 64px oklch(0 0 0 / 16%);
89
+ }
package/dist/index.d.ts DELETED
@@ -1,253 +0,0 @@
1
- //#region src/types.d.ts
2
- /**
3
- * Core type definitions for @lmring/theme
4
- *
5
- * All color values use the OKLCH color space for perceptual uniformity.
6
- */
7
- /** A color in the OKLCH color space. */
8
- interface OklchColor {
9
- /** Lightness: 0–1 */
10
- l: number;
11
- /** Chroma: 0–0.4 */
12
- c: number;
13
- /** Hue: 0–360 */
14
- h: number;
15
- }
16
- /** Full set of semantic color slots used by the design system. */
17
- interface SemanticPalette {
18
- primary: OklchColor;
19
- primaryForeground: OklchColor;
20
- secondary: OklchColor;
21
- secondaryForeground: OklchColor;
22
- accent: OklchColor;
23
- accentForeground: OklchColor;
24
- muted: OklchColor;
25
- mutedForeground: OklchColor;
26
- destructive: OklchColor;
27
- destructiveForeground: OklchColor;
28
- background: OklchColor;
29
- foreground: OklchColor;
30
- card: OklchColor;
31
- cardForeground: OklchColor;
32
- border: OklchColor;
33
- input: OklchColor;
34
- ring: OklchColor;
35
- }
36
- /** Light and dark mode palettes derived from a seed color. */
37
- interface ThemePalette {
38
- light: SemanticPalette;
39
- dark: SemanticPalette;
40
- }
41
- /** Serializable theme configuration stored in localStorage / server DB. */
42
- interface PersistedThemeConfig {
43
- mode: 'light' | 'dark' | 'system';
44
- seedColor: OklchColor;
45
- presetName: string | null;
46
- }
47
- /** A named preset theme with its OKLCH seed parameters. */
48
- interface ThemePreset {
49
- name: string;
50
- hue: number;
51
- chroma: number;
52
- lightness: number;
53
- }
54
- //#endregion
55
- //#region src/color-convert.d.ts
56
- /**
57
- * Convert a HEX color string to an OKLCH color object.
58
- *
59
- * @param hex - A valid 3 or 6 digit HEX string with `#` prefix (e.g. `#ff0000`, `#f00`)
60
- * @returns The color in OKLCH space
61
- * @throws If the HEX string is invalid
62
- */
63
- declare function hexToOklch(hex: string): OklchColor;
64
- /**
65
- * Convert an OKLCH color object back to a 6-digit HEX string.
66
- *
67
- * @param color - An OKLCH color
68
- * @returns A HEX string like `#rrggbb`
69
- */
70
- declare function oklchToHex(color: OklchColor): string;
71
- /**
72
- * Format an OKLCH color as a CSS `oklch()` function string.
73
- *
74
- * @param color - An OKLCH color
75
- * @returns A string like `oklch(0.5 0.2 270)`
76
- */
77
- declare function oklchToCss(color: OklchColor): string;
78
- //#endregion
79
- //#region src/contrast.d.ts
80
- /**
81
- * Compute the WCAG 2.1 relative luminance of an OKLCH color.
82
- *
83
- * Converts the color to sRGB, linearizes each channel, then applies
84
- * the standard luminance coefficients: 0.2126·R + 0.7152·G + 0.0722·B.
85
- *
86
- * @param color - An OKLCH color
87
- * @returns Relative luminance in [0, 1]
88
- */
89
- declare function getRelativeLuminance(color: OklchColor): number;
90
- /**
91
- * Compute the WCAG 2.1 contrast ratio between two OKLCH colors.
92
- *
93
- * The ratio is always ≥ 1, with 21:1 being the maximum (black on white).
94
- *
95
- * @param fg - Foreground color
96
- * @param bg - Background color
97
- * @returns Contrast ratio (e.g. 4.5 means 4.5:1)
98
- */
99
- declare function getContrastRatio(fg: OklchColor, bg: OklchColor): number;
100
- /**
101
- * Check whether two OKLCH colors meet the WCAG 2.1 AA contrast requirement.
102
- *
103
- * - Normal text: contrast ratio ≥ 4.5:1
104
- * - Large text (≥ 18pt or ≥ 14pt bold): contrast ratio ≥ 3.0:1
105
- *
106
- * @param fg - Foreground color
107
- * @param bg - Background color
108
- * @param isLargeText - Whether the text qualifies as "large" under WCAG
109
- * @returns `true` if the pair meets WCAG AA
110
- */
111
- declare function meetsWcagAA(fg: OklchColor, bg: OklchColor, isLargeText: boolean): boolean;
112
- //#endregion
113
- //#region src/color-engine.d.ts
114
- /**
115
- * Generate a complete light + dark semantic palette from a seed OKLCH color.
116
- *
117
- * The seed color's hue drives the entire palette. Lightness and chroma
118
- * are adjusted per semantic role according to the design system rules.
119
- *
120
- * @param seed - The user-chosen seed color in OKLCH space
121
- * @returns A `ThemePalette` with `light` and `dark` semantic palettes
122
- */
123
- declare function generatePalette(seed: OklchColor): ThemePalette;
124
- /**
125
- * Deep-merge partial overrides into a base palette.
126
- *
127
- * Overridden keys take the override value; all other keys are preserved
128
- * from the base. Always returns a new object (no mutation).
129
- *
130
- * @param base - The base palette to start from
131
- * @param overrides - Partial light/dark overrides to apply
132
- * @returns A new `ThemePalette` with overrides merged in
133
- */
134
- declare function mergePalette(base: ThemePalette, overrides: Partial<{
135
- light: Partial<SemanticPalette>;
136
- dark: Partial<SemanticPalette>;
137
- }>): ThemePalette;
138
- //#endregion
139
- //#region src/presets.d.ts
140
- /**
141
- * All available preset themes.
142
- *
143
- * Each preset uses a default chroma of 0.18 and lightness of 0.55,
144
- * varying only in hue to produce distinct color families.
145
- */
146
- declare const presets: ThemePreset[];
147
- /**
148
- * Look up a preset by name and return its generated palette.
149
- *
150
- * @param name - Kebab-case preset name (e.g. 'ocean-blue', 'violet')
151
- * @returns The full light + dark `ThemePalette` for the preset
152
- * @throws {Error} If no preset matches the given name
153
- */
154
- declare function getPreset(name: string): ThemePalette;
155
- //#endregion
156
- //#region src/tokens.d.ts
157
- /**
158
- * Design tokens for @lmring/theme
159
- *
160
- * Static design tokens covering spacing, radius, shadow, typography,
161
- * line-height (leading), easing, and duration values.
162
- *
163
- * Spacing uses a 4px base grid. All numeric spacing values (excluding 0)
164
- * are positive multiples of 4.
165
- */
166
- /** All design tokens grouped by category */
167
- declare const tokens: {
168
- readonly spacing: {
169
- readonly 0: "0px";
170
- readonly 1: "4px";
171
- readonly 2: "8px";
172
- readonly 3: "12px";
173
- readonly 4: "16px";
174
- readonly 5: "20px";
175
- readonly 6: "24px";
176
- readonly 8: "32px";
177
- readonly 10: "40px";
178
- readonly 12: "48px";
179
- readonly 16: "64px";
180
- };
181
- readonly radius: {
182
- readonly sm: "calc(var(--radius) - 4px)";
183
- readonly md: "calc(var(--radius) - 2px)";
184
- readonly lg: "var(--radius)";
185
- readonly xl: "calc(var(--radius) + 4px)";
186
- readonly '2xl': "calc(var(--radius) + 8px)";
187
- readonly full: "9999px";
188
- };
189
- readonly shadow: {
190
- readonly sm: "0 1px 2px oklch(0 0 0 / 3%), 0 1px 3px oklch(0 0 0 / 2%)";
191
- readonly md: "0 2px 4px oklch(0 0 0 / 3%), 0 4px 8px oklch(0 0 0 / 3%), 0 8px 16px oklch(0 0 0 / 2%)";
192
- readonly lg: "0 4px 8px oklch(0 0 0 / 3%), 0 8px 16px oklch(0 0 0 / 3%), 0 16px 32px oklch(0 0 0 / 4%), 0 32px 64px oklch(0 0 0 / 2%)";
193
- };
194
- readonly typography: {
195
- readonly xs: "0.75rem";
196
- readonly sm: "0.875rem";
197
- readonly base: "1rem";
198
- readonly lg: "1.125rem";
199
- readonly xl: "1.25rem";
200
- readonly '2xl': "1.5rem";
201
- readonly '3xl': "1.875rem";
202
- readonly '4xl': "2.25rem";
203
- };
204
- readonly leading: {
205
- readonly tight: "1.25";
206
- readonly snug: "1.375";
207
- readonly normal: "1.5";
208
- readonly relaxed: "1.625";
209
- readonly loose: "1.75";
210
- };
211
- readonly easing: {
212
- readonly spring: "cubic-bezier(0.34, 1.56, 0.64, 1)";
213
- readonly smooth: "cubic-bezier(0.25, 0.1, 0.25, 1)";
214
- readonly outExpo: "cubic-bezier(0.16, 1, 0.3, 1)";
215
- };
216
- readonly duration: {
217
- readonly fast: "150ms";
218
- readonly normal: "200ms";
219
- readonly slow: "300ms";
220
- readonly slower: "500ms";
221
- };
222
- };
223
- //#endregion
224
- //#region src/css-generator.d.ts
225
- /**
226
- * Convert a SemanticPalette into a Record of CSS custom properties.
227
- *
228
- * Each key in the palette is converted from camelCase to a `--kebab-case`
229
- * CSS variable name, and each value is formatted as an `oklch(l c h)` string.
230
- *
231
- * @param palette - A semantic palette (light or dark)
232
- * @returns A record mapping CSS variable names to OKLCH CSS values
233
- *
234
- * @example
235
- * paletteToCssVars(palette)
236
- * // { '--primary': 'oklch(0.55 0.18 255)', '--primary-foreground': 'oklch(1 0 0)', ... }
237
- */
238
- declare function paletteToCssVars(palette: SemanticPalette): Record<string, string>;
239
- //#endregion
240
- //#region src/persistence.d.ts
241
- /** Serialize a theme config to a JSON string. */
242
- declare function serialize(config: PersistedThemeConfig): string;
243
- /**
244
- * Deserialize a raw JSON string into a validated {@link PersistedThemeConfig}.
245
- *
246
- * Returns `null` when:
247
- * - the string is not valid JSON
248
- * - any field fails validation (mode enum, OKLCH ranges, presetName type)
249
- */
250
- declare function deserialize(raw: string): PersistedThemeConfig | null;
251
- //#endregion
252
- export { type OklchColor, type PersistedThemeConfig, type SemanticPalette, type ThemePalette, type ThemePreset, deserialize, generatePalette, getContrastRatio, getPreset, getRelativeLuminance, hexToOklch, meetsWcagAA, mergePalette, oklchToCss, oklchToHex, paletteToCssVars, presets, serialize, tokens };
253
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/color-convert.ts","../src/contrast.ts","../src/color-engine.ts","../src/presets.ts","../src/tokens.ts","../src/css-generator.ts","../src/persistence.ts"],"mappings":";;AAOA;;;;;UAAiB,UAAA;EAMf;EAJA,CAAA;EAIC;EAFD,CAAA;EAM8B;EAJ9B,CAAA;AAAA;;UAIe,eAAA;EACf,OAAA,EAAS,UAAA;EACT,iBAAA,EAAmB,UAAA;EACnB,SAAA,EAAW,UAAA;EACX,mBAAA,EAAqB,UAAA;EACrB,MAAA,EAAQ,UAAA;EACR,gBAAA,EAAkB,UAAA;EAClB,KAAA,EAAO,UAAA;EACP,eAAA,EAAiB,UAAA;EACjB,WAAA,EAAa,UAAA;EACb,qBAAA,EAAuB,UAAA;EACvB,UAAA,EAAY,UAAA;EACZ,UAAA,EAAY,UAAA;EACZ,IAAA,EAAM,UAAA;EACN,cAAA,EAAgB,UAAA;EAChB,MAAA,EAAQ,UAAA;EACR,KAAA,EAAO,UAAA;EACP,IAAA,EAAM,UAAA;AAAA;;UAIS,YAAA;EACf,KAAA,EAAO,eAAA;EACP,IAAA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conversion utilities.
6
- *
7
- * Converts between HEX, OKLCH, and CSS string representations
8
- * using the `culori` library for accurate color math.
9
- */
10
- const toOklch = converter("oklch");
11
- const HEX_REGEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
12
- /**
13
- * Validate that a string is a valid HEX color (#RGB or #RRGGBB).
14
- * Throws if the format is invalid.
15
- */
16
- function assertValidHex(hex) {
17
- if (!HEX_REGEX.test(hex)) throw new Error(`Invalid HEX color: "${hex}". Expected format: #RGB or #RRGGBB.`);
18
- }
19
- /**
20
- * Convert a HEX color string to an OKLCH color object.
21
- *
22
- * @param hex - A valid 3 or 6 digit HEX string with `#` prefix (e.g. `#ff0000`, `#f00`)
23
- * @returns The color in OKLCH space
24
- * @throws If the HEX string is invalid
25
- */
26
- function hexToOklch(hex) {
27
- assertValidHex(hex);
28
- const result = toOklch(hex);
29
- if (!result) throw new Error(`Failed to convert HEX "${hex}" to OKLCH.`);
30
- return {
31
- l: result.l,
32
- c: result.c ?? 0,
33
- h: result.h ?? 0
34
- };
35
- }
36
- /**
37
- * Convert an OKLCH color object back to a 6-digit HEX string.
38
- *
39
- * @param color - An OKLCH color
40
- * @returns A HEX string like `#rrggbb`
41
- */
42
- function oklchToHex(color) {
43
- return formatHex({
44
- mode: "oklch",
45
- l: color.l,
46
- c: color.c,
47
- h: color.h
48
- });
49
- }
50
- /**
51
- * Format an OKLCH color as a CSS `oklch()` function string.
52
- *
53
- * @param color - An OKLCH color
54
- * @returns A string like `oklch(0.5 0.2 270)`
55
- */
56
- function oklchToCss(color) {
57
- return `oklch(${color.l} ${color.c} ${color.h})`;
58
- }
59
-
60
- //#endregion
61
- //#region src/contrast.ts
62
- /**
63
- * WCAG 2.1 contrast ratio utilities.
64
- *
65
- * Computes relative luminance and contrast ratios for OKLCH colors
66
- * by converting through sRGB, following the WCAG 2.1 specification.
67
- */
68
- const toRgb = converter("rgb");
69
- /**
70
- * Linearize a single sRGB channel value for luminance calculation.
71
- *
72
- * @param c - sRGB channel value in [0, 1]
73
- * @returns Linear RGB value
74
- */
75
- function linearize(c) {
76
- return c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4;
77
- }
78
- /**
79
- * Compute the WCAG 2.1 relative luminance of an OKLCH color.
80
- *
81
- * Converts the color to sRGB, linearizes each channel, then applies
82
- * the standard luminance coefficients: 0.2126·R + 0.7152·G + 0.0722·B.
83
- *
84
- * @param color - An OKLCH color
85
- * @returns Relative luminance in [0, 1]
86
- */
87
- function getRelativeLuminance(color) {
88
- const rgb = toRgb({
89
- mode: "oklch",
90
- l: color.l,
91
- c: color.c,
92
- h: color.h
93
- });
94
- if (!rgb) return 0;
95
- const r = linearize(Math.max(0, Math.min(1, rgb.r)));
96
- const g = linearize(Math.max(0, Math.min(1, rgb.g)));
97
- const b = linearize(Math.max(0, Math.min(1, rgb.b)));
98
- return .2126 * r + .7152 * g + .0722 * b;
99
- }
100
- /**
101
- * Compute the WCAG 2.1 contrast ratio between two OKLCH colors.
102
- *
103
- * The ratio is always ≥ 1, with 21:1 being the maximum (black on white).
104
- *
105
- * @param fg - Foreground color
106
- * @param bg - Background color
107
- * @returns Contrast ratio (e.g. 4.5 means 4.5:1)
108
- */
109
- function getContrastRatio(fg, bg) {
110
- const l1 = getRelativeLuminance(fg);
111
- const l2 = getRelativeLuminance(bg);
112
- const lighter = Math.max(l1, l2);
113
- const darker = Math.min(l1, l2);
114
- return (lighter + .05) / (darker + .05);
115
- }
116
- /**
117
- * Check whether two OKLCH colors meet the WCAG 2.1 AA contrast requirement.
118
- *
119
- * - Normal text: contrast ratio ≥ 4.5:1
120
- * - Large text (≥ 18pt or ≥ 14pt bold): contrast ratio ≥ 3.0:1
121
- *
122
- * @param fg - Foreground color
123
- * @param bg - Background color
124
- * @param isLargeText - Whether the text qualifies as "large" under WCAG
125
- * @returns `true` if the pair meets WCAG AA
126
- */
127
- function meetsWcagAA(fg, bg, isLargeText) {
128
- const ratio = getContrastRatio(fg, bg);
129
- return isLargeText ? ratio >= 3 : ratio >= 4.5;
130
- }
131
-
132
- //#endregion
133
- //#region src/color-engine.ts
134
- /**
135
- * Clamp a number to the given range.
136
- */
137
- function clamp(value, min, max) {
138
- return Math.min(max, Math.max(min, value));
139
- }
140
- /**
141
- * Normalize a hue value to [0, 360).
142
- */
143
- function normalizeHue(h) {
144
- return (h % 360 + 360) % 360;
145
- }
146
- /**
147
- * Create a valid OklchColor with clamped values.
148
- */
149
- function oklch(l, c, h) {
150
- return {
151
- l: clamp(l, 0, 1),
152
- c: clamp(c, 0, .4),
153
- h: normalizeHue(h)
154
- };
155
- }
156
- /**
157
- * Derive the light-mode semantic palette from a seed color.
158
- */
159
- function generateLightPalette(seed) {
160
- const h = normalizeHue(seed.h);
161
- const primary = oklch(.52, seed.c, h);
162
- return {
163
- primary,
164
- primaryForeground: oklch(1, 0, h),
165
- secondary: oklch(.96, .005, h),
166
- secondaryForeground: oklch(.25, .015, h),
167
- accent: oklch(.96, .01, h),
168
- accentForeground: oklch(.25, .015, h),
169
- muted: oklch(.96, .005, h),
170
- mutedForeground: oklch(.58, .01, h),
171
- destructive: oklch(.55, .22, 25),
172
- destructiveForeground: oklch(1, 0, 25),
173
- background: oklch(.98, .002, h),
174
- foreground: oklch(.2, .015, h),
175
- card: oklch(1, 0, h),
176
- cardForeground: oklch(.2, .015, h),
177
- border: oklch(.9, .005, h),
178
- input: oklch(.95, .005, h),
179
- ring: primary
180
- };
181
- }
182
- /**
183
- * Derive the dark-mode semantic palette from a seed color.
184
- *
185
- * Uses a layered surface system with increasing lightness:
186
- * Layer 0 (background): L=0.14
187
- * Layer 1 (card): L=0.18
188
- * Layer 2 (elevated): L=0.22 (mapped to `input`)
189
- * Layer 3 (overlay): L=0.26 (mapped to `border` at L=0.28 per rules table)
190
- */
191
- function generateDarkPalette(seed) {
192
- const h = normalizeHue(seed.h);
193
- const primary = oklch(.45, seed.c * .9, h);
194
- return {
195
- primary,
196
- primaryForeground: oklch(.98, .005, h),
197
- secondary: oklch(.25, .01, h),
198
- secondaryForeground: oklch(.9, .005, h),
199
- accent: oklch(.28, .015, h),
200
- accentForeground: oklch(.9, .005, h),
201
- muted: oklch(.25, .01, h),
202
- mutedForeground: oklch(.72, .005, h),
203
- destructive: oklch(.6, .24, 25),
204
- destructiveForeground: oklch(.95, .01, 25),
205
- background: oklch(.14, .01, h),
206
- foreground: oklch(.95, .005, h),
207
- card: oklch(.18, .01, h),
208
- cardForeground: oklch(.95, .005, h),
209
- border: oklch(.28, .01, h),
210
- input: oklch(.22, .01, h),
211
- ring: primary
212
- };
213
- }
214
- /**
215
- * Generate a complete light + dark semantic palette from a seed OKLCH color.
216
- *
217
- * The seed color's hue drives the entire palette. Lightness and chroma
218
- * are adjusted per semantic role according to the design system rules.
219
- *
220
- * @param seed - The user-chosen seed color in OKLCH space
221
- * @returns A `ThemePalette` with `light` and `dark` semantic palettes
222
- */
223
- function generatePalette(seed) {
224
- return {
225
- light: generateLightPalette(seed),
226
- dark: generateDarkPalette(seed)
227
- };
228
- }
229
- /**
230
- * Deep-merge partial overrides into a base palette.
231
- *
232
- * Overridden keys take the override value; all other keys are preserved
233
- * from the base. Always returns a new object (no mutation).
234
- *
235
- * @param base - The base palette to start from
236
- * @param overrides - Partial light/dark overrides to apply
237
- * @returns A new `ThemePalette` with overrides merged in
238
- */
239
- function mergePalette(base, overrides) {
240
- return {
241
- light: {
242
- ...base.light,
243
- ...overrides.light
244
- },
245
- dark: {
246
- ...base.dark,
247
- ...overrides.dark
248
- }
249
- };
250
- }
251
-
252
- //#endregion
253
- //#region src/presets.ts
254
- /**
255
- * Preset theme definitions for @lmring/theme.
256
- *
257
- * Each preset is defined by its OKLCH hue angle. The color engine
258
- * generates a full semantic palette from the seed parameters.
259
- */
260
- /**
261
- * All available preset themes.
262
- *
263
- * Each preset uses a default chroma of 0.18 and lightness of 0.55,
264
- * varying only in hue to produce distinct color families.
265
- */
266
- const presets = [
267
- {
268
- name: "ocean-blue",
269
- hue: 255,
270
- chroma: .18,
271
- lightness: .55
272
- },
273
- {
274
- name: "violet",
275
- hue: 280,
276
- chroma: .18,
277
- lightness: .55
278
- },
279
- {
280
- name: "emerald",
281
- hue: 155,
282
- chroma: .18,
283
- lightness: .55
284
- },
285
- {
286
- name: "amber",
287
- hue: 75,
288
- chroma: .18,
289
- lightness: .55
290
- },
291
- {
292
- name: "rose",
293
- hue: 350,
294
- chroma: .18,
295
- lightness: .55
296
- },
297
- {
298
- name: "crimson",
299
- hue: 25,
300
- chroma: .18,
301
- lightness: .55
302
- },
303
- {
304
- name: "cyan",
305
- hue: 195,
306
- chroma: .18,
307
- lightness: .55
308
- },
309
- {
310
- name: "indigo",
311
- hue: 265,
312
- chroma: .18,
313
- lightness: .55
314
- }
315
- ];
316
- /**
317
- * Look up a preset by name and return its generated palette.
318
- *
319
- * @param name - Kebab-case preset name (e.g. 'ocean-blue', 'violet')
320
- * @returns The full light + dark `ThemePalette` for the preset
321
- * @throws {Error} If no preset matches the given name
322
- */
323
- function getPreset(name) {
324
- const preset = presets.find((p) => p.name === name);
325
- if (!preset) throw new Error(`Unknown preset "${name}". Available: ${presets.map((p) => p.name).join(", ")}`);
326
- return generatePalette({
327
- h: preset.hue,
328
- c: preset.chroma,
329
- l: preset.lightness
330
- });
331
- }
332
-
333
- //#endregion
334
- //#region src/tokens.ts
335
- /**
336
- * Design tokens for @lmring/theme
337
- *
338
- * Static design tokens covering spacing, radius, shadow, typography,
339
- * line-height (leading), easing, and duration values.
340
- *
341
- * Spacing uses a 4px base grid. All numeric spacing values (excluding 0)
342
- * are positive multiples of 4.
343
- */
344
- /** Spacing scale based on 4px grid */
345
- const spacing = {
346
- 0: "0px",
347
- 1: "4px",
348
- 2: "8px",
349
- 3: "12px",
350
- 4: "16px",
351
- 5: "20px",
352
- 6: "24px",
353
- 8: "32px",
354
- 10: "40px",
355
- 12: "48px",
356
- 16: "64px"
357
- };
358
- /** Border-radius scale with 10px (0.625rem) base */
359
- const radius = {
360
- sm: "calc(var(--radius) - 4px)",
361
- md: "calc(var(--radius) - 2px)",
362
- lg: "var(--radius)",
363
- xl: "calc(var(--radius) + 4px)",
364
- "2xl": "calc(var(--radius) + 8px)",
365
- full: "9999px"
366
- };
367
- /** Multi-layer composite shadow system (3 levels) */
368
- const shadow = {
369
- sm: "0 1px 2px oklch(0 0 0 / 3%), 0 1px 3px oklch(0 0 0 / 2%)",
370
- md: "0 2px 4px oklch(0 0 0 / 3%), 0 4px 8px oklch(0 0 0 / 3%), 0 8px 16px oklch(0 0 0 / 2%)",
371
- lg: "0 4px 8px oklch(0 0 0 / 3%), 0 8px 16px oklch(0 0 0 / 3%), 0 16px 32px oklch(0 0 0 / 4%), 0 32px 64px oklch(0 0 0 / 2%)"
372
- };
373
- /** Typography font-size scale (rem values) */
374
- const typography = {
375
- xs: "0.75rem",
376
- sm: "0.875rem",
377
- base: "1rem",
378
- lg: "1.125rem",
379
- xl: "1.25rem",
380
- "2xl": "1.5rem",
381
- "3xl": "1.875rem",
382
- "4xl": "2.25rem"
383
- };
384
- /** Line-height scale */
385
- const leading = {
386
- tight: "1.25",
387
- snug: "1.375",
388
- normal: "1.5",
389
- relaxed: "1.625",
390
- loose: "1.75"
391
- };
392
- /** CSS easing functions */
393
- const easing = {
394
- spring: "cubic-bezier(0.34, 1.56, 0.64, 1)",
395
- smooth: "cubic-bezier(0.25, 0.1, 0.25, 1)",
396
- outExpo: "cubic-bezier(0.16, 1, 0.3, 1)"
397
- };
398
- /** Animation duration values */
399
- const duration = {
400
- fast: "150ms",
401
- normal: "200ms",
402
- slow: "300ms",
403
- slower: "500ms"
404
- };
405
- /** All design tokens grouped by category */
406
- const tokens = {
407
- spacing,
408
- radius,
409
- shadow,
410
- typography,
411
- leading,
412
- easing,
413
- duration
414
- };
415
-
416
- //#endregion
417
- //#region src/css-generator.ts
418
- /**
419
- * CSS variable generator.
420
- *
421
- * Converts a SemanticPalette into CSS custom property key-value pairs
422
- * for injection into the document root element.
423
- */
424
- /**
425
- * Convert a camelCase string to kebab-case.
426
- *
427
- * @example camelToKebab('primaryForeground') // 'primary-foreground'
428
- */
429
- function camelToKebab(str) {
430
- return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
431
- }
432
- /**
433
- * Convert a SemanticPalette into a Record of CSS custom properties.
434
- *
435
- * Each key in the palette is converted from camelCase to a `--kebab-case`
436
- * CSS variable name, and each value is formatted as an `oklch(l c h)` string.
437
- *
438
- * @param palette - A semantic palette (light or dark)
439
- * @returns A record mapping CSS variable names to OKLCH CSS values
440
- *
441
- * @example
442
- * paletteToCssVars(palette)
443
- * // { '--primary': 'oklch(0.55 0.18 255)', '--primary-foreground': 'oklch(1 0 0)', ... }
444
- */
445
- function paletteToCssVars(palette) {
446
- const vars = {};
447
- for (const [key, color] of Object.entries(palette)) {
448
- const cssVarName = `--${camelToKebab(key)}`;
449
- vars[cssVarName] = oklchToCss(color);
450
- }
451
- return vars;
452
- }
453
-
454
- //#endregion
455
- //#region src/persistence.ts
456
- const VALID_MODES = new Set([
457
- "light",
458
- "dark",
459
- "system"
460
- ]);
461
- /** Serialize a theme config to a JSON string. */
462
- function serialize(config) {
463
- return JSON.stringify(config);
464
- }
465
- /**
466
- * Deserialize a raw JSON string into a validated {@link PersistedThemeConfig}.
467
- *
468
- * Returns `null` when:
469
- * - the string is not valid JSON
470
- * - any field fails validation (mode enum, OKLCH ranges, presetName type)
471
- */
472
- function deserialize(raw) {
473
- let parsed;
474
- try {
475
- parsed = JSON.parse(raw);
476
- } catch {
477
- return null;
478
- }
479
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
480
- const obj = parsed;
481
- if (!VALID_MODES.has(obj.mode)) return null;
482
- if (!isValidOklchColor(obj.seedColor)) return null;
483
- if (obj.presetName !== null && typeof obj.presetName !== "string") return null;
484
- return {
485
- mode: obj.mode,
486
- seedColor: obj.seedColor,
487
- presetName: obj.presetName
488
- };
489
- }
490
- function isValidOklchColor(value) {
491
- if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
492
- const color = value;
493
- return typeof color.l === "number" && typeof color.c === "number" && typeof color.h === "number" && color.l >= 0 && color.l <= 1 && color.c >= 0 && color.c <= .4 && color.h >= 0 && color.h <= 360;
494
- }
495
-
496
- //#endregion
497
- export { deserialize, generatePalette, getContrastRatio, getPreset, getRelativeLuminance, hexToOklch, meetsWcagAA, mergePalette, oklchToCss, oklchToHex, paletteToCssVars, presets, serialize, tokens };
498
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/color-convert.ts","../src/contrast.ts","../src/color-engine.ts","../src/presets.ts","../src/tokens.ts","../src/css-generator.ts","../src/persistence.ts"],"sourcesContent":["/**\r\n * Color space conversion utilities.\r\n *\r\n * Converts between HEX, OKLCH, and CSS string representations\r\n * using the `culori` library for accurate color math.\r\n */\r\n\r\nimport { converter, formatHex } from 'culori';\r\nimport type { OklchColor } from './types';\r\n\r\nconst toOklch = converter('oklch');\r\n\r\nconst HEX_REGEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;\r\n\r\n/**\r\n * Validate that a string is a valid HEX color (#RGB or #RRGGBB).\r\n * Throws if the format is invalid.\r\n */\r\nfunction assertValidHex(hex: string): void {\r\n if (!HEX_REGEX.test(hex)) {\r\n throw new Error(\r\n `Invalid HEX color: \"${hex}\". Expected format: #RGB or #RRGGBB.`,\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Convert a HEX color string to an OKLCH color object.\r\n *\r\n * @param hex - A valid 3 or 6 digit HEX string with `#` prefix (e.g. `#ff0000`, `#f00`)\r\n * @returns The color in OKLCH space\r\n * @throws If the HEX string is invalid\r\n */\r\nexport function hexToOklch(hex: string): OklchColor {\r\n assertValidHex(hex);\r\n const result = toOklch(hex);\r\n if (!result) {\r\n throw new Error(`Failed to convert HEX \"${hex}\" to OKLCH.`);\r\n }\r\n return {\r\n l: result.l,\r\n c: result.c ?? 0,\r\n h: result.h ?? 0,\r\n };\r\n}\r\n\r\n/**\r\n * Convert an OKLCH color object back to a 6-digit HEX string.\r\n *\r\n * @param color - An OKLCH color\r\n * @returns A HEX string like `#rrggbb`\r\n */\r\nexport function oklchToHex(color: OklchColor): string {\r\n const hex = formatHex({ mode: 'oklch', l: color.l, c: color.c, h: color.h });\r\n return hex;\r\n}\r\n\r\n/**\r\n * Format an OKLCH color as a CSS `oklch()` function string.\r\n *\r\n * @param color - An OKLCH color\r\n * @returns A string like `oklch(0.5 0.2 270)`\r\n */\r\nexport function oklchToCss(color: OklchColor): string {\r\n return `oklch(${color.l} ${color.c} ${color.h})`;\r\n}\r\n","/**\r\n * WCAG 2.1 contrast ratio utilities.\r\n *\r\n * Computes relative luminance and contrast ratios for OKLCH colors\r\n * by converting through sRGB, following the WCAG 2.1 specification.\r\n */\r\n\r\nimport { converter } from 'culori';\r\nimport type { OklchColor } from './types';\r\n\r\nconst toRgb = converter('rgb');\r\n\r\n/**\r\n * Linearize a single sRGB channel value for luminance calculation.\r\n *\r\n * @param c - sRGB channel value in [0, 1]\r\n * @returns Linear RGB value\r\n */\r\nfunction linearize(c: number): number {\r\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\r\n}\r\n\r\n/**\r\n * Compute the WCAG 2.1 relative luminance of an OKLCH color.\r\n *\r\n * Converts the color to sRGB, linearizes each channel, then applies\r\n * the standard luminance coefficients: 0.2126·R + 0.7152·G + 0.0722·B.\r\n *\r\n * @param color - An OKLCH color\r\n * @returns Relative luminance in [0, 1]\r\n */\r\nexport function getRelativeLuminance(color: OklchColor): number {\r\n const rgb = toRgb({ mode: 'oklch', l: color.l, c: color.c, h: color.h });\r\n if (!rgb) {\r\n return 0;\r\n }\r\n\r\n const r = linearize(Math.max(0, Math.min(1, rgb.r)));\r\n const g = linearize(Math.max(0, Math.min(1, rgb.g)));\r\n const b = linearize(Math.max(0, Math.min(1, rgb.b)));\r\n\r\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\r\n}\r\n\r\n/**\r\n * Compute the WCAG 2.1 contrast ratio between two OKLCH colors.\r\n *\r\n * The ratio is always ≥ 1, with 21:1 being the maximum (black on white).\r\n *\r\n * @param fg - Foreground color\r\n * @param bg - Background color\r\n * @returns Contrast ratio (e.g. 4.5 means 4.5:1)\r\n */\r\nexport function getContrastRatio(fg: OklchColor, bg: OklchColor): number {\r\n const l1 = getRelativeLuminance(fg);\r\n const l2 = getRelativeLuminance(bg);\r\n const lighter = Math.max(l1, l2);\r\n const darker = Math.min(l1, l2);\r\n return (lighter + 0.05) / (darker + 0.05);\r\n}\r\n\r\n/**\r\n * Check whether two OKLCH colors meet the WCAG 2.1 AA contrast requirement.\r\n *\r\n * - Normal text: contrast ratio ≥ 4.5:1\r\n * - Large text (≥ 18pt or ≥ 14pt bold): contrast ratio ≥ 3.0:1\r\n *\r\n * @param fg - Foreground color\r\n * @param bg - Background color\r\n * @param isLargeText - Whether the text qualifies as \"large\" under WCAG\r\n * @returns `true` if the pair meets WCAG AA\r\n */\r\nexport function meetsWcagAA(\r\n fg: OklchColor,\r\n bg: OklchColor,\r\n isLargeText: boolean,\r\n): boolean {\r\n const ratio = getContrastRatio(fg, bg);\r\n return isLargeText ? ratio >= 3.0 : ratio >= 4.5;\r\n}\r\n","/**\r\n * OKLCH palette generation engine.\r\n *\r\n * Given a seed color in OKLCH space, generates a complete semantic palette\r\n * for both light and dark modes following the design system's generation rules.\r\n */\r\n\r\nimport type { OklchColor, SemanticPalette, ThemePalette } from './types';\r\n\r\n/**\r\n * Clamp a number to the given range.\r\n */\r\nfunction clamp(value: number, min: number, max: number): number {\r\n return Math.min(max, Math.max(min, value));\r\n}\r\n\r\n/**\r\n * Normalize a hue value to [0, 360).\r\n */\r\nfunction normalizeHue(h: number): number {\r\n return ((h % 360) + 360) % 360;\r\n}\r\n\r\n/**\r\n * Create a valid OklchColor with clamped values.\r\n */\r\nfunction oklch(l: number, c: number, h: number): OklchColor {\r\n return {\r\n l: clamp(l, 0, 1),\r\n c: clamp(c, 0, 0.4),\r\n h: normalizeHue(h),\r\n };\r\n}\r\n\r\n/**\r\n * Derive the light-mode semantic palette from a seed color.\r\n */\r\nfunction generateLightPalette(seed: OklchColor): SemanticPalette {\r\n const h = normalizeHue(seed.h);\r\n\r\n const primary = oklch(0.52, seed.c, h);\r\n\r\n return {\r\n primary,\r\n primaryForeground: oklch(1.0, 0, h),\r\n secondary: oklch(0.96, 0.005, h),\r\n secondaryForeground: oklch(0.25, 0.015, h),\r\n accent: oklch(0.96, 0.01, h),\r\n accentForeground: oklch(0.25, 0.015, h),\r\n muted: oklch(0.96, 0.005, h),\r\n mutedForeground: oklch(0.58, 0.01, h),\r\n destructive: oklch(0.55, 0.22, 25),\r\n destructiveForeground: oklch(1.0, 0, 25),\r\n background: oklch(0.98, 0.002, h),\r\n foreground: oklch(0.20, 0.015, h),\r\n card: oklch(1.0, 0, h),\r\n cardForeground: oklch(0.20, 0.015, h),\r\n border: oklch(0.90, 0.005, h),\r\n input: oklch(0.95, 0.005, h),\r\n ring: primary,\r\n };\r\n}\r\n\r\n/**\r\n * Derive the dark-mode semantic palette from a seed color.\r\n *\r\n * Uses a layered surface system with increasing lightness:\r\n * Layer 0 (background): L=0.14\r\n * Layer 1 (card): L=0.18\r\n * Layer 2 (elevated): L=0.22 (mapped to `input`)\r\n * Layer 3 (overlay): L=0.26 (mapped to `border` at L=0.28 per rules table)\r\n */\r\nfunction generateDarkPalette(seed: OklchColor): SemanticPalette {\r\n const h = normalizeHue(seed.h);\r\n\r\n const primary = oklch(0.45, seed.c * 0.9, h);\r\n\r\n return {\r\n primary,\r\n primaryForeground: oklch(0.98, 0.005, h),\r\n secondary: oklch(0.25, 0.01, h),\r\n secondaryForeground: oklch(0.90, 0.005, h),\r\n accent: oklch(0.28, 0.015, h),\r\n accentForeground: oklch(0.90, 0.005, h),\r\n muted: oklch(0.25, 0.01, h),\r\n mutedForeground: oklch(0.72, 0.005, h),\r\n destructive: oklch(0.60, 0.24, 25),\r\n destructiveForeground: oklch(0.95, 0.01, 25),\r\n background: oklch(0.14, 0.01, h),\r\n foreground: oklch(0.95, 0.005, h),\r\n card: oklch(0.18, 0.01, h),\r\n cardForeground: oklch(0.95, 0.005, h),\r\n border: oklch(0.28, 0.01, h),\r\n input: oklch(0.22, 0.01, h),\r\n ring: primary,\r\n };\r\n}\r\n\r\n\r\n/**\r\n * Generate a complete light + dark semantic palette from a seed OKLCH color.\r\n *\r\n * The seed color's hue drives the entire palette. Lightness and chroma\r\n * are adjusted per semantic role according to the design system rules.\r\n *\r\n * @param seed - The user-chosen seed color in OKLCH space\r\n * @returns A `ThemePalette` with `light` and `dark` semantic palettes\r\n */\r\nexport function generatePalette(seed: OklchColor): ThemePalette {\r\n return {\r\n light: generateLightPalette(seed),\r\n dark: generateDarkPalette(seed),\r\n };\r\n}\r\n\r\n/**\r\n * Deep-merge partial overrides into a base palette.\r\n *\r\n * Overridden keys take the override value; all other keys are preserved\r\n * from the base. Always returns a new object (no mutation).\r\n *\r\n * @param base - The base palette to start from\r\n * @param overrides - Partial light/dark overrides to apply\r\n * @returns A new `ThemePalette` with overrides merged in\r\n */\r\nexport function mergePalette(\r\n base: ThemePalette,\r\n overrides: Partial<{\r\n light: Partial<SemanticPalette>;\r\n dark: Partial<SemanticPalette>;\r\n }>,\r\n): ThemePalette {\r\n return {\r\n light: { ...base.light, ...overrides.light },\r\n dark: { ...base.dark, ...overrides.dark },\r\n };\r\n}\r\n","/**\r\n * Preset theme definitions for @lmring/theme.\r\n *\r\n * Each preset is defined by its OKLCH hue angle. The color engine\r\n * generates a full semantic palette from the seed parameters.\r\n */\r\n\r\nimport { generatePalette } from './color-engine';\r\nimport type { ThemePalette, ThemePreset } from './types';\r\n\r\n/**\r\n * All available preset themes.\r\n *\r\n * Each preset uses a default chroma of 0.18 and lightness of 0.55,\r\n * varying only in hue to produce distinct color families.\r\n */\r\nexport const presets: ThemePreset[] = [\r\n { name: 'ocean-blue', hue: 255, chroma: 0.18, lightness: 0.55 },\r\n { name: 'violet', hue: 280, chroma: 0.18, lightness: 0.55 },\r\n { name: 'emerald', hue: 155, chroma: 0.18, lightness: 0.55 },\r\n { name: 'amber', hue: 75, chroma: 0.18, lightness: 0.55 },\r\n { name: 'rose', hue: 350, chroma: 0.18, lightness: 0.55 },\r\n { name: 'crimson', hue: 25, chroma: 0.18, lightness: 0.55 },\r\n { name: 'cyan', hue: 195, chroma: 0.18, lightness: 0.55 },\r\n { name: 'indigo', hue: 265, chroma: 0.18, lightness: 0.55 },\r\n];\r\n\r\n/**\r\n * Look up a preset by name and return its generated palette.\r\n *\r\n * @param name - Kebab-case preset name (e.g. 'ocean-blue', 'violet')\r\n * @returns The full light + dark `ThemePalette` for the preset\r\n * @throws {Error} If no preset matches the given name\r\n */\r\nexport function getPreset(name: string): ThemePalette {\r\n const preset = presets.find((p) => p.name === name);\r\n if (!preset) {\r\n throw new Error(\r\n `Unknown preset \"${name}\". Available: ${presets.map((p) => p.name).join(', ')}`,\r\n );\r\n }\r\n return generatePalette({ h: preset.hue, c: preset.chroma, l: preset.lightness });\r\n}\r\n","/**\r\n * Design tokens for @lmring/theme\r\n *\r\n * Static design tokens covering spacing, radius, shadow, typography,\r\n * line-height (leading), easing, and duration values.\r\n *\r\n * Spacing uses a 4px base grid. All numeric spacing values (excluding 0)\r\n * are positive multiples of 4.\r\n */\r\n\r\n/** Spacing scale based on 4px grid */\r\nconst spacing = {\r\n 0: '0px',\r\n 1: '4px',\r\n 2: '8px',\r\n 3: '12px',\r\n 4: '16px',\r\n 5: '20px',\r\n 6: '24px',\r\n 8: '32px',\r\n 10: '40px',\r\n 12: '48px',\r\n 16: '64px',\r\n} as const;\r\n\r\n/** Border-radius scale with 10px (0.625rem) base */\r\nconst radius = {\r\n sm: 'calc(var(--radius) - 4px)',\r\n md: 'calc(var(--radius) - 2px)',\r\n lg: 'var(--radius)',\r\n xl: 'calc(var(--radius) + 4px)',\r\n '2xl': 'calc(var(--radius) + 8px)',\r\n full: '9999px',\r\n} as const;\r\n\r\n/** Multi-layer composite shadow system (3 levels) */\r\nconst shadow = {\r\n sm: '0 1px 2px oklch(0 0 0 / 3%), 0 1px 3px oklch(0 0 0 / 2%)',\r\n md: '0 2px 4px oklch(0 0 0 / 3%), 0 4px 8px oklch(0 0 0 / 3%), 0 8px 16px oklch(0 0 0 / 2%)',\r\n lg: '0 4px 8px oklch(0 0 0 / 3%), 0 8px 16px oklch(0 0 0 / 3%), 0 16px 32px oklch(0 0 0 / 4%), 0 32px 64px oklch(0 0 0 / 2%)',\r\n} as const;\r\n\r\n/** Typography font-size scale (rem values) */\r\nconst typography = {\r\n xs: '0.75rem',\r\n sm: '0.875rem',\r\n base: '1rem',\r\n lg: '1.125rem',\r\n xl: '1.25rem',\r\n '2xl': '1.5rem',\r\n '3xl': '1.875rem',\r\n '4xl': '2.25rem',\r\n} as const;\r\n\r\n/** Line-height scale */\r\nconst leading = {\r\n tight: '1.25',\r\n snug: '1.375',\r\n normal: '1.5',\r\n relaxed: '1.625',\r\n loose: '1.75',\r\n} as const;\r\n\r\n/** CSS easing functions */\r\nconst easing = {\r\n spring: 'cubic-bezier(0.34, 1.56, 0.64, 1)',\r\n smooth: 'cubic-bezier(0.25, 0.1, 0.25, 1)',\r\n outExpo: 'cubic-bezier(0.16, 1, 0.3, 1)',\r\n} as const;\r\n\r\n/** Animation duration values */\r\nconst duration = {\r\n fast: '150ms',\r\n normal: '200ms',\r\n slow: '300ms',\r\n slower: '500ms',\r\n} as const;\r\n\r\n/** All design tokens grouped by category */\r\nexport const tokens = {\r\n spacing,\r\n radius,\r\n shadow,\r\n typography,\r\n leading,\r\n easing,\r\n duration,\r\n} as const;\r\n","/**\r\n * CSS variable generator.\r\n *\r\n * Converts a SemanticPalette into CSS custom property key-value pairs\r\n * for injection into the document root element.\r\n */\r\n\r\nimport { oklchToCss } from './color-convert';\r\nimport type { SemanticPalette } from './types';\r\n\r\n/**\r\n * Convert a camelCase string to kebab-case.\r\n *\r\n * @example camelToKebab('primaryForeground') // 'primary-foreground'\r\n */\r\nfunction camelToKebab(str: string): string {\r\n return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);\r\n}\r\n\r\n/**\r\n * Convert a SemanticPalette into a Record of CSS custom properties.\r\n *\r\n * Each key in the palette is converted from camelCase to a `--kebab-case`\r\n * CSS variable name, and each value is formatted as an `oklch(l c h)` string.\r\n *\r\n * @param palette - A semantic palette (light or dark)\r\n * @returns A record mapping CSS variable names to OKLCH CSS values\r\n *\r\n * @example\r\n * paletteToCssVars(palette)\r\n * // { '--primary': 'oklch(0.55 0.18 255)', '--primary-foreground': 'oklch(1 0 0)', ... }\r\n */\r\nexport function paletteToCssVars(palette: SemanticPalette): Record<string, string> {\r\n const vars: Record<string, string> = {};\r\n\r\n for (const [key, color] of Object.entries(palette)) {\r\n const cssVarName = `--${camelToKebab(key)}`;\r\n vars[cssVarName] = oklchToCss(color);\r\n }\r\n\r\n return vars;\r\n}\r\n","/**\r\n * Theme configuration serialization and deserialization.\r\n *\r\n * Provides pure-function helpers for persisting a {@link PersistedThemeConfig}\r\n * to/from JSON strings. Deserialization includes full validation so callers\r\n * can safely trust the returned value.\r\n */\r\n\r\nimport type { PersistedThemeConfig, OklchColor } from './types';\r\n\r\nconst VALID_MODES = new Set<PersistedThemeConfig['mode']>([\r\n 'light',\r\n 'dark',\r\n 'system',\r\n]);\r\n\r\n/** Serialize a theme config to a JSON string. */\r\nexport function serialize(config: PersistedThemeConfig): string {\r\n return JSON.stringify(config);\r\n}\r\n\r\n/**\r\n * Deserialize a raw JSON string into a validated {@link PersistedThemeConfig}.\r\n *\r\n * Returns `null` when:\r\n * - the string is not valid JSON\r\n * - any field fails validation (mode enum, OKLCH ranges, presetName type)\r\n */\r\nexport function deserialize(raw: string): PersistedThemeConfig | null {\r\n let parsed: unknown;\r\n try {\r\n parsed = JSON.parse(raw);\r\n } catch {\r\n return null;\r\n }\r\n\r\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\r\n return null;\r\n }\r\n\r\n const obj = parsed as Record<string, unknown>;\r\n\r\n // Validate mode\r\n if (!VALID_MODES.has(obj.mode as PersistedThemeConfig['mode'])) {\r\n return null;\r\n }\r\n\r\n // Validate seedColor\r\n if (!isValidOklchColor(obj.seedColor)) {\r\n return null;\r\n }\r\n\r\n // Validate presetName\r\n if (obj.presetName !== null && typeof obj.presetName !== 'string') {\r\n return null;\r\n }\r\n\r\n return {\r\n mode: obj.mode as PersistedThemeConfig['mode'],\r\n seedColor: obj.seedColor as OklchColor,\r\n presetName: obj.presetName as string | null,\r\n };\r\n}\r\n\r\nfunction isValidOklchColor(value: unknown): value is OklchColor {\r\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\r\n return false;\r\n }\r\n\r\n const color = value as Record<string, unknown>;\r\n\r\n return (\r\n typeof color.l === 'number' &&\r\n typeof color.c === 'number' &&\r\n typeof color.h === 'number' &&\r\n color.l >= 0 &&\r\n color.l <= 1 &&\r\n color.c >= 0 &&\r\n color.c <= 0.4 &&\r\n color.h >= 0 &&\r\n color.h <= 360\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;AAUA,MAAM,UAAU,UAAU,QAAQ;AAElC,MAAM,YAAY;;;;;AAMlB,SAAS,eAAe,KAAmB;AACzC,KAAI,CAAC,UAAU,KAAK,IAAI,CACtB,OAAM,IAAI,MACR,uBAAuB,IAAI,sCAC5B;;;;;;;;;AAWL,SAAgB,WAAW,KAAyB;AAClD,gBAAe,IAAI;CACnB,MAAM,SAAS,QAAQ,IAAI;AAC3B,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,0BAA0B,IAAI,aAAa;AAE7D,QAAO;EACL,GAAG,OAAO;EACV,GAAG,OAAO,KAAK;EACf,GAAG,OAAO,KAAK;EAChB;;;;;;;;AASH,SAAgB,WAAW,OAA2B;AAEpD,QADY,UAAU;EAAE,MAAM;EAAS,GAAG,MAAM;EAAG,GAAG,MAAM;EAAG,GAAG,MAAM;EAAG,CAAC;;;;;;;;AAU9E,SAAgB,WAAW,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