@newtonedev/components 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 (181) hide show
  1. package/dist/AppShell/AppShell.d.ts +4 -0
  2. package/dist/AppShell/AppShell.d.ts.map +1 -0
  3. package/dist/AppShell/AppShell.styles.d.ts +16 -0
  4. package/dist/AppShell/AppShell.styles.d.ts.map +1 -0
  5. package/dist/AppShell/AppShell.types.d.ts +8 -0
  6. package/dist/AppShell/AppShell.types.d.ts.map +1 -0
  7. package/dist/AppShell/index.d.ts +3 -0
  8. package/dist/AppShell/index.d.ts.map +1 -0
  9. package/dist/Button/Button.d.ts +9 -4
  10. package/dist/Button/Button.d.ts.map +1 -1
  11. package/dist/Button/Button.styles.d.ts +33 -26
  12. package/dist/Button/Button.styles.d.ts.map +1 -1
  13. package/dist/Button/Button.types.d.ts +17 -2
  14. package/dist/Button/Button.types.d.ts.map +1 -1
  15. package/dist/ColorScaleSlider/ColorScaleSlider.d.ts +13 -0
  16. package/dist/ColorScaleSlider/ColorScaleSlider.d.ts.map +1 -0
  17. package/dist/ColorScaleSlider/ColorScaleSlider.styles.d.ts +54 -0
  18. package/dist/ColorScaleSlider/ColorScaleSlider.styles.d.ts.map +1 -0
  19. package/dist/ColorScaleSlider/ColorScaleSlider.types.d.ts +25 -0
  20. package/dist/ColorScaleSlider/ColorScaleSlider.types.d.ts.map +1 -0
  21. package/dist/ColorScaleSlider/index.d.ts +3 -0
  22. package/dist/ColorScaleSlider/index.d.ts.map +1 -0
  23. package/dist/Frame/Frame.d.ts +48 -0
  24. package/dist/Frame/Frame.d.ts.map +1 -0
  25. package/dist/Frame/Frame.styles.d.ts +39 -0
  26. package/dist/Frame/Frame.styles.d.ts.map +1 -0
  27. package/dist/Frame/Frame.types.d.ts +115 -0
  28. package/dist/Frame/Frame.types.d.ts.map +1 -0
  29. package/dist/Frame/Frame.utils.d.ts +39 -0
  30. package/dist/Frame/Frame.utils.d.ts.map +1 -0
  31. package/dist/Frame/index.d.ts +4 -0
  32. package/dist/Frame/index.d.ts.map +1 -0
  33. package/dist/HueSlider/HueSlider.d.ts +1 -1
  34. package/dist/HueSlider/HueSlider.d.ts.map +1 -1
  35. package/dist/HueSlider/HueSlider.styles.d.ts +47 -5
  36. package/dist/HueSlider/HueSlider.styles.d.ts.map +1 -1
  37. package/dist/HueSlider/HueSlider.types.d.ts +1 -0
  38. package/dist/HueSlider/HueSlider.types.d.ts.map +1 -1
  39. package/dist/Icon/Icon.d.ts +36 -0
  40. package/dist/Icon/Icon.d.ts.map +1 -0
  41. package/dist/Navbar/Navbar.d.ts +4 -0
  42. package/dist/Navbar/Navbar.d.ts.map +1 -0
  43. package/dist/Navbar/Navbar.styles.d.ts +31 -0
  44. package/dist/Navbar/Navbar.styles.d.ts.map +1 -0
  45. package/dist/Navbar/Navbar.types.d.ts +14 -0
  46. package/dist/Navbar/Navbar.types.d.ts.map +1 -0
  47. package/dist/Navbar/index.d.ts +3 -0
  48. package/dist/Navbar/index.d.ts.map +1 -0
  49. package/dist/Popover/Popover.d.ts +4 -0
  50. package/dist/Popover/Popover.d.ts.map +1 -0
  51. package/dist/Popover/Popover.styles.d.ts +9 -0
  52. package/dist/Popover/Popover.styles.d.ts.map +1 -0
  53. package/dist/Popover/Popover.types.d.ts +37 -0
  54. package/dist/Popover/Popover.types.d.ts.map +1 -0
  55. package/dist/Popover/index.d.ts +4 -0
  56. package/dist/Popover/index.d.ts.map +1 -0
  57. package/dist/Popover/usePopover.d.ts +3 -0
  58. package/dist/Popover/usePopover.d.ts.map +1 -0
  59. package/dist/Select/Select.d.ts +1 -8
  60. package/dist/Select/Select.d.ts.map +1 -1
  61. package/dist/Select/Select.styles.d.ts +32 -5
  62. package/dist/Select/Select.styles.d.ts.map +1 -1
  63. package/dist/Select/Select.types.d.ts +25 -1
  64. package/dist/Select/Select.types.d.ts.map +1 -1
  65. package/dist/Select/SelectOption.d.ts +13 -0
  66. package/dist/Select/SelectOption.d.ts.map +1 -0
  67. package/dist/Select/useSelect.d.ts +15 -0
  68. package/dist/Select/useSelect.d.ts.map +1 -0
  69. package/dist/Sidebar/Sidebar.d.ts +4 -0
  70. package/dist/Sidebar/Sidebar.d.ts.map +1 -0
  71. package/dist/Sidebar/Sidebar.styles.d.ts +31 -0
  72. package/dist/Sidebar/Sidebar.styles.d.ts.map +1 -0
  73. package/dist/Sidebar/Sidebar.types.d.ts +14 -0
  74. package/dist/Sidebar/Sidebar.types.d.ts.map +1 -0
  75. package/dist/Sidebar/index.d.ts +3 -0
  76. package/dist/Sidebar/index.d.ts.map +1 -0
  77. package/dist/Slider/Slider.d.ts +1 -1
  78. package/dist/Slider/Slider.d.ts.map +1 -1
  79. package/dist/Slider/Slider.styles.d.ts +48 -8
  80. package/dist/Slider/Slider.styles.d.ts.map +1 -1
  81. package/dist/Slider/Slider.types.d.ts +1 -0
  82. package/dist/Slider/Slider.types.d.ts.map +1 -1
  83. package/dist/TextInput/TextInput.styles.d.ts +3 -1
  84. package/dist/TextInput/TextInput.styles.d.ts.map +1 -1
  85. package/dist/Toggle/Toggle.styles.d.ts +2 -1
  86. package/dist/Toggle/Toggle.styles.d.ts.map +1 -1
  87. package/dist/fonts/GoogleFontLoader.d.ts +19 -0
  88. package/dist/fonts/GoogleFontLoader.d.ts.map +1 -0
  89. package/dist/fonts/IconFontLoader.d.ts +13 -0
  90. package/dist/fonts/IconFontLoader.d.ts.map +1 -0
  91. package/dist/fonts/buildGoogleFontsUrl.d.ts +17 -0
  92. package/dist/fonts/buildGoogleFontsUrl.d.ts.map +1 -0
  93. package/dist/fonts/googleFonts.d.ts +20 -0
  94. package/dist/fonts/googleFonts.d.ts.map +1 -0
  95. package/dist/index.cjs +2303 -205
  96. package/dist/index.cjs.map +1 -1
  97. package/dist/index.d.ts +27 -3
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +2279 -200
  100. package/dist/index.js.map +1 -1
  101. package/dist/registry/codegen.d.ts +11 -0
  102. package/dist/registry/codegen.d.ts.map +1 -0
  103. package/dist/registry/index.d.ts +4 -0
  104. package/dist/registry/index.d.ts.map +1 -0
  105. package/dist/registry/registry.d.ts +7 -0
  106. package/dist/registry/registry.d.ts.map +1 -0
  107. package/dist/registry/types.d.ts +32 -0
  108. package/dist/registry/types.d.ts.map +1 -0
  109. package/dist/theme/FrameContext.d.ts +24 -0
  110. package/dist/theme/FrameContext.d.ts.map +1 -0
  111. package/dist/theme/NewtoneProvider.d.ts.map +1 -1
  112. package/dist/theme/defaults.d.ts.map +1 -1
  113. package/dist/theme/types.d.ts +64 -1
  114. package/dist/theme/types.d.ts.map +1 -1
  115. package/dist/tokens/computeTokens.d.ts +55 -3
  116. package/dist/tokens/computeTokens.d.ts.map +1 -1
  117. package/dist/tokens/types.d.ts +52 -0
  118. package/dist/tokens/types.d.ts.map +1 -1
  119. package/dist/tokens/useTokens.d.ts +12 -9
  120. package/dist/tokens/useTokens.d.ts.map +1 -1
  121. package/package.json +1 -1
  122. package/src/AppShell/AppShell.styles.ts +20 -0
  123. package/src/AppShell/AppShell.tsx +17 -0
  124. package/src/AppShell/AppShell.types.ts +8 -0
  125. package/src/AppShell/index.ts +2 -0
  126. package/src/Button/Button.styles.ts +74 -41
  127. package/src/Button/Button.tsx +36 -17
  128. package/src/Button/Button.types.ts +20 -2
  129. package/src/Card/Card.styles.ts +2 -2
  130. package/src/ColorScaleSlider/ColorScaleSlider.styles.ts +60 -0
  131. package/src/ColorScaleSlider/ColorScaleSlider.tsx +156 -0
  132. package/src/ColorScaleSlider/ColorScaleSlider.types.ts +25 -0
  133. package/src/ColorScaleSlider/index.ts +2 -0
  134. package/src/Frame/Frame.styles.ts +213 -0
  135. package/src/Frame/Frame.tsx +242 -0
  136. package/src/Frame/Frame.types.ts +181 -0
  137. package/src/Frame/Frame.utils.ts +189 -0
  138. package/src/Frame/index.ts +21 -0
  139. package/src/HueSlider/HueSlider.styles.ts +58 -39
  140. package/src/HueSlider/HueSlider.tsx +97 -25
  141. package/src/HueSlider/HueSlider.types.ts +1 -0
  142. package/src/Icon/Icon.tsx +76 -0
  143. package/src/Navbar/Navbar.styles.ts +37 -0
  144. package/src/Navbar/Navbar.tsx +32 -0
  145. package/src/Navbar/Navbar.types.ts +14 -0
  146. package/src/Navbar/index.ts +2 -0
  147. package/src/Popover/Popover.styles.ts +39 -0
  148. package/src/Popover/Popover.tsx +103 -0
  149. package/src/Popover/Popover.types.ts +40 -0
  150. package/src/Popover/index.ts +3 -0
  151. package/src/Popover/usePopover.ts +26 -0
  152. package/src/Select/Select.styles.ts +49 -10
  153. package/src/Select/Select.tsx +127 -36
  154. package/src/Select/Select.types.ts +30 -1
  155. package/src/Select/SelectOption.tsx +104 -0
  156. package/src/Select/useSelect.ts +129 -0
  157. package/src/Sidebar/Sidebar.styles.ts +37 -0
  158. package/src/Sidebar/Sidebar.tsx +27 -0
  159. package/src/Sidebar/Sidebar.types.ts +14 -0
  160. package/src/Sidebar/index.ts +2 -0
  161. package/src/Slider/Slider.styles.ts +53 -25
  162. package/src/Slider/Slider.tsx +89 -24
  163. package/src/Slider/Slider.types.ts +1 -0
  164. package/src/TextInput/TextInput.styles.ts +9 -7
  165. package/src/Toggle/Toggle.styles.ts +4 -3
  166. package/src/fonts/GoogleFontLoader.tsx +63 -0
  167. package/src/fonts/IconFontLoader.tsx +49 -0
  168. package/src/fonts/buildGoogleFontsUrl.ts +31 -0
  169. package/src/fonts/googleFonts.ts +87 -0
  170. package/src/index.ts +70 -2
  171. package/src/registry/codegen.ts +132 -0
  172. package/src/registry/index.ts +17 -0
  173. package/src/registry/registry.ts +402 -0
  174. package/src/registry/types.ts +35 -0
  175. package/src/theme/FrameContext.tsx +29 -0
  176. package/src/theme/NewtoneProvider.tsx +9 -1
  177. package/src/theme/defaults.ts +51 -0
  178. package/src/theme/types.ts +66 -1
  179. package/src/tokens/computeTokens.ts +103 -46
  180. package/src/tokens/types.ts +52 -0
  181. package/src/tokens/useTokens.ts +30 -15
