@vashu96/ui 0.0.3 → 0.0.4

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/dist/lib/cn.d.ts CHANGED
@@ -1 +1,5 @@
1
+ /**
2
+ * ClassName utility that merges Tailwind classes.
3
+ * Combines `clsx` (for conditional classes) and `tailwind-merge` (for conflict resolution).
4
+ */
1
5
  export { cn } from '@sglara/cn';
@@ -0,0 +1,85 @@
1
+ /**
2
+ * colorScheme.ts — Dynamic Color Scheme Generator with WCAG Contrast Enforcement
3
+ *
4
+ * Algorithm:
5
+ * 1. Parse hex → HSL
6
+ * 2. Derive primary shades (hover, active, subtle) by shifting lightness
7
+ * 3. If no secondary, auto-generate a split-complementary accent
8
+ * 4. Generate surface tones that harmonize with the primary hue
9
+ * 5. Derive status colors that don't clash with the primary
10
+ * 6. **Enforce WCAG 2.0 AA contrast ratios** for all foreground colors
11
+ * 7. Output as CSS custom property values
12
+ */
13
+ export interface ColorSchemeInput {
14
+ primary: string;
15
+ secondary?: string;
16
+ neutral?: string;
17
+ }
18
+ export interface ColorScheme {
19
+ primary: string;
20
+ primaryHover: string;
21
+ primaryActive: string;
22
+ primarySubtleLight: string;
23
+ primarySubtleDark: string;
24
+ /** The primary color adjusted for use as foreground text on white */
25
+ primaryOnLight: string;
26
+ /** The primary color adjusted for use as foreground text on dark surfaces */
27
+ primaryOnDark: string;
28
+ secondary: string;
29
+ surfaceBaseLight: string;
30
+ surface1Light: string;
31
+ surface2Light: string;
32
+ surface3Light: string;
33
+ surfaceBaseDark: string;
34
+ surface1Dark: string;
35
+ surface2Dark: string;
36
+ surface3Dark: string;
37
+ glassBgLight: string;
38
+ glassBgDark: string;
39
+ glassBorderLight: string;
40
+ glassBorderDark: string;
41
+ spotlightColor: string;
42
+ success: string;
43
+ warning: string;
44
+ danger: string;
45
+ info: string;
46
+ contrastInfo: ContrastInfo;
47
+ }
48
+ export interface ContrastInfo {
49
+ primaryOnWhite: number;
50
+ primaryOnDark: number;
51
+ primaryWasAdjusted: boolean;
52
+ statusOnWhite: {
53
+ success: number;
54
+ warning: number;
55
+ danger: number;
56
+ info: number;
57
+ };
58
+ }
59
+ export interface HSL {
60
+ h: number;
61
+ s: number;
62
+ l: number;
63
+ }
64
+ export declare function hexToHSL(hex: string): HSL;
65
+ export declare function hslToHex(hsl: HSL): string;
66
+ /**
67
+ * Calculates WCAG 2.0 contrast ratio between two luminances.
68
+ * Result is between 1:1 (no contrast) and 21:1 (max contrast).
69
+ */
70
+ export declare function contrastRatio(l1: number, l2: number): number;
71
+ export declare function generateColorScheme(input: ColorSchemeInput): ColorScheme;
72
+ /**
73
+ * Applies a ColorScheme to the document by injecting a dynamic <style> tag.
74
+ *
75
+ * IMPORTANT: We do NOT use inline styles (root.style.setProperty) because
76
+ * inline styles have higher CSS specificity than any selector — meaning
77
+ * the [data-theme="dark"] overrides would never take effect.
78
+ * Instead, we inject a <style> tag with :root and [data-theme="dark"] blocks.
79
+ */
80
+ export declare function applyColorScheme(scheme: ColorScheme, styleId?: string): void;
81
+ /**
82
+ * Convenience: generate + apply in one call.
83
+ */
84
+ export declare function setThemeColors(input: ColorSchemeInput, styleId?: string): ColorScheme;
85
+ export declare const PRESETS: Record<string, ColorSchemeInput>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vashu96/ui",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",