@clhaas/palette-kit 0.1.0 → 0.1.2

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 (70) hide show
  1. package/README.md +4 -3
  2. package/dist/alpha/generateAlphaScale.d.ts +5 -0
  3. package/dist/alpha/generateAlphaScale.js +34 -0
  4. package/dist/contrast/apca.d.ts +2 -0
  5. package/dist/contrast/apca.js +5 -0
  6. package/dist/contrast/onSolid.d.ts +6 -0
  7. package/dist/contrast/onSolid.js +28 -0
  8. package/dist/contrast/solveText.d.ts +2 -0
  9. package/dist/contrast/solveText.js +31 -0
  10. package/dist/createTheme.d.ts +34 -0
  11. package/dist/createTheme.js +88 -0
  12. package/dist/data/radixSeeds.d.ts +3 -0
  13. package/dist/data/radixSeeds.js +34 -0
  14. package/dist/diagnostics/analyzeScale.d.ts +2 -0
  15. package/dist/diagnostics/analyzeScale.js +7 -0
  16. package/dist/diagnostics/analyzeTheme.d.ts +2 -0
  17. package/dist/diagnostics/analyzeTheme.js +35 -0
  18. package/dist/diagnostics/warnings.d.ts +2 -0
  19. package/dist/diagnostics/warnings.js +20 -0
  20. package/dist/engine/curves.d.ts +9 -0
  21. package/dist/engine/curves.js +48 -0
  22. package/dist/engine/oklch.d.ts +8 -0
  23. package/dist/engine/oklch.js +40 -0
  24. package/dist/engine/templates.d.ts +14 -0
  25. package/dist/engine/templates.js +45 -0
  26. package/dist/exporters/selectColorMode.d.ts +2 -0
  27. package/dist/exporters/selectColorMode.js +19 -0
  28. package/dist/exporters/toCssVars.d.ts +12 -0
  29. package/dist/exporters/toCssVars.js +84 -0
  30. package/dist/exporters/toJson.d.ts +3 -0
  31. package/dist/exporters/toJson.js +25 -0
  32. package/dist/exporters/toReactNative.d.ts +30 -0
  33. package/dist/exporters/toReactNative.js +26 -0
  34. package/dist/exporters/toTailwind.d.ts +16 -0
  35. package/dist/exporters/toTailwind.js +90 -0
  36. package/dist/exporters/toTs.d.ts +3 -0
  37. package/dist/exporters/toTs.js +28 -0
  38. package/dist/generateScale.d.ts +48 -0
  39. package/dist/generateScale.js +274 -0
  40. package/dist/index.d.ts +17 -0
  41. package/{src/index.ts → dist/index.js} +0 -15
  42. package/dist/tokens/presetRadixLikeUi.d.ts +5 -0
  43. package/dist/tokens/presetRadixLikeUi.js +55 -0
  44. package/dist/types.d.ts +59 -0
  45. package/dist/types.js +1 -0
  46. package/package.json +19 -3
  47. package/.markdownlint.json +0 -4
  48. package/biome.json +0 -43
  49. package/src/alpha/generateAlphaScale.ts +0 -43
  50. package/src/contrast/apca.ts +0 -7
  51. package/src/contrast/onSolid.ts +0 -38
  52. package/src/contrast/solveText.ts +0 -49
  53. package/src/createTheme.ts +0 -130
  54. package/src/data/radixSeeds.ts +0 -37
  55. package/src/diagnostics/analyzeScale.ts +0 -6
  56. package/src/diagnostics/analyzeTheme.ts +0 -54
  57. package/src/diagnostics/warnings.ts +0 -25
  58. package/src/engine/curves.ts +0 -64
  59. package/src/engine/oklch.ts +0 -53
  60. package/src/engine/templates.ts +0 -58
  61. package/src/exporters/selectColorMode.ts +0 -25
  62. package/src/exporters/toCssVars.ts +0 -116
  63. package/src/exporters/toJson.ts +0 -31
  64. package/src/exporters/toReactNative.ts +0 -39
  65. package/src/exporters/toTailwind.ts +0 -110
  66. package/src/exporters/toTs.ts +0 -34
  67. package/src/generateScale.ts +0 -163
  68. package/src/tokens/presetRadixLikeUi.ts +0 -75
  69. package/src/types.ts +0 -63
  70. package/tsconfig.json +0 -14
