@yuva-devlab/tokens 0.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.
Files changed (48) hide show
  1. package/.prettierignore +12 -0
  2. package/.turbo/turbo-build.log +18 -0
  3. package/CHANGELOG.md +14 -0
  4. package/README.md +56 -0
  5. package/dist/breakpoints.css.d.ts +13 -0
  6. package/dist/breakpoints.css.d.ts.map +1 -0
  7. package/dist/colors.css.d.ts +99 -0
  8. package/dist/colors.css.d.ts.map +1 -0
  9. package/dist/index.cjs +1 -0
  10. package/dist/index.d.ts +11 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +15 -0
  13. package/dist/palettes.css.d.ts +109 -0
  14. package/dist/palettes.css.d.ts.map +1 -0
  15. package/dist/radii.css.d.ts +15 -0
  16. package/dist/radii.css.d.ts.map +1 -0
  17. package/dist/shadows.css.d.ts +15 -0
  18. package/dist/shadows.css.d.ts.map +1 -0
  19. package/dist/spacing.css.d.ts +17 -0
  20. package/dist/spacing.css.d.ts.map +1 -0
  21. package/dist/themes.css.d.ts +7 -0
  22. package/dist/themes.css.d.ts.map +1 -0
  23. package/dist/tokens.css +1 -0
  24. package/dist/transitions.css.d.ts +20 -0
  25. package/dist/transitions.css.d.ts.map +1 -0
  26. package/dist/typography.css.d.ts +40 -0
  27. package/dist/typography.css.d.ts.map +1 -0
  28. package/dist/utils/color-generator.d.ts +39 -0
  29. package/dist/utils/color-generator.d.ts.map +1 -0
  30. package/dist/zindex.css.d.ts +16 -0
  31. package/dist/zindex.css.d.ts.map +1 -0
  32. package/eslint.config.js +8 -0
  33. package/package.json +46 -0
  34. package/prettier.config.js +1 -0
  35. package/src/breakpoints.css.ts +23 -0
  36. package/src/colors.css.ts +73 -0
  37. package/src/index.ts +16 -0
  38. package/src/palettes.css.ts +122 -0
  39. package/src/radii.css.ts +28 -0
  40. package/src/shadows.css.ts +28 -0
  41. package/src/spacing.css.ts +31 -0
  42. package/src/themes.css.ts +181 -0
  43. package/src/transitions.css.ts +38 -0
  44. package/src/typography.css.ts +77 -0
  45. package/src/utils/color-generator.ts +90 -0
  46. package/src/zindex.css.ts +29 -0
  47. package/tsconfig.json +12 -0
  48. package/vite.config.ts +31 -0