@@ -0,0 +1,11 @@
1
+ import type { ComponentMeta } from './types';
2
+ /**
3
+ * Generates a ready-to-paste JSX code snippet for a component with the given prop overrides.
4
+ *
5
+ * - Includes the import statement
6
+ * - Omits props that match their default values
7
+ * - Adds placeholder handlers for interactive props
8
+ * - Formats Select's options as a const declaration
9
+ */
10
+ export declare function generateComponentCode(component: ComponentMeta, propOverrides: Record<string, unknown>): string;
11
+ //# sourceMappingURL=codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/registry/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAwB7C;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,aAAa,EACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,MAAM,CAmFR"}
@@ -0,0 +1,4 @@
1
+ export type { CategoryMeta, VariantMeta, EditableProp, EditablePropOption, ComponentMeta, } from './types';
2
+ export { CATEGORIES, COMPONENTS, getComponent, getCategory, getComponentsByCategory, } from './registry';
3
+ export { generateComponentCode } from './codegen';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { CategoryMeta, ComponentMeta } from './types';
2
+ export declare const CATEGORIES: readonly CategoryMeta[];
3
+ export declare const COMPONENTS: readonly ComponentMeta[];
4
+ export declare function getComponent(id: string): ComponentMeta | undefined;
5
+ export declare function getCategory(id: string): CategoryMeta | undefined;
6
+ export declare function getComponentsByCategory(categoryId: string): readonly ComponentMeta[];
7
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,UAAU,EAAE,SAAS,YAAY,EAK7C,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,SAAS,aAAa,EA4X9C,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAElE;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEhE;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,aAAa,EAAE,CAEpF"}
@@ -0,0 +1,32 @@
1
+ export interface CategoryMeta {
2
+ readonly id: string;
3
+ readonly name: string;
4
+ readonly description: string;
5
+ }
6
+ export interface VariantMeta {
7
+ readonly id: string;
8
+ readonly label: string;
9
+ readonly props: Record<string, unknown>;
10
+ }
11
+ export interface EditablePropOption {
12
+ readonly label: string;
13
+ readonly value: string | number | boolean;
14
+ }
15
+ export interface EditableProp {
16
+ readonly name: string;
17
+ readonly label: string;
18
+ readonly control: 'select' | 'text' | 'toggle' | 'number';
19
+ readonly options?: readonly EditablePropOption[];
20
+ readonly defaultValue: string | number | boolean;
21
+ }
22
+ export interface ComponentMeta {
23
+ readonly id: string;
24
+ readonly name: string;
25
+ readonly importName: string;
26
+ readonly categoryId: string;
27
+ readonly description: string;
28
+ readonly hasChildren: boolean;
29
+ readonly variants: readonly VariantMeta[];
30
+ readonly editableProps: readonly EditableProp[];
31
+ }
32
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version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C;IAC1C,QAAQ,CAAC,aAAa,EAAE,SAAS,YAAY,EAAE,CAAC;CACjD"}
@@ -0,0 +1,24 @@
1
+ import type { ThemeName, ElevationLevel } from './types';
2
+ /**
3
+ * Context value provided by Frame to its descendants.
4
+ * Contains the resolved theme and elevation that children should use.
5
+ */
6
+ export interface FrameContextValue {
7
+ readonly theme: ThemeName;
8
+ readonly elevation: ElevationLevel;
9
+ }
10
+ /**
11
+ * FrameContext - Propagates theme and elevation overrides from Frame to descendants.
12
+ *
13
+ * When null, components fall back to NewtoneProvider's theme and default elevation (1).
14
+ * When present, useTokens() reads from this context instead.
15
+ */
16
+ export declare const FrameContext: import("react").Context<FrameContextValue | null>;
17
+ /**
18
+ * useFrameContext - Read the nearest Frame's context, if any.
19
+ *
20
+ * Returns null when no parent Frame exists. This is intentionally not an error —
21
+ * components outside a Frame simply fall back to the NewtoneProvider defaults.
22
+ */
23
+ export declare function useFrameContext(): FrameContextValue | null;
24
+ //# sourceMappingURL=FrameContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrameContext.d.ts","sourceRoot":"","sources":["../../src/theme/FrameContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;CACpC;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,mDAAgD,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,iBAAiB,GAAG,IAAI,CAE1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"NewtoneProvider.d.ts","sourceRoot":"","sources":["../../src/theme/NewtoneProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAK7F,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAA6B,EAC7B,WAAqB,EACrB,YAAwB,EACxB,QAAQ,GACT,EAAE,oBAAoB,qBAgBtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,IAAI,mBAAmB,CAMrD"}
1
+ {"version":3,"file":"NewtoneProvider.d.ts","sourceRoot":"","sources":["../../src/theme/NewtoneProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAO7F,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC;IACjC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAA6B,EAC7B,WAAqB,EACrB,YAAwB,EACxB,QAAQ,GACT,EAAE,oBAAoB,qBAsBtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,IAAI,mBAAmB,CAMrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/theme/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAclD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBAuBlC,CAAC"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/theme/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAclD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBA0ElC,CAAC"}
@@ -3,15 +3,30 @@ import type { DynamicRange, PaletteConfig } from 'newtone';
3
3
  * Color mode: light or dark
4
4
  */
5
5
  export type ColorMode = 'light' | 'dark';
6
+ /**
7
+ * Font configuration for a single font slot
8
+ */
9
+ export interface FontConfig {
10
+ readonly type: 'system' | 'google' | 'custom';
11
+ readonly family: string;
12
+ readonly customUrl?: string;
13
+ readonly fallback: string;
14
+ }
6
15
  /**
7
16
  * Theme names for different UI contexts
8
17
  */
9
18
  export type ThemeName = 'neutral' | 'primary' | 'secondary' | 'strong';
10
19
  /**
11
- * Elevation levels for surfaces
20
+ * Elevation levels for surfaces (internal)
12
21
  * 0 = sunken, 1 = default, 2 = elevated
13
22
  */
14
23
  export type ElevationLevel = 0 | 1 | 2;
24
+ /**
25
+ * User-facing elevation for Frame component
26
+ * -2 = deeply sunken (inset shadow), -1 = sunken, 0 = default,
27
+ * 1 = elevated, 2 = prominently elevated (drop shadow)
28
+ */
29
+ export type FrameElevation = -2 | -1 | 0 | 1 | 2;
15
30
  /**
16
31
  * Theme mapping: which palette and normalizedValue to use for backgrounds/text
17
32
  * Based on playground theme preview logic
@@ -42,6 +57,54 @@ export interface NewtoneThemeConfig {
42
57
  readonly elevation: {
43
58
  readonly offsets: readonly [number, number, number];
44
59
  };
60
+ readonly spacing: {
61
+ readonly xs: number;
62
+ readonly sm: number;
63
+ readonly md: number;
64
+ readonly lg: number;
65
+ readonly xl: number;
66
+ readonly xxl: number;
67
+ };
68
+ readonly radius: {
69
+ readonly none: number;
70
+ readonly sm: number;
71
+ readonly md: number;
72
+ readonly lg: number;
73
+ readonly xl: number;
74
+ readonly pill: 999;
75
+ };
76
+ readonly typography: {
77
+ readonly fonts: {
78
+ readonly mono: FontConfig;
79
+ readonly display: FontConfig;
80
+ readonly default: FontConfig;
81
+ };
82
+ readonly scale: {
83
+ readonly xs: number;
84
+ readonly sm: number;
85
+ readonly base: number;
86
+ readonly md: number;
87
+ readonly lg: number;
88
+ readonly xl: number;
89
+ readonly xxl: number;
90
+ };
91
+ readonly lineHeight: {
92
+ readonly tight: number;
93
+ readonly normal: number;
94
+ readonly relaxed: number;
95
+ };
96
+ readonly fontWeight: {
97
+ readonly regular: number;
98
+ readonly medium: number;
99
+ readonly semibold: number;
100
+ readonly bold: number;
101
+ };
102
+ };
103
+ readonly icons: {
104
+ readonly variant: 'outlined' | 'rounded' | 'sharp';
105
+ readonly weight: 100 | 200 | 300 | 400 | 500 | 600 | 700;
106
+ readonly autoGrade: boolean;
107
+ };
45
108
  }
46
109
  /**
47
110
  * Current theme context state
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/theme/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;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AAC,OAAO,EAAE,MAAM,CAAC;SAC1B,CAAC;QACF,QAAQ,CAAC,UAAU,EAAE;YACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;YACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;YACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;YAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;SACvB,CAAC;KACH,CAAC;IACF,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;QACnD,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;QACzD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;KAC7B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC5C,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CAC/C"}
@@ -1,4 +1,4 @@
1
- import type { ColorSystemConfig, ColorMode, ThemeMapping, ElevationLevel } from '../theme/types';
1
+ import type { ColorSystemConfig, ColorMode, ThemeMapping, ElevationLevel, FontConfig } from '../theme/types';
2
2
  import type { ResolvedTokens } from './types';
3
3
  /**
4
4
  * Compute design tokens for a specific mode/theme/elevation combination.
@@ -12,6 +12,10 @@ import type { ResolvedTokens } from './types';
12
12
  * @param themeMapping - Theme configuration (which palette and NV to use)
13
13
  * @param elevation - Elevation level (0=sunken, 1=default, 2=elevated)
14
14
  * @param elevationOffsets - NV offsets for each elevation level
15
+ * @param spacing - Spacing scale for paddings, gaps, and margins
16
+ * @param radius - Border radius scale for component roundness
17
+ * @param typography - Typography configuration with fonts and scales
18
+ * @param icons - Icon configuration with variant, weight, and auto-grade setting
15
19
  * @returns Resolved design tokens with all necessary colors
16
20
  *
17
21
  * @example
@@ -21,10 +25,58 @@ import type { ResolvedTokens } from './types';
21
25
  * 'light',
22
26
  * config.themes.neutral,
23
27
  * 1,
24
- * config.elevation.offsets
28
+ * config.elevation.offsets,
29
+ * config.spacing,
30
+ * config.radius,
31
+ * config.typography,
32
+ * config.icons
25
33
  * );
26
34
  * console.log(tokens.background.srgb); // { r: 0.95, g: 0.95, b: 0.95 }
27
35
  * ```
28
36
  */
29
- export declare function computeTokens(config: ColorSystemConfig, mode: ColorMode, themeMapping: ThemeMapping, elevation: ElevationLevel, elevationOffsets: readonly [number, number, number]): ResolvedTokens;
37
+ export declare function computeTokens(config: ColorSystemConfig, mode: ColorMode, themeMapping: ThemeMapping, elevation: ElevationLevel, elevationOffsets: readonly [number, number, number], spacing: {
38
+ readonly xs: number;
39
+ readonly sm: number;
40
+ readonly md: number;
41
+ readonly lg: number;
42
+ readonly xl: number;
43
+ readonly xxl: number;
44
+ }, radius: {
45
+ readonly none: number;
46
+ readonly sm: number;
47
+ readonly md: number;
48
+ readonly lg: number;
49
+ readonly xl: number;
50
+ readonly pill: 999;
51
+ }, typography: {
52
+ readonly fonts: {
53
+ readonly mono: FontConfig;
54
+ readonly display: FontConfig;
55
+ readonly default: FontConfig;
56
+ };
57
+ readonly scale: {
58
+ readonly xs: number;
59
+ readonly sm: number;
60
+ readonly base: number;
61
+ readonly md: number;
62
+ readonly lg: number;
63
+ readonly xl: number;
64
+ readonly xxl: number;
65
+ };
66
+ readonly lineHeight: {
67
+ readonly tight: number;
68
+ readonly normal: number;
69
+ readonly relaxed: number;
70
+ };
71
+ readonly fontWeight: {
72
+ readonly regular: number;
73
+ readonly medium: number;
74
+ readonly semibold: number;
75
+ readonly bold: number;
76
+ };
77
+ }, icons: {
78
+ readonly variant: 'outlined' | 'rounded' | 'sharp';
79
+ readonly weight: 100 | 200 | 300 | 400 | 500 | 600 | 700;
80
+ readonly autoGrade: boolean;
81
+ }): ResolvedTokens;
30
82
  //# sourceMappingURL=computeTokens.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"computeTokens.d.ts","sourceRoot":"","sources":["../../src/tokens/computeTokens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACjG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,cAAc,EACzB,gBAAgB,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAClD,cAAc,CAoLhB"}
1
+ {"version":3,"file":"computeTokens.d.ts","sourceRoot":"","sources":["../../src/tokens/computeTokens.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC7G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAU9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,cAAc,EACzB,gBAAgB,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACnD,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QA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AU,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9H,EACD,KAAK,EAAE;IACL,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACzD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B,GACA,cAAc,CA+MhB"}
@@ -27,5 +27,57 @@ export interface ResolvedTokens {
27
27
  readonly warning: ColorResult;
28
28
  /** Error/destructive state color (from error palette, index 4) */
29
29
  readonly error: ColorResult;
30
+ /** Spacing tokens for paddings, gaps, and margins */
31
+ readonly spacing: {
32
+ readonly xs: number;
33
+ readonly sm: number;
34
+ readonly md: number;
35
+ readonly lg: number;
36
+ readonly xl: number;
37
+ readonly xxl: number;
38
+ };
39
+ /** Border radius tokens for component roundness */
40
+ readonly radius: {
41
+ readonly none: number;
42
+ readonly sm: number;
43
+ readonly md: number;
44
+ readonly lg: number;
45
+ readonly xl: number;
46
+ readonly pill: 999;
47
+ };
48
+ /** Typography tokens for fonts, sizes, line heights, and weights */
49
+ readonly typography: {
50
+ readonly fonts: {
51
+ readonly mono: string;
52
+ readonly display: string;
53
+ readonly default: string;
54
+ };
55
+ readonly size: {
56
+ readonly xs: number;
57
+ readonly sm: number;
58
+ readonly base: number;
59
+ readonly md: number;
60
+ readonly lg: number;
61
+ readonly xl: number;
62
+ readonly xxl: number;
63
+ };
64
+ readonly lineHeight: {
65
+ readonly tight: number;
66
+ readonly normal: number;
67
+ readonly relaxed: number;
68
+ };
69
+ readonly weight: {
70
+ readonly regular: number;
71
+ readonly medium: number;
72
+ readonly semibold: number;
73
+ readonly bold: number;
74
+ };
75
+ };
76
+ /** Icon tokens for Material Symbols configuration */
77
+ readonly icons: {
78
+ readonly variant: 'outlined' | 'rounded' | 'sharp';
79
+ readonly weight: 100 | 200 | 300 | 400 | 500 | 600 | 700;
80
+ readonly grade: -25 | 0 | 200;
81
+ };
30
82
  }
31
83
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tokens/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,6DAA6D;IAC7D,QAAQ,CAAC,kBAAkB,EAAE,WAAW,CAAC;IACzC,iEAAiE;IACjE,QAAQ,CAAC,gBAAgB,EAAE,WAAW,CAAC;IACvC,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,iEAAiE;IACjE,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC;IACpC,iDAAiD;IACjD,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,sCAAsC;IACtC,QAAQ,CAAC,gBAAgB,EAAE,WAAW,CAAC;IACvC,+CAA+C;IAC/C,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC;IACxC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tokens/types.ts"],"names":[],"mappings":"AAAA,OAAO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,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;QACnD,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;QACzD,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;KAC/B,CAAC;CACH"}
@@ -3,21 +3,24 @@ import type { ResolvedTokens } from './types';
3
3
  /**
4
4
  * Hook to compute design tokens for the current theme/mode/elevation.
5
5
  *
6
- * This hook automatically recomputes tokens when the theme configuration,
7
- * mode, theme name, or elevation changes. Results are memoized to avoid
8
- * unnecessary computation.
6
+ * Resolution order:
7
+ * 1. Explicit elevation parameter takes highest priority
8
+ * 2. FrameContext values (from nearest parent Frame) are used when elevation is omitted
9
+ * 3. Falls back to NewtoneProvider theme + elevation 1
9
10
  *
10
- * @param elevation - Elevation level (0=sunken, 1=default, 2=elevated)
11
+ * Theme always reads from FrameContext if present, falling back to NewtoneProvider.
12
+ *
13
+ * @param elevation - Elevation level (0=sunken, 1=default, 2=elevated).
14
+ * When omitted, reads from FrameContext or defaults to 1.
11
15
  * @returns Resolved design tokens with all necessary colors
12
16
  *
13
17
  * @example
14
18
  * ```tsx
15
- * function Button() {
16
- * const tokens = useTokens(1); // Default elevation
19
+ * // Inside a <Frame theme="primary" elevation={1}>:
20
+ * function MyComponent() {
21
+ * const tokens = useTokens(); // Gets primary theme, elevation 2 (mapped from Frame's 1)
17
22
  * return (
18
- * <button style={{ backgroundColor: srgbToHex(tokens.interactive.srgb) }}>
19
- * Click me
20
- * </button>
23
+ * <View style={{ backgroundColor: srgbToHex(tokens.background.srgb) }} />
21
24
  * );
22
25
  * }
23
26
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"useTokens.d.ts","sourceRoot":"","sources":["../../src/tokens/useTokens.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,SAAS,GAAE,cAAkB,GAAG,cAAc,CAavE"}
1
+ {"version":3,"file":"useTokens.d.ts","sourceRoot":"","sources":["../../src/tokens/useTokens.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,SAAS,CAAC,EAAE,cAAc,GAAG,cAAc,CAwBpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtonedev/components",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "React + React Native Web component library for Newtone",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -0,0 +1,20 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { srgbToHex } from 'newtone';
3
+ import type { ResolvedTokens } from '../tokens/types';
4
+
5
+ export function getAppShellStyles(tokens: ResolvedTokens) {
6
+ return StyleSheet.create({
7
+ container: {
8
+ flex: 1,
9
+ flexDirection: 'row',
10
+ overflow: 'hidden',
11
+ backgroundColor: srgbToHex(tokens.background.srgb),
12
+ },
13
+ main: {
14
+ flex: 1,
15
+ flexDirection: 'column',
16
+ minWidth: 0,
17
+ overflow: 'hidden',
18
+ },
19
+ });
20
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import type { AppShellProps } from './AppShell.types';
4
+ import { useTokens } from '../tokens/useTokens';
5
+ import { getAppShellStyles } from './AppShell.styles';
6
+
7
+ export function AppShell({ sidebar, children }: AppShellProps) {
8
+ const tokens = useTokens();
9
+ const styles = React.useMemo(() => getAppShellStyles(tokens), [tokens]);
10
+
11
+ return (
12
+ <View style={styles.container}>
13
+ {sidebar}
14
+ <View style={styles.main}>{children}</View>
15
+ </View>
16
+ );
17
+ }
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ export interface AppShellProps {
4
+ /** Sidebar element rendered on the left */
5
+ readonly sidebar?: ReactNode;
6
+ /** Main content area (navbar + page content) */
7
+ readonly children: ReactNode;
8
+ }
@@ -0,0 +1,2 @@
1
+ export { AppShell } from './AppShell';
2
+ export type { AppShellProps } from './AppShell.types';
@@ -4,13 +4,36 @@ import type { ResolvedTokens } from '../tokens/types';
4
4
  import type { ButtonVariant, ButtonSize } from './Button.types';
5
5
 
6
6
  /**
7
- * Size configuration for buttons
7
+ * Get size configuration for buttons using design tokens
8
8
  */
9
- const SIZE_CONFIG = {
10
- sm: { paddingVertical: 6, paddingHorizontal: 12, fontSize: 12, borderRadius: 4 },
11
- md: { paddingVertical: 10, paddingHorizontal: 20, fontSize: 14, borderRadius: 6 },
12
- lg: { paddingVertical: 14, paddingHorizontal: 28, fontSize: 16, borderRadius: 8 },
13
- } as const;
9
+ function getSizeConfig(tokens: ResolvedTokens) {
10
+ return {
11
+ sm: {
12
+ paddingVertical: tokens.spacing.xs,
13
+ paddingHorizontal: tokens.spacing.md,
14
+ fontSize: tokens.typography.size.sm,
15
+ borderRadius: tokens.radius.sm,
16
+ gap: tokens.spacing.xs,
17
+ iconSize: tokens.typography.size.sm,
18
+ },
19
+ md: {
20
+ paddingVertical: tokens.spacing.sm,
21
+ paddingHorizontal: tokens.spacing.lg,
22
+ fontSize: tokens.typography.size.base,
23
+ borderRadius: tokens.radius.md,
24
+ gap: tokens.spacing.sm,
25
+ iconSize: tokens.typography.size.base,
26
+ },
27
+ lg: {
28
+ paddingVertical: tokens.spacing.md,
29
+ paddingHorizontal: tokens.spacing.xl,
30
+ fontSize: tokens.typography.size.base,
31
+ borderRadius: tokens.radius.lg,
32
+ gap: tokens.spacing.sm,
33
+ iconSize: tokens.typography.size.base,
34
+ },
35
+ };
36
+ }
14
37
 
15
38
  /**
16
39
  * Compute button styles based on tokens, variant, size, and state
@@ -19,24 +42,27 @@ const SIZE_CONFIG = {
19
42
  * @param variant - Button variant (primary, secondary, ghost, outline)
20
43
  * @param size - Button size (sm, md, lg)
21
44
  * @param disabled - Whether button is disabled
22
- * @returns StyleSheet with button styles
45
+ * @param isIconOnly - Whether the button shows only an icon (no text)
46
+ * @returns StyleSheet with button styles + iconColor for the Icon component
23
47
  */
24
48
  export function getButtonStyles(
25
49
  tokens: ResolvedTokens,
26
50
  variant: ButtonVariant,
27
51
  size: ButtonSize,
28
- disabled: boolean
52
+ disabled: boolean,
53
+ isIconOnly: boolean
29
54
  ) {
30
- const sizeConfig = SIZE_CONFIG[size];
55
+ const sizeConfig = getSizeConfig(tokens)[size];
31
56
 
32
57
  // Base styles
33
58
  const base = {
34
59
  paddingVertical: sizeConfig.paddingVertical,
35
- paddingHorizontal: sizeConfig.paddingHorizontal,
60
+ paddingHorizontal: isIconOnly ? sizeConfig.paddingVertical : sizeConfig.paddingHorizontal,
36
61
  borderRadius: sizeConfig.borderRadius,
37
62
  alignItems: 'center' as const,
38
63
  justifyContent: 'center' as const,
39
64
  flexDirection: 'row' as const,
65
+ gap: sizeConfig.gap,
40
66
  };
41
67
 
42
68
  // Variant-specific colors
@@ -66,35 +92,42 @@ export function getButtonStyles(
66
92
  break;
67
93
  }
68
94
 
69
- return StyleSheet.create({
70
- base: {
71
- ...base,
72
- backgroundColor: disabled ? srgbToHex(tokens.backgroundSunken.srgb) : backgroundColor,
73
- borderWidth,
74
- ...(borderColor && { borderColor }),
75
- },
76
- pressed: {
77
- backgroundColor:
78
- variant === 'primary'
79
- ? srgbToHex(tokens.interactiveActive.srgb)
80
- : variant === 'secondary'
81
- ? srgbToHex(tokens.backgroundSunken.srgb)
82
- : 'transparent',
83
- opacity: variant === 'ghost' || variant === 'outline' ? 0.7 : 1,
84
- },
85
- disabled: {
86
- opacity: 0.4,
87
- },
88
- text: {
89
- fontSize: sizeConfig.fontSize,
90
- fontWeight: '600' as const,
91
- color: disabled ? srgbToHex(tokens.textSecondary.srgb) : textColor,
92
- },
93
- textPressed: {
94
- // Color changes handled by parent opacity
95
- },
96
- textDisabled: {
97
- // Color already set in text style via disabled check
98
- },
99
- });
95
+ const resolvedTextColor = disabled ? srgbToHex(tokens.textSecondary.srgb) : textColor;
96
+
97
+ return {
98
+ iconColor: resolvedTextColor,
99
+ iconSize: sizeConfig.iconSize,
100
+ styles: StyleSheet.create({
101
+ base: {
102
+ ...base,
103
+ backgroundColor: disabled ? srgbToHex(tokens.backgroundSunken.srgb) : backgroundColor,
104
+ borderWidth,
105
+ ...(borderColor && { borderColor }),
106
+ },
107
+ pressed: {
108
+ backgroundColor:
109
+ variant === 'primary'
110
+ ? srgbToHex(tokens.interactiveActive.srgb)
111
+ : variant === 'secondary'
112
+ ? srgbToHex(tokens.backgroundSunken.srgb)
113
+ : 'transparent',
114
+ opacity: variant === 'ghost' || variant === 'outline' ? 0.7 : 1,
115
+ },
116
+ disabled: {
117
+ opacity: 0.4,
118
+ },
119
+ text: {
120
+ fontFamily: tokens.typography.fonts.default,
121
+ fontSize: sizeConfig.fontSize,
122
+ fontWeight: tokens.typography.weight.semibold as any,
123
+ color: resolvedTextColor,
124
+ },
125
+ textPressed: {
126
+ // Color changes handled by parent opacity
127
+ },
128
+ textDisabled: {
129
+ // Color already set in text style via disabled check
130
+ },
131
+ }),
132
+ };
100
133
  }