@@ -1,75 +0,0 @@
1
- import type { ColorHex, Scale, Step } from "../types.js";
2
-
3
- type TokenMapEntry = {
4
- token: string;
5
- slot: string;
6
- step: Step;
7
- required?: boolean;
8
- };
9
-
10
- const tokenMap: TokenMapEntry[] = [
11
- { token: "bg.app", slot: "neutral", step: 1 },
12
- { token: "bg.subtle", slot: "neutral", step: 2 },
13
- { token: "surface.card", slot: "neutral", step: 2 },
14
- { token: "surface.raised", slot: "neutral", step: 3 },
15
- { token: "component.bg", slot: "neutral", step: 3 },
16
- { token: "component.bgHover", slot: "neutral", step: 4 },
17
- { token: "component.bgActive", slot: "neutral", step: 5 },
18
- { token: "border.subtle", slot: "neutral", step: 6 },
19
- { token: "border.default", slot: "neutral", step: 7 },
20
- { token: "border.strong", slot: "neutral", step: 8 },
21
- { token: "text.secondary", slot: "neutral", step: 11 },
22
- { token: "text.primary", slot: "neutral", step: 12 },
23
- { token: "text.disabled", slot: "neutral", step: 10 },
24
-
25
- { token: "focus.ring", slot: "accent", step: 8 },
26
- { token: "accent.solid", slot: "accent", step: 9 },
27
- { token: "accent.solidHover", slot: "accent", step: 10 },
28
- { token: "accent.border", slot: "accent", step: 7 },
29
- { token: "accent.subtle", slot: "accent", step: 3 },
30
- { token: "accent.subtleHover", slot: "accent", step: 4 },
31
-
32
- { token: "status.success.solidBg", slot: "success", step: 9, required: false },
33
- { token: "status.success.solidHover", slot: "success", step: 10, required: false },
34
- { token: "status.success.subtleBg", slot: "success", step: 3, required: false },
35
- { token: "status.success.border", slot: "success", step: 7, required: false },
36
- { token: "status.success.text", slot: "success", step: 11, required: false },
37
- { token: "status.success.textStrong", slot: "success", step: 12, required: false },
38
-
39
- { token: "status.warning.solidBg", slot: "warning", step: 9, required: false },
40
- { token: "status.warning.solidHover", slot: "warning", step: 10, required: false },
41
- { token: "status.warning.subtleBg", slot: "warning", step: 3, required: false },
42
- { token: "status.warning.border", slot: "warning", step: 7, required: false },
43
- { token: "status.warning.text", slot: "warning", step: 11, required: false },
44
- { token: "status.warning.textStrong", slot: "warning", step: 12, required: false },
45
-
46
- { token: "status.danger.solidBg", slot: "danger", step: 9, required: false },
47
- { token: "status.danger.solidHover", slot: "danger", step: 10, required: false },
48
- { token: "status.danger.subtleBg", slot: "danger", step: 3, required: false },
49
- { token: "status.danger.border", slot: "danger", step: 7, required: false },
50
- { token: "status.danger.text", slot: "danger", step: 11, required: false },
51
- { token: "status.danger.textStrong", slot: "danger", step: 12, required: false },
52
- ];
53
-
54
- export function buildPresetTokens(scales: Record<string, Scale>): {
55
- light: Record<string, ColorHex>;
56
- dark: Record<string, ColorHex>;
57
- } {
58
- const light: Record<string, ColorHex> = {};
59
- const dark: Record<string, ColorHex> = {};
60
-
61
- for (const { token, slot, step, required } of tokenMap) {
62
- const scale = scales[slot];
63
- if (!scale) {
64
- if (required === false) {
65
- continue;
66
- }
67
- throw new Error(`Missing scale for slot: ${slot}`);
68
- }
69
-
70
- light[token] = scale.light[step];
71
- dark[token] = scale.dark[step];
72
- }
73
-
74
- return { light, dark };
75
- }
package/src/types.ts DELETED
@@ -1,63 +0,0 @@
1
- export type Step = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
2
-
3
- export type ColorHex = `#${string}`;
4
- export type ColorP3 = string;
5
-
6
- export type RadixSeedName = string;
7
-
8
- export type TemplateId = "neutral" | "warm" | "cool";
9
-
10
- export type ColorSource =
11
- | { source: "seed"; value: ColorHex }
12
- | { source: "radix"; name: RadixSeedName };
13
-
14
- export type ScaleDiagnostics = {
15
- outOfGamutCount: number;
16
- outOfP3GamutCount?: number;
17
- };
18
-
19
- export type Scale = {
20
- light: Record<Step, ColorHex>;
21
- dark: Record<Step, ColorHex>;
22
- p3?: {
23
- light: Record<Step, ColorP3>;
24
- dark: Record<Step, ColorP3>;
25
- };
26
- meta?: ScaleDiagnostics;
27
- };
28
-
29
- export type ScaleColorMode = Omit<Scale, "light" | "dark"> & {
30
- light: Record<Step, string>;
31
- dark: Record<Step, string>;
32
- };
33
-
34
- export type AlphaScale = {
35
- light: Record<Step, ColorHex>;
36
- dark: Record<Step, ColorHex>;
37
- };
38
-
39
- export type ThemeDiagnostics = {
40
- contrast: Record<string, number>;
41
- outOfGamutCount: number;
42
- warnings?: string[];
43
- };
44
-
45
- export type Theme = {
46
- scales: Record<string, Scale>;
47
- tokens: {
48
- light: Record<string, ColorHex>;
49
- dark: Record<string, ColorHex>;
50
- };
51
- alpha?: AlphaScale;
52
- diagnostics?: ThemeDiagnostics;
53
- };
54
-
55
- export type ThemeColorMode = Omit<Theme, "scales"> & {
56
- scales: Record<string, ScaleColorMode>;
57
- };
58
-
59
- export type OklchColor = {
60
- l: number;
61
- c: number;
62
- h: number;
63
- };
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "declaration": true,
7
- "strict": true,
8
- "skipLibCheck": true,
9
- "forceConsistentCasingInFileNames": true,
10
- "noEmit": true
11
- },
12
- "include": ["src/**/*.ts"],
13
- "exclude": ["examples/**", "tests/**", "node_modules/**"]
14
- }