@@ -0,0 +1,90 @@
1
+ import {
2
+ generate,
3
+ hexToRgb,
4
+ rgbToHsl,
5
+ hslToRgb,
6
+ rgbToHex,
7
+ } from "@yuva-devlab/colors";
8
+
9
+ export interface TonalPalette {
10
+ 0: string;
11
+ 10: string;
12
+ 20: string;
13
+ 30: string;
14
+ 40: string;
15
+ 50: string;
16
+ 60: string;
17
+ 70: string;
18
+ 80: string;
19
+ 90: string;
20
+ 95: string;
21
+ 99: string;
22
+ 100: string;
23
+ }
24
+
25
+ export interface SemanticShades {
26
+ main: string;
27
+ onMain: string;
28
+ container: string;
29
+ onContainer: string;
30
+ hover: string;
31
+ active: string;
32
+ subtle: string;
33
+ }
34
+
35
+ /**
36
+ * Generates semantic shades (main, hover, active, subtle) from a single seed hex color.
37
+ *
38
+ * Mapping logic based on @yuva-devlab/colors LIGHTNESS_MAP:
39
+ * - main: Index 5 (Primary)
40
+ * - hover: Index 6 (Darker)
41
+ * - active: Index 7 (Even darker)
42
+ * - subtle: Index 0 (Very light)
43
+ */
44
+ export const generateSemanticShades = (
45
+ hex: string,
46
+ theme: "light" | "dark" = "light",
47
+ overrides?: Partial<Omit<SemanticShades, "hover" | "active" | "subtle">>,
48
+ ): SemanticShades => {
49
+ const palette = generate(hex, { theme });
50
+
51
+ // Fallback generation based on standard tonal maps
52
+ const base = {
53
+ main: theme === "light" ? palette[5] : palette[5],
54
+ onMain: theme === "light" ? "#ffffff" : "#000000",
55
+ container: theme === "light" ? palette[1] : palette[1],
56
+ onContainer: theme === "light" ? palette[9] : palette[9],
57
+ hover: theme === "light" ? palette[6] : palette[6],
58
+ active: theme === "light" ? palette[7] : palette[7],
59
+ subtle: palette[0],
60
+ };
61
+
62
+ return {
63
+ ...base,
64
+ ...overrides,
65
+ };
66
+ };
67
+
68
+ /**
69
+ * Generates a full MD3-compatible 13-shade tonal palette (0-100) from a seed color.
70
+ */
71
+ export const generateTonalPalette = (hex: string): TonalPalette => {
72
+ const tones = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 99, 100] as const;
73
+ const rgb = hexToRgb(hex);
74
+ const hsl = rgbToHsl(rgb);
75
+
76
+ const palette: Record<number, string> = {};
77
+
78
+ tones.forEach((tone) => {
79
+ // MD3 Tones are essentially lightness values
80
+ const newHsl = {
81
+ h: hsl.h,
82
+ s: hsl.s,
83
+ l: tone,
84
+ };
85
+
86
+ palette[tone] = rgbToHex(hslToRgb(newHsl));
87
+ });
88
+
89
+ return palette as unknown as TonalPalette;
90
+ };
@@ -0,0 +1,29 @@
1
+ import { createGlobalTheme, createThemeContract } from "@vanilla-extract/css";
2
+
3
+ /**
4
+ * Z-index layering system for predictable stacking.
5
+ * Semantic names for common UI layers.
6
+ */
7
+ export const zIndex = createThemeContract({
8
+ base: null,
9
+ dropdown: null,
10
+ sticky: null,
11
+ fixed: null,
12
+ overlay: null,
13
+ modal: null,
14
+ popover: null,
15
+ tooltip: null,
16
+ toast: null,
17
+ });
18
+
19
+ createGlobalTheme(":root", zIndex, {
20
+ base: "0",
21
+ dropdown: "1000",
22
+ sticky: "1100",
23
+ fixed: "1200",
24
+ overlay: "1300",
25
+ modal: "1400",
26
+ popover: "1500",
27
+ tooltip: "1600",
28
+ toast: "1700",
29
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "@yuva-devlab/typescript-config/base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "types": ["vite/client"]
9
+ },
10
+ "include": ["src"],
11
+ "exclude": ["node_modules", "dist"]
12
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { resolve } from "path";
2
+
3
+ import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
4
+ import { defineConfig } from "vite";
5
+ import dts from "vite-plugin-dts";
6
+
7
+ export default defineConfig({
8
+ plugins: [
9
+ vanillaExtractPlugin(),
10
+ dts({
11
+ include: ["src/**/*.ts"],
12
+ exclude: ["src/**/*.test.ts"],
13
+ insertTypesEntry: true,
14
+ }),
15
+ ],
16
+ build: {
17
+ lib: {
18
+ entry: resolve(__dirname, "src/index.ts"),
19
+ name: "YuvaDevlabTokens",
20
+ formats: ["es", "cjs"],
21
+ fileName: (format) => `index.${format === "es" ? "js" : "cjs"}`,
22
+ },
23
+ rollupOptions: {
24
+ external: ["@vanilla-extract/css"],
25
+ output: {
26
+ preserveModules: false,
27
+ exports: "named",
28
+ },
29
+ },
30
+ },
31
+ });