@kushagradhawan/kookie-ui 0.1.41 → 0.1.42

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 (142) hide show
  1. package/README.md +257 -60
  2. package/components.css +386 -79
  3. package/dist/cjs/components/schemas/base-button.schema.d.ts +319 -0
  4. package/dist/cjs/components/schemas/base-button.schema.d.ts.map +1 -0
  5. package/dist/cjs/components/schemas/base-button.schema.js +2 -0
  6. package/dist/cjs/components/schemas/base-button.schema.js.map +7 -0
  7. package/dist/cjs/components/schemas/button.schema.d.ts +686 -0
  8. package/dist/cjs/components/schemas/button.schema.d.ts.map +1 -0
  9. package/dist/cjs/components/schemas/button.schema.js +2 -0
  10. package/dist/cjs/components/schemas/button.schema.js.map +7 -0
  11. package/dist/cjs/components/schemas/icon-button.schema.d.ts +329 -0
  12. package/dist/cjs/components/schemas/icon-button.schema.d.ts.map +1 -0
  13. package/dist/cjs/components/schemas/icon-button.schema.js +2 -0
  14. package/dist/cjs/components/schemas/icon-button.schema.js.map +7 -0
  15. package/dist/cjs/components/schemas/index.d.ts +52 -0
  16. package/dist/cjs/components/schemas/index.d.ts.map +1 -0
  17. package/dist/cjs/components/schemas/index.js +2 -0
  18. package/dist/cjs/components/schemas/index.js.map +7 -0
  19. package/dist/cjs/components/schemas/toggle-button.schema.d.ts +1172 -0
  20. package/dist/cjs/components/schemas/toggle-button.schema.d.ts.map +1 -0
  21. package/dist/cjs/components/schemas/toggle-button.schema.js +2 -0
  22. package/dist/cjs/components/schemas/toggle-button.schema.js.map +7 -0
  23. package/dist/cjs/components/schemas/toggle-icon-button.schema.d.ts +563 -0
  24. package/dist/cjs/components/schemas/toggle-icon-button.schema.d.ts.map +1 -0
  25. package/dist/cjs/components/schemas/toggle-icon-button.schema.js +2 -0
  26. package/dist/cjs/components/schemas/toggle-icon-button.schema.js.map +7 -0
  27. package/dist/cjs/components/sheet.d.ts +1 -1
  28. package/dist/cjs/components/sheet.d.ts.map +1 -1
  29. package/dist/cjs/components/sheet.js +1 -1
  30. package/dist/cjs/components/sheet.js.map +3 -3
  31. package/dist/cjs/components/shell.d.ts +125 -164
  32. package/dist/cjs/components/shell.d.ts.map +1 -1
  33. package/dist/cjs/components/shell.js +1 -1
  34. package/dist/cjs/components/shell.js.map +3 -3
  35. package/dist/cjs/components/sidebar.d.ts +1 -7
  36. package/dist/cjs/components/sidebar.d.ts.map +1 -1
  37. package/dist/cjs/components/sidebar.js +1 -1
  38. package/dist/cjs/components/sidebar.js.map +3 -3
  39. package/dist/cjs/components/theme.d.ts +3 -0
  40. package/dist/cjs/components/theme.d.ts.map +1 -1
  41. package/dist/cjs/components/theme.js +1 -1
  42. package/dist/cjs/components/theme.js.map +3 -3
  43. package/dist/cjs/components/theme.props.d.ts +10 -0
  44. package/dist/cjs/components/theme.props.d.ts.map +1 -1
  45. package/dist/cjs/components/theme.props.js +1 -1
  46. package/dist/cjs/components/theme.props.js.map +3 -3
  47. package/dist/cjs/helpers/font-config.d.ts +96 -0
  48. package/dist/cjs/helpers/font-config.d.ts.map +1 -0
  49. package/dist/cjs/helpers/font-config.js +3 -0
  50. package/dist/cjs/helpers/font-config.js.map +7 -0
  51. package/dist/cjs/helpers/index.d.ts +1 -0
  52. package/dist/cjs/helpers/index.d.ts.map +1 -1
  53. package/dist/cjs/helpers/index.js +1 -1
  54. package/dist/cjs/helpers/index.js.map +2 -2
  55. package/dist/esm/components/schemas/base-button.schema.d.ts +319 -0
  56. package/dist/esm/components/schemas/base-button.schema.d.ts.map +1 -0
  57. package/dist/esm/components/schemas/base-button.schema.js +2 -0
  58. package/dist/esm/components/schemas/base-button.schema.js.map +7 -0
  59. package/dist/esm/components/schemas/button.schema.d.ts +686 -0
  60. package/dist/esm/components/schemas/button.schema.d.ts.map +1 -0
  61. package/dist/esm/components/schemas/button.schema.js +2 -0
  62. package/dist/esm/components/schemas/button.schema.js.map +7 -0
  63. package/dist/esm/components/schemas/icon-button.schema.d.ts +329 -0
  64. package/dist/esm/components/schemas/icon-button.schema.d.ts.map +1 -0
  65. package/dist/esm/components/schemas/icon-button.schema.js +2 -0
  66. package/dist/esm/components/schemas/icon-button.schema.js.map +7 -0
  67. package/dist/esm/components/schemas/index.d.ts +52 -0
  68. package/dist/esm/components/schemas/index.d.ts.map +1 -0
  69. package/dist/esm/components/schemas/index.js +2 -0
  70. package/dist/esm/components/schemas/index.js.map +7 -0
  71. package/dist/esm/components/schemas/toggle-button.schema.d.ts +1172 -0
  72. package/dist/esm/components/schemas/toggle-button.schema.d.ts.map +1 -0
  73. package/dist/esm/components/schemas/toggle-button.schema.js +2 -0
  74. package/dist/esm/components/schemas/toggle-button.schema.js.map +7 -0
  75. package/dist/esm/components/schemas/toggle-icon-button.schema.d.ts +563 -0
  76. package/dist/esm/components/schemas/toggle-icon-button.schema.d.ts.map +1 -0
  77. package/dist/esm/components/schemas/toggle-icon-button.schema.js +2 -0
  78. package/dist/esm/components/schemas/toggle-icon-button.schema.js.map +7 -0
  79. package/dist/esm/components/sheet.d.ts +1 -1
  80. package/dist/esm/components/sheet.d.ts.map +1 -1
  81. package/dist/esm/components/sheet.js +1 -1
  82. package/dist/esm/components/sheet.js.map +3 -3
  83. package/dist/esm/components/shell.d.ts +125 -164
  84. package/dist/esm/components/shell.d.ts.map +1 -1
  85. package/dist/esm/components/shell.js +1 -1
  86. package/dist/esm/components/shell.js.map +3 -3
  87. package/dist/esm/components/sidebar.d.ts +1 -7
  88. package/dist/esm/components/sidebar.d.ts.map +1 -1
  89. package/dist/esm/components/sidebar.js +1 -1
  90. package/dist/esm/components/sidebar.js.map +3 -3
  91. package/dist/esm/components/theme.d.ts +3 -0
  92. package/dist/esm/components/theme.d.ts.map +1 -1
  93. package/dist/esm/components/theme.js +1 -1
  94. package/dist/esm/components/theme.js.map +3 -3
  95. package/dist/esm/components/theme.props.d.ts +10 -0
  96. package/dist/esm/components/theme.props.d.ts.map +1 -1
  97. package/dist/esm/components/theme.props.js +1 -1
  98. package/dist/esm/components/theme.props.js.map +3 -3
  99. package/dist/esm/helpers/font-config.d.ts +96 -0
  100. package/dist/esm/helpers/font-config.d.ts.map +1 -0
  101. package/dist/esm/helpers/font-config.js +3 -0
  102. package/dist/esm/helpers/font-config.js.map +7 -0
  103. package/dist/esm/helpers/index.d.ts +1 -0
  104. package/dist/esm/helpers/index.d.ts.map +1 -1
  105. package/dist/esm/helpers/index.js +1 -1
  106. package/dist/esm/helpers/index.js.map +2 -2
  107. package/package.json +23 -3
  108. package/schemas/base-button.d.ts +2 -0
  109. package/schemas/base-button.json +284 -0
  110. package/schemas/button.d.ts +2 -0
  111. package/schemas/button.json +535 -0
  112. package/schemas/icon-button.d.ts +2 -0
  113. package/schemas/icon-button.json +318 -0
  114. package/schemas/index.d.ts +2 -0
  115. package/schemas/index.json +2016 -0
  116. package/schemas/schemas.d.ts +29 -0
  117. package/schemas/toggle-button.d.ts +2 -0
  118. package/schemas/toggle-button.json +543 -0
  119. package/schemas/toggle-icon-button.d.ts +2 -0
  120. package/schemas/toggle-icon-button.json +326 -0
  121. package/schemas-json.d.ts +12 -0
  122. package/src/components/_internal/base-sidebar.css +1 -2
  123. package/src/components/schemas/base-button.schema.ts +339 -0
  124. package/src/components/schemas/button.schema.ts +198 -0
  125. package/src/components/schemas/icon-button.schema.ts +142 -0
  126. package/src/components/schemas/index.ts +68 -0
  127. package/src/components/schemas/toggle-button.schema.ts +122 -0
  128. package/src/components/schemas/toggle-icon-button.schema.ts +195 -0
  129. package/src/components/sheet.css +39 -19
  130. package/src/components/sheet.tsx +62 -3
  131. package/src/components/shell.css +510 -89
  132. package/src/components/shell.tsx +2055 -928
  133. package/src/components/sidebar.tsx +3 -22
  134. package/src/components/theme.props.tsx +8 -0
  135. package/src/components/theme.tsx +16 -0
  136. package/src/helpers/font-config.ts +167 -0
  137. package/src/helpers/index.ts +1 -0
  138. package/src/styles/fonts.css +16 -13
  139. package/src/styles/tokens/typography.css +27 -4
  140. package/styles.css +398 -79
  141. package/tokens/base.css +12 -0
  142. package/tokens.css +12 -0
@@ -39,21 +39,7 @@ function useSidebarVisual() {
39
39
  return React.useContext(SidebarVisualContext);
40
40
  }
41
41
 
42
- // Context detection for Shell.Sidebar integration
43
- type ShellSidebarSectionContextValue = {
44
- side: 'start' | 'end';
45
- section: 'rail' | 'panel';
46
- };
47
-
48
- // Create a context that Shell.Sidebar can provide
49
- const ShellSidebarSectionContext = React.createContext<ShellSidebarSectionContextValue | null>(
50
- null,
51
- );
52
-
53
- // This context comes from Shell.Sidebar when Sidebar is used within Shell
54
- function useShellSidebarSection(): ShellSidebarSectionContextValue | null {
55
- return React.useContext(ShellSidebarSectionContext);
56
- }
42
+ // Sidebar is now independent of Shell - no integration needed
57
43
 
58
44
  // Main Sidebar component
59
45
  type SidebarOwnProps = GetPropDefTypes<typeof sidebarPropDefs>;
@@ -79,9 +65,8 @@ const Sidebar = React.forwardRef<HTMLDivElement, SidebarProps>((props, forwarded
79
65
  const { asChild: _, panelBackground: __, ...safeRootProps } = rootProps; // Remove asChild and panelBackground from DOM props
80
66
  const resolvedColor = color || themeContext.accentColor;
81
67
 
82
- // Detect Shell.Sidebar context to auto-resolve layout
83
- const shellSection = useShellSidebarSection();
84
- const resolvedLayout = layout || shellSection?.section || 'panel'; // Default to 'panel' if no context
68
+ // Resolve layout (default to 'panel')
69
+ const resolvedLayout = layout || 'panel';
85
70
 
86
71
  // Update context with current props - we'll pass the resolved values
87
72
  const resolvedSize = typeof size === 'object' ? size.initial || '2' : size;
@@ -615,8 +600,4 @@ export type {
615
600
  SidebarHeaderProps as HeaderProps,
616
601
  SidebarFooterProps as FooterProps,
617
602
  BadgeConfig,
618
- ShellSidebarSectionContextValue,
619
603
  };
620
-
621
- // Export context for Shell.Sidebar integration
622
- export { ShellSidebarSectionContext };
@@ -8,6 +8,7 @@ const appearances = ['inherit', 'light', 'dark'] as const;
8
8
  const panelBackgrounds = ['solid', 'translucent'] as const;
9
9
  const materials = ['solid', 'translucent'] as const;
10
10
  const scalings = ['90%', '95%', '100%', '105%', '110%'] as const;
11
+ const fontFamilies = ['sans', 'mono'] as const;
11
12
 
12
13
  const themePropDefs = {
13
14
  ...asChildPropDef,
@@ -71,6 +72,12 @@ const themePropDefs = {
71
72
  * https://www.radix-ui.com/themes/docs/theme/layout
72
73
  */
73
74
  scaling: { type: 'enum', values: scalings, default: '100%' },
75
+ /**
76
+ * Sets the font family for the theme.
77
+ *
78
+ * @default 'sans'
79
+ */
80
+ fontFamily: { type: 'enum', values: fontFamilies, default: 'sans' },
74
81
  } satisfies {
75
82
  hasBackground: PropDef<boolean>;
76
83
  appearance: PropDef<(typeof appearances)[number]>;
@@ -80,6 +87,7 @@ const themePropDefs = {
80
87
  panelBackground: PropDef<(typeof panelBackgrounds)[number]>;
81
88
  radius: PropDef<(typeof radii)[number]>;
82
89
  scaling: PropDef<(typeof scalings)[number]>;
90
+ fontFamily: PropDef<(typeof fontFamilies)[number]>;
83
91
  };
84
92
 
85
93
  type ThemeOwnProps = GetPropDefTypes<typeof themePropDefs & typeof asChildPropDef>;
@@ -19,6 +19,7 @@ type ThemeMaterial = (typeof themePropDefs.material.values)[number];
19
19
  type ThemePanelBackground = (typeof themePropDefs.panelBackground.values)[number];
20
20
  type ThemeRadius = (typeof themePropDefs.radius.values)[number];
21
21
  type ThemeScaling = (typeof themePropDefs.scaling.values)[number];
22
+ type ThemeFontFamily = (typeof themePropDefs.fontFamily.values)[number];
22
23
 
23
24
  interface ThemeChangeHandlers {
24
25
  onAppearanceChange: (appearance: ThemeAppearance) => void;
@@ -28,6 +29,7 @@ interface ThemeChangeHandlers {
28
29
  onPanelBackgroundChange: (panelBackground: ThemePanelBackground) => void;
29
30
  onRadiusChange: (radius: ThemeRadius) => void;
30
31
  onScalingChange: (scaling: ThemeScaling) => void;
32
+ onFontFamilyChange: (fontFamily: ThemeFontFamily) => void;
31
33
  }
32
34
 
33
35
  interface ThemeContextValue extends ThemeChangeHandlers {
@@ -39,6 +41,7 @@ interface ThemeContextValue extends ThemeChangeHandlers {
39
41
  panelBackground: ThemePanelBackground;
40
42
  radius: ThemeRadius;
41
43
  scaling: ThemeScaling;
44
+ fontFamily: ThemeFontFamily;
42
45
  }
43
46
  const ThemeContext = React.createContext<ThemeContextValue | undefined>(undefined);
44
47
 
@@ -77,6 +80,7 @@ const ThemeRoot = React.forwardRef<ThemeImplElement, ThemeImplPublicProps>(
77
80
  panelBackground: panelBackgroundProp = themePropDefs.panelBackground.default,
78
81
  radius: radiusProp = themePropDefs.radius.default,
79
82
  scaling: scalingProp = themePropDefs.scaling.default,
83
+ fontFamily: fontFamilyProp = themePropDefs.fontFamily.default,
80
84
  hasBackground = themePropDefs.hasBackground.default,
81
85
  ...rootProps
82
86
  } = props;
@@ -115,6 +119,9 @@ const ThemeRoot = React.forwardRef<ThemeImplElement, ThemeImplPublicProps>(
115
119
  const [scaling, setScaling] = React.useState(scalingProp);
116
120
  React.useEffect(() => setScaling(scalingProp), [scalingProp]);
117
121
 
122
+ const [fontFamily, setFontFamily] = React.useState(fontFamilyProp);
123
+ React.useEffect(() => setFontFamily(fontFamilyProp), [fontFamilyProp]);
124
+
118
125
  return (
119
126
  <ThemeImpl
120
127
  {...rootProps}
@@ -129,6 +136,7 @@ const ThemeRoot = React.forwardRef<ThemeImplElement, ThemeImplPublicProps>(
129
136
  panelBackground={panelBackground}
130
137
  radius={radius}
131
138
  scaling={scaling}
139
+ fontFamily={fontFamily}
132
140
  //
133
141
  onAppearanceChange={setAppearance}
134
142
  onAccentColorChange={setAccentColor}
@@ -137,6 +145,7 @@ const ThemeRoot = React.forwardRef<ThemeImplElement, ThemeImplPublicProps>(
137
145
  onPanelBackgroundChange={setPanelBackground}
138
146
  onRadiusChange={setRadius}
139
147
  onScalingChange={setScaling}
148
+ onFontFamilyChange={setFontFamily}
140
149
  />
141
150
  );
142
151
  },
@@ -167,6 +176,7 @@ const ThemeImpl = React.forwardRef<ThemeImplElement, ThemeImplProps>((props, for
167
176
  themePropDefs.panelBackground.default,
168
177
  radius = props.radius ?? context?.radius ?? themePropDefs.radius.default,
169
178
  scaling = props.scaling ?? context?.scaling ?? themePropDefs.scaling.default,
179
+ fontFamily = props.fontFamily ?? context?.fontFamily ?? themePropDefs.fontFamily.default,
170
180
  //
171
181
  onAppearanceChange = noop,
172
182
  onAccentColorChange = noop,
@@ -175,6 +185,7 @@ const ThemeImpl = React.forwardRef<ThemeImplElement, ThemeImplProps>((props, for
175
185
  onPanelBackgroundChange = noop,
176
186
  onRadiusChange = noop,
177
187
  onScalingChange = noop,
188
+ onFontFamilyChange = noop,
178
189
  //
179
190
  ...themeProps
180
191
  } = props;
@@ -195,6 +206,7 @@ const ThemeImpl = React.forwardRef<ThemeImplElement, ThemeImplProps>((props, for
195
206
  panelBackground,
196
207
  radius,
197
208
  scaling,
209
+ fontFamily,
198
210
  //
199
211
  onAppearanceChange,
200
212
  onAccentColorChange,
@@ -203,6 +215,7 @@ const ThemeImpl = React.forwardRef<ThemeImplElement, ThemeImplProps>((props, for
203
215
  onPanelBackgroundChange,
204
216
  onRadiusChange,
205
217
  onScalingChange,
218
+ onFontFamilyChange,
206
219
  }),
207
220
  [
208
221
  appearance,
@@ -213,6 +226,7 @@ const ThemeImpl = React.forwardRef<ThemeImplElement, ThemeImplProps>((props, for
213
226
  panelBackground,
214
227
  radius,
215
228
  scaling,
229
+ fontFamily,
216
230
  //
217
231
  onAppearanceChange,
218
232
  onAccentColorChange,
@@ -221,6 +235,7 @@ const ThemeImpl = React.forwardRef<ThemeImplElement, ThemeImplProps>((props, for
221
235
  onPanelBackgroundChange,
222
236
  onRadiusChange,
223
237
  onScalingChange,
238
+ onFontFamilyChange,
224
239
  ],
225
240
  )}
226
241
  >
@@ -234,6 +249,7 @@ const ThemeImpl = React.forwardRef<ThemeImplElement, ThemeImplProps>((props, for
234
249
  data-panel-background={panelBackground}
235
250
  data-radius={radius}
236
251
  data-scaling={scaling}
252
+ data-font-family={fontFamily}
237
253
  ref={forwardedRef}
238
254
  {...themeProps}
239
255
  className={classNames(
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Font configuration utilities for Kookie UI
3
+ *
4
+ * These utilities help users configure custom fonts through CSS variables
5
+ * and provide type-safe font configuration options.
6
+ */
7
+
8
+ /**
9
+ * Font family configuration interface
10
+ */
11
+ export interface FontConfig {
12
+ /** Sans-serif font stack for fontFamily="sans" */
13
+ sans?: string;
14
+ /** Monospace font stack for fontFamily="mono" */
15
+ mono?: string;
16
+ /** Base Inter font replacement */
17
+ inter?: string;
18
+ /** Base JetBrains Mono font replacement */
19
+ jetbrainsMono?: string;
20
+ }
21
+
22
+ /**
23
+ * CSS variable names used by Kookie UI for fonts
24
+ */
25
+ export const FONT_CSS_VARIABLES = {
26
+ sans: '--font-sans',
27
+ mono: '--font-mono',
28
+ inter: '--font-inter',
29
+ jetbrainsMono: '--font-jetbrains-mono',
30
+ defaultFamily: '--default-font-family',
31
+ headingFamily: '--heading-font-family',
32
+ strongFamily: '--strong-font-family',
33
+ codeFamily: '--code-font-family',
34
+ } as const;
35
+
36
+ /**
37
+ * Popular font stacks for common use cases
38
+ */
39
+ export const FONT_STACKS = {
40
+ // Sans-serif options
41
+ inter: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
42
+ system:
43
+ "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
44
+ poppins: "'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif",
45
+ openSans: "'Open Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif",
46
+
47
+ // Monospace options
48
+ jetbrainsMono: "'JetBrains Mono', 'Fira Code', 'Consolas', 'Liberation Mono', monospace",
49
+ firaCode: "'Fira Code', 'JetBrains Mono', 'Consolas', 'Liberation Mono', monospace",
50
+ sourceCodePro: "'Source Code Pro', 'JetBrains Mono', 'Consolas', monospace",
51
+ systemMono: "'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', 'Courier New', monospace",
52
+ } as const;
53
+
54
+ /**
55
+ * Apply font configuration to CSS variables
56
+ *
57
+ * @param config Font configuration object
58
+ * @param target Target element (defaults to document.documentElement)
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * // Use Google Fonts
63
+ * applyFontConfig({
64
+ * sans: FONT_STACKS.poppins,
65
+ * mono: FONT_STACKS.firaCode
66
+ * });
67
+ *
68
+ * // Use system fonts only
69
+ * applyFontConfig({
70
+ * sans: FONT_STACKS.system,
71
+ * mono: FONT_STACKS.systemMono
72
+ * });
73
+ * ```
74
+ */
75
+ export function applyFontConfig(
76
+ config: FontConfig,
77
+ target: HTMLElement = document.documentElement,
78
+ ): void {
79
+ const style = target.style;
80
+
81
+ if (config.sans) {
82
+ style.setProperty(FONT_CSS_VARIABLES.sans, config.sans);
83
+ }
84
+
85
+ if (config.mono) {
86
+ style.setProperty(FONT_CSS_VARIABLES.mono, config.mono);
87
+ }
88
+
89
+ if (config.inter) {
90
+ style.setProperty(FONT_CSS_VARIABLES.inter, config.inter);
91
+ }
92
+
93
+ if (config.jetbrainsMono) {
94
+ style.setProperty(FONT_CSS_VARIABLES.jetbrainsMono, config.jetbrainsMono);
95
+ }
96
+ }
97
+
98
+ /**
99
+ * Generate CSS string for font configuration
100
+ *
101
+ * @param config Font configuration object
102
+ * @returns CSS string that can be injected into a stylesheet
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const css = generateFontCSS({
107
+ * sans: FONT_STACKS.poppins,
108
+ * mono: FONT_STACKS.firaCode
109
+ * });
110
+ *
111
+ * // Inject into document
112
+ * const style = document.createElement('style');
113
+ * style.textContent = css;
114
+ * document.head.appendChild(style);
115
+ * ```
116
+ */
117
+ export function generateFontCSS(config: FontConfig): string {
118
+ const rules: string[] = [':root {'];
119
+
120
+ if (config.sans) {
121
+ rules.push(` ${FONT_CSS_VARIABLES.sans}: ${config.sans};`);
122
+ }
123
+
124
+ if (config.mono) {
125
+ rules.push(` ${FONT_CSS_VARIABLES.mono}: ${config.mono};`);
126
+ }
127
+
128
+ if (config.inter) {
129
+ rules.push(` ${FONT_CSS_VARIABLES.inter}: ${config.inter};`);
130
+ }
131
+
132
+ if (config.jetbrainsMono) {
133
+ rules.push(` ${FONT_CSS_VARIABLES.jetbrainsMono}: ${config.jetbrainsMono};`);
134
+ }
135
+
136
+ rules.push('}');
137
+
138
+ return rules.join('\n');
139
+ }
140
+
141
+ /**
142
+ * Reset fonts to Kookie UI defaults
143
+ */
144
+ export function resetFonts(target: HTMLElement = document.documentElement): void {
145
+ const style = target.style;
146
+
147
+ // Remove custom font variables to fall back to defaults
148
+ style.removeProperty(FONT_CSS_VARIABLES.sans);
149
+ style.removeProperty(FONT_CSS_VARIABLES.mono);
150
+ style.removeProperty(FONT_CSS_VARIABLES.inter);
151
+ style.removeProperty(FONT_CSS_VARIABLES.jetbrainsMono);
152
+ }
153
+
154
+ /**
155
+ * Get current font configuration from CSS variables
156
+ */
157
+ export function getCurrentFontConfig(target: HTMLElement = document.documentElement): FontConfig {
158
+ const computedStyle = getComputedStyle(target);
159
+
160
+ return {
161
+ sans: computedStyle.getPropertyValue(FONT_CSS_VARIABLES.sans).trim() || undefined,
162
+ mono: computedStyle.getPropertyValue(FONT_CSS_VARIABLES.mono).trim() || undefined,
163
+ inter: computedStyle.getPropertyValue(FONT_CSS_VARIABLES.inter).trim() || undefined,
164
+ jetbrainsMono:
165
+ computedStyle.getPropertyValue(FONT_CSS_VARIABLES.jetbrainsMono).trim() || undefined,
166
+ };
167
+ }
@@ -1,6 +1,7 @@
1
1
  export * from './component-props.js';
2
2
  export * from './extract-margin-props.js';
3
3
  export * from './extract-props.js';
4
+ export * from './font-config.js';
4
5
  export * from './get-margin-styles.js';
5
6
  export * from './get-matching-gray-color.js';
6
7
  export * from './get-responsive-styles.js';
@@ -2,19 +2,23 @@
2
2
  @import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,100..900;1,100..900&display=swap');
3
3
  @import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');
4
4
 
5
- /* Font Variables */
5
+ /* Font Variables - Customize these to change fonts throughout your app */
6
6
  :root {
7
- --font-inter: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
8
- --font-jetbrains-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
9
-
10
- /* Primary font variables */
11
- --font-general-sans: var(--font-inter);
12
- --font-inter-mono: var(--font-jetbrains-mono);
13
-
14
- /* Tailwind-compatible aliases */
15
- --font-sans: var(--font-inter);
16
- --font-mono: var(--font-jetbrains-mono);
17
-
7
+ /* Base font definitions - override these in your CSS to customize fonts */
8
+ --font-inter:
9
+ 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
10
+ sans-serif;
11
+ --font-jetbrains-mono:
12
+ 'JetBrains Mono', 'Fira Code', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
13
+
14
+ /* Primary font variables - these map to theme fontFamily values */
15
+ --font-general-sans: var(--font-inter); /* Used when fontFamily="sans" */
16
+ --font-inter-mono: var(--font-jetbrains-mono); /* Used for code elements */
17
+
18
+ /* Tailwind-compatible aliases - override these to change theme fonts */
19
+ --font-sans: var(--font-inter); /* Theme fontFamily="sans" uses this */
20
+ --font-mono: var(--font-jetbrains-mono); /* Theme fontFamily="mono" uses this */
21
+
18
22
  /* Force proper font weight rendering */
19
23
  font-synthesis: none; /* Prevent browser from synthesizing weights */
20
24
  }
@@ -33,4 +37,3 @@
33
37
  font-display: block;
34
38
  src: local('-apple-system'), local('BlinkMacSystemFont'), local('Segoe UI'), local('Roboto');
35
39
  }
36
-
@@ -43,8 +43,17 @@
43
43
 
44
44
  /* default values */
45
45
 
46
- --default-font-family: var(--font-inter, 'Inter'), -apple-system, BlinkMacSystemFont, 'Segoe UI (Custom)',
47
- Roboto, 'Helvetica Neue', 'Open Sans (Custom)', system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
46
+ --default-font-family:
47
+ var(--font-inter, 'Inter'), -apple-system, BlinkMacSystemFont, 'Segoe UI (Custom)', Roboto,
48
+ 'Helvetica Neue', 'Open Sans (Custom)', system-ui, sans-serif, 'Apple Color Emoji',
49
+ 'Segoe UI Emoji';
50
+
51
+ /* Font family overrides based on theme data attribute */
52
+ --default-font-family-sans:
53
+ var(--font-inter, 'Inter'), -apple-system, BlinkMacSystemFont, 'Segoe UI (Custom)', Roboto,
54
+ 'Helvetica Neue', 'Open Sans (Custom)', system-ui, sans-serif, 'Apple Color Emoji',
55
+ 'Segoe UI Emoji';
56
+ --default-font-family-mono: var(--font-mono);
48
57
  --default-font-size: var(--font-size-3); /* Same size used for `<Text size="3">` */
49
58
  --default-font-style: normal;
50
59
  --default-font-weight: var(--font-weight-regular);
@@ -75,8 +84,9 @@
75
84
 
76
85
  /* Code */
77
86
 
78
- --code-font-family: var(--font-inter-mono, 'JetBrains Mono'), 'Menlo', 'Consolas (Custom)', 'Bitstream Vera Sans Mono',
79
- monospace, 'Apple Color Emoji', 'Segoe UI Emoji';
87
+ --code-font-family:
88
+ var(--font-inter-mono, 'JetBrains Mono'), 'Menlo', 'Consolas (Custom)',
89
+ 'Bitstream Vera Sans Mono', monospace, 'Apple Color Emoji', 'Segoe UI Emoji';
80
90
  --code-font-size-adjust: 0.95;
81
91
  --code-font-style: normal;
82
92
  --code-font-weight: inherit;
@@ -304,3 +314,16 @@
304
314
  descent-override: 22%;
305
315
  src: local('Consolas Bold Italic');
306
316
  }
317
+
318
+ /* Font family data attribute support */
319
+ [data-font-family='sans'] {
320
+ --default-font-family: var(--default-font-family-sans);
321
+ --heading-font-family: var(--default-font-family-sans);
322
+ --strong-font-family: var(--default-font-family-sans);
323
+ }
324
+
325
+ [data-font-family='mono'] {
326
+ --default-font-family: var(--default-font-family-mono);
327
+ --heading-font-family: var(--default-font-family-mono);
328
+ --strong-font-family: var(--default-font-family-mono);
329
+ }