@impulse-ui-native/theme 1.0.7 → 1.0.8
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/index.cjs.js +76 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.esm.js +68 -12
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/constants/index.ts +2 -1
- package/src/constants/typography.constants.ts +25 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-components-theme.hook.ts +12 -0
- package/src/index.ts +6 -6
- package/src/providers/theme.provider.tsx +25 -7
- package/src/theme/dark.theme.ts +5 -0
- package/src/theme/index.ts +1 -0
- package/src/theme/light.theme.ts +5 -0
- package/src/types/theme-provider.types.ts +11 -2
package/dist/index.cjs.js
CHANGED
|
@@ -20,14 +20,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
BorderSizeTokens: () => BorderSizeTokens,
|
|
23
24
|
DarkTheme: () => DarkTheme,
|
|
25
|
+
FontSizeTokens: () => FontSizeTokens,
|
|
26
|
+
FontWeightsItalic: () => FontWeightsItalic,
|
|
27
|
+
FontWeightsNormal: () => FontWeightsNormal,
|
|
24
28
|
LightTheme: () => LightTheme,
|
|
29
|
+
NeutralColorTokens: () => NeutralColorTokens,
|
|
30
|
+
RadiiTokens: () => RadiiTokens,
|
|
31
|
+
SpaceTokens: () => SpaceTokens,
|
|
25
32
|
StylePropsSet: () => StylePropsSet,
|
|
26
33
|
ThemeProvider: () => ThemeProvider,
|
|
27
34
|
createStyleKey: () => createStyleKey,
|
|
28
35
|
extractStyleProps: () => extractStyleProps,
|
|
29
36
|
useBorder: () => useBorder,
|
|
30
37
|
useColors: () => useColors,
|
|
38
|
+
useComponentsTheme: () => useComponentsTheme,
|
|
31
39
|
useRadii: () => useRadii,
|
|
32
40
|
useSpace: () => useSpace,
|
|
33
41
|
useStyleProps: () => useStyleProps,
|
|
@@ -112,6 +120,30 @@ var StylePropsSet = /* @__PURE__ */ new Set([
|
|
|
112
120
|
"aspectRatio"
|
|
113
121
|
]);
|
|
114
122
|
|
|
123
|
+
// src/constants/typography.constants.ts
|
|
124
|
+
var FontWeightsNormal = {
|
|
125
|
+
100: "Montserrat_100Thin",
|
|
126
|
+
200: "Montserrat_200ExtraLight",
|
|
127
|
+
300: "Montserrat_300Light",
|
|
128
|
+
400: "Montserrat_400Regular",
|
|
129
|
+
500: "Montserrat_500Medium",
|
|
130
|
+
600: "Montserrat_600SemiBold",
|
|
131
|
+
700: "Montserrat_700Bold",
|
|
132
|
+
800: "Montserrat_800ExtraBold",
|
|
133
|
+
900: "Montserrat_900Black"
|
|
134
|
+
};
|
|
135
|
+
var FontWeightsItalic = {
|
|
136
|
+
100: "Montserrat_100Thin_Italic",
|
|
137
|
+
200: "Montserrat_200ExtraLight_Italic",
|
|
138
|
+
300: "Montserrat_300Light_Italic",
|
|
139
|
+
400: "Montserrat_400Regular_Italic",
|
|
140
|
+
500: "Montserrat_500Medium_Italic",
|
|
141
|
+
600: "Montserrat_600SemiBold_Italic",
|
|
142
|
+
700: "Montserrat_700Bold_Italic",
|
|
143
|
+
800: "Montserrat_800ExtraBold_Italic",
|
|
144
|
+
900: "Montserrat_900Black_Italic"
|
|
145
|
+
};
|
|
146
|
+
|
|
115
147
|
// src/hooks/use-border.hook.ts
|
|
116
148
|
var import_react2 = require("react");
|
|
117
149
|
|
|
@@ -202,6 +234,10 @@ var DarkTheme = {
|
|
|
202
234
|
},
|
|
203
235
|
spacing: SpaceTokens,
|
|
204
236
|
radii: RadiiTokens,
|
|
237
|
+
fontWeights: {
|
|
238
|
+
normal: FontWeightsNormal,
|
|
239
|
+
italic: FontWeightsItalic
|
|
240
|
+
},
|
|
205
241
|
borderSize: BorderSizeTokens,
|
|
206
242
|
fontSize: FontSizeTokens
|
|
207
243
|
};
|
|
@@ -229,6 +265,10 @@ var LightTheme = {
|
|
|
229
265
|
},
|
|
230
266
|
spacing: SpaceTokens,
|
|
231
267
|
radii: RadiiTokens,
|
|
268
|
+
fontWeights: {
|
|
269
|
+
normal: FontWeightsNormal,
|
|
270
|
+
italic: FontWeightsItalic
|
|
271
|
+
},
|
|
232
272
|
borderSize: BorderSizeTokens,
|
|
233
273
|
fontSize: FontSizeTokens
|
|
234
274
|
};
|
|
@@ -260,11 +300,20 @@ var ThemeProvider = (0, import_react.memo)(function ThemeProvider2(props) {
|
|
|
260
300
|
});
|
|
261
301
|
const context = (0, import_react.useMemo)(() => {
|
|
262
302
|
const baseTheme = scheme === "light" ? LightTheme : DarkTheme;
|
|
303
|
+
const customBaseTheme = props.theme?.[scheme];
|
|
304
|
+
const theme = (0, import_core.merge)(baseTheme, customBaseTheme);
|
|
305
|
+
let componentsTheme;
|
|
306
|
+
if (typeof props.components === "function") {
|
|
307
|
+
componentsTheme = props.components(theme);
|
|
308
|
+
} else {
|
|
309
|
+
componentsTheme = props.components;
|
|
310
|
+
}
|
|
263
311
|
return {
|
|
264
312
|
loaded,
|
|
265
|
-
theme
|
|
313
|
+
theme,
|
|
314
|
+
components: componentsTheme
|
|
266
315
|
};
|
|
267
|
-
}, [props.theme?.light, props.theme?.dark]);
|
|
316
|
+
}, [props.theme?.light, props.theme?.dark, props.components]);
|
|
268
317
|
return /* @__PURE__ */ React.createElement(ThemeContext.Provider, { value: context }, props.children);
|
|
269
318
|
});
|
|
270
319
|
function useThemeContext() {
|
|
@@ -288,22 +337,29 @@ function useColors() {
|
|
|
288
337
|
return (0, import_react3.useMemo)(() => context.theme.colors, [context.theme.colors]);
|
|
289
338
|
}
|
|
290
339
|
|
|
291
|
-
// src/hooks/use-
|
|
340
|
+
// src/hooks/use-components-theme.hook.ts
|
|
292
341
|
var import_react4 = require("react");
|
|
342
|
+
function useComponentsTheme() {
|
|
343
|
+
const context = useThemeContext();
|
|
344
|
+
return (0, import_react4.useMemo)(() => context.components, [context.components]);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/hooks/use-radii.hook.ts
|
|
348
|
+
var import_react5 = require("react");
|
|
293
349
|
function useRadii() {
|
|
294
350
|
const context = useThemeContext();
|
|
295
|
-
return (0,
|
|
351
|
+
return (0, import_react5.useMemo)(() => context.theme.radii, [context.theme.radii]);
|
|
296
352
|
}
|
|
297
353
|
|
|
298
354
|
// src/hooks/use-space.hook.ts
|
|
299
|
-
var
|
|
355
|
+
var import_react6 = require("react");
|
|
300
356
|
function useSpace() {
|
|
301
357
|
const context = useThemeContext();
|
|
302
|
-
return (0,
|
|
358
|
+
return (0, import_react6.useMemo)(() => context.theme.spacing, [context.theme.spacing]);
|
|
303
359
|
}
|
|
304
360
|
|
|
305
361
|
// src/hooks/use-style-props.hook.ts
|
|
306
|
-
var
|
|
362
|
+
var import_react7 = require("react");
|
|
307
363
|
|
|
308
364
|
// src/utils/style.utils.ts
|
|
309
365
|
var isStylePropKey = (k) => StylePropsSet.has(k);
|
|
@@ -329,32 +385,40 @@ var createStyleKey = (props) => {
|
|
|
329
385
|
// src/hooks/use-style-props.hook.ts
|
|
330
386
|
function useStyleProps(props) {
|
|
331
387
|
const key = createStyleKey(props);
|
|
332
|
-
return (0,
|
|
388
|
+
return (0, import_react7.useMemo)(() => extractStyleProps(props), [key]);
|
|
333
389
|
}
|
|
334
390
|
|
|
335
391
|
// src/hooks/use-theme.hook.ts
|
|
336
|
-
var
|
|
392
|
+
var import_react8 = require("react");
|
|
337
393
|
function useTheme() {
|
|
338
394
|
const context = useThemeContext();
|
|
339
|
-
return (0,
|
|
395
|
+
return (0, import_react8.useMemo)(() => context.theme, [context.theme]);
|
|
340
396
|
}
|
|
341
397
|
|
|
342
398
|
// src/hooks/use-themed-styles.ts
|
|
343
|
-
var
|
|
399
|
+
var import_react9 = require("react");
|
|
344
400
|
var useThemedStyles = (styledFunction, props) => {
|
|
345
401
|
const theme = useTheme();
|
|
346
|
-
return (0,
|
|
402
|
+
return (0, import_react9.useMemo)(() => styledFunction(theme, props), [theme, props]);
|
|
347
403
|
};
|
|
348
404
|
// Annotate the CommonJS export names for ESM import in node:
|
|
349
405
|
0 && (module.exports = {
|
|
406
|
+
BorderSizeTokens,
|
|
350
407
|
DarkTheme,
|
|
408
|
+
FontSizeTokens,
|
|
409
|
+
FontWeightsItalic,
|
|
410
|
+
FontWeightsNormal,
|
|
351
411
|
LightTheme,
|
|
412
|
+
NeutralColorTokens,
|
|
413
|
+
RadiiTokens,
|
|
414
|
+
SpaceTokens,
|
|
352
415
|
StylePropsSet,
|
|
353
416
|
ThemeProvider,
|
|
354
417
|
createStyleKey,
|
|
355
418
|
extractStyleProps,
|
|
356
419
|
useBorder,
|
|
357
420
|
useColors,
|
|
421
|
+
useComponentsTheme,
|
|
358
422
|
useRadii,
|
|
359
423
|
useSpace,
|
|
360
424
|
useStyleProps,
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/constants/style.constants.ts","../src/hooks/use-border.hook.ts","../src/providers/theme.provider.tsx","../src/theme/tokens.theme.ts","../src/theme/dark.theme.ts","../src/theme/light.theme.ts","../src/hooks/use-colors.hook.ts","../src/hooks/use-radii.hook.ts","../src/hooks/use-space.hook.ts","../src/hooks/use-style-props.hook.ts","../src/utils/style.utils.ts","../src/hooks/use-theme.hook.ts","../src/hooks/use-themed-styles.ts"],"sourcesContent":["export * from './constants';\r\nexport * from './hooks';\r\nexport * from './providers';\r\nexport * from './theme';\r\nexport * from './types';\r\nexport * from './utils';\r\n","import { StyleProps } from \"../types\";\r\n\r\nexport const StylePropsSet = new Set<keyof StyleProps>([\r\n // Spacing\r\n \"margin\",\r\n \"marginTop\",\r\n \"marginBottom\",\r\n \"marginLeft\",\r\n \"marginRight\",\r\n \"marginHorizontal\",\r\n \"marginVertical\",\r\n \"padding\",\r\n \"paddingTop\",\r\n \"paddingBottom\",\r\n \"paddingLeft\",\r\n \"paddingRight\",\r\n \"paddingHorizontal\",\r\n \"paddingVertical\",\r\n\r\n // Appearance\r\n \"color\",\r\n \"backgroundColor\",\r\n \"opacity\",\r\n \"borderRadius\",\r\n \"borderColor\",\r\n \"borderWidth\",\r\n \"borderStyle\",\r\n \"shadowColor\",\r\n \"shadowOpacity\",\r\n \"shadowRadius\",\r\n \"shadowOffset\",\r\n \"elevation\",\r\n\r\n // Typography (TextStyle)\r\n \"fontSize\",\r\n \"fontFamily\",\r\n \"fontWeight\",\r\n \"fontStyle\",\r\n \"letterSpacing\",\r\n \"lineHeight\",\r\n \"textAlign\",\r\n \"textDecorationLine\",\r\n \"textDecorationStyle\",\r\n \"textDecorationColor\",\r\n \"textTransform\",\r\n \"includeFontPadding\",\r\n \"textAlignVertical\",\r\n \"writingDirection\",\r\n\r\n // Flex (ViewStyle)\r\n \"flex\",\r\n \"flexGrow\",\r\n \"flexShrink\",\r\n \"flexBasis\",\r\n \"flexDirection\",\r\n \"flexWrap\",\r\n \"justifyContent\",\r\n \"alignItems\",\r\n \"alignSelf\",\r\n \"alignContent\",\r\n \"gap\",\r\n \"rowGap\",\r\n \"columnGap\",\r\n\r\n // Positioning (commonly used with flex layouts)\r\n \"position\",\r\n \"top\",\r\n \"right\",\r\n \"bottom\",\r\n \"left\",\r\n\r\n // Dimensions (ViewStyle)\r\n \"width\",\r\n \"height\",\r\n \"minWidth\",\r\n \"maxWidth\",\r\n \"minHeight\",\r\n \"maxHeight\",\r\n \"aspectRatio\",\r\n]);\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { BorderSizes } from \"../types\";\r\n\r\nexport function useBorder(): BorderSizes {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.borderSize, [context.theme.borderSize]);\r\n}\r\n","import { DeepPartial, merge } from \"@impulse-ui-native/core\";\r\nimport {\r\n createContext,\r\n memo,\r\n PropsWithChildren,\r\n useContext,\r\n useMemo,\r\n} from \"react\";\r\nimport { DarkTheme, LightTheme } from \"../theme\";\r\nimport { AppTheme, ColorScheme, ThemeContextData } from \"../types\";\r\n\r\nimport {\r\n Montserrat_100Thin,\r\n Montserrat_100Thin_Italic,\r\n Montserrat_200ExtraLight,\r\n Montserrat_200ExtraLight_Italic,\r\n Montserrat_300Light,\r\n Montserrat_300Light_Italic,\r\n Montserrat_400Regular,\r\n Montserrat_400Regular_Italic,\r\n Montserrat_500Medium,\r\n Montserrat_500Medium_Italic,\r\n Montserrat_600SemiBold,\r\n Montserrat_600SemiBold_Italic,\r\n Montserrat_700Bold,\r\n Montserrat_700Bold_Italic,\r\n Montserrat_800ExtraBold,\r\n Montserrat_800ExtraBold_Italic,\r\n Montserrat_900Black,\r\n Montserrat_900Black_Italic,\r\n useFonts,\r\n} from \"@expo-google-fonts/montserrat\";\r\n\r\nconst ThemeContext = createContext<ThemeContextData | undefined>(undefined);\r\n\r\ninterface ThemeProviderProps {\r\n scheme: ColorScheme;\r\n theme: {\r\n light: AppTheme;\r\n dark: AppTheme;\r\n };\r\n}\r\n\r\nexport const ThemeProvider = memo(function ThemeProvider(\r\n props: PropsWithChildren<DeepPartial<ThemeProviderProps>>\r\n) {\r\n const scheme = props.scheme ?? \"light\";\r\n\r\n const [loaded] = useFonts({\r\n Montserrat_100Thin,\r\n Montserrat_100Thin_Italic,\r\n Montserrat_200ExtraLight,\r\n Montserrat_200ExtraLight_Italic,\r\n Montserrat_300Light,\r\n Montserrat_300Light_Italic,\r\n Montserrat_400Regular,\r\n Montserrat_400Regular_Italic,\r\n Montserrat_500Medium,\r\n Montserrat_500Medium_Italic,\r\n Montserrat_600SemiBold,\r\n Montserrat_600SemiBold_Italic,\r\n Montserrat_700Bold,\r\n Montserrat_700Bold_Italic,\r\n Montserrat_800ExtraBold,\r\n Montserrat_800ExtraBold_Italic,\r\n Montserrat_900Black,\r\n Montserrat_900Black_Italic,\r\n });\r\n\r\n const context = useMemo<ThemeContextData>(() => {\r\n const baseTheme = scheme === \"light\" ? LightTheme : DarkTheme;\r\n\r\n return {\r\n loaded,\r\n theme: merge(baseTheme, props.theme?.[scheme]),\r\n };\r\n }, [props.theme?.light, props.theme?.dark]);\r\n\r\n return (\r\n <ThemeContext.Provider value={context}>\r\n {props.children}\r\n </ThemeContext.Provider>\r\n );\r\n});\r\n\r\nexport function useThemeContext() {\r\n const context = useContext(ThemeContext);\r\n\r\n if (!context) {\r\n throw new Error(\"useThemeContext must be used within a ThemeProvider\");\r\n }\r\n\r\n return context;\r\n}\r\n","import { BorderSizes, FontSizes, NeutralColors, Radii, Space } from \"../types\";\r\n\r\nexport const SpaceTokens: Space = {\r\n none: 0,\r\n auto: \"auto\",\r\n xxs: 4,\r\n xs: 8,\r\n mxs: 12,\r\n sm: 16,\r\n msm: 24,\r\n md: 32,\r\n lg: 48,\r\n xl: 64,\r\n xxl: 96,\r\n};\r\n\r\nexport const BorderSizeTokens: BorderSizes = {\r\n sm: 1,\r\n md: 2,\r\n lg: 3,\r\n xl: 5,\r\n xxl: 10,\r\n};\r\n\r\nexport const RadiiTokens: Radii = {\r\n sm: 4,\r\n md: 8,\r\n lg: 16,\r\n xl: 32,\r\n xxl: 64,\r\n xxxl: 128,\r\n round: 100000,\r\n};\r\n\r\nexport const FontSizeTokens: FontSizes = {\r\n xxs: 8,\r\n xs: 12,\r\n xsm: 14,\r\n sm: 16,\r\n md: 18,\r\n lg: 20,\r\n xl: 24,\r\n xxl: 32,\r\n xxxl: 40,\r\n huge: 48,\r\n massive: 56,\r\n};\r\n\r\nexport const NeutralColorTokens: NeutralColors = {\r\n \"0\": \"#ffffff\",\r\n \"1\": \"#f8f9fa\",\r\n \"2\": \"#f1f3f5\",\r\n \"3\": \"#e9ecef\",\r\n \"4\": \"#dee2e6\",\r\n \"5\": \"#ced4da\",\r\n \"6\": \"#adb5bd\",\r\n \"7\": \"#868e96\",\r\n \"8\": \"#495057\",\r\n \"9\": \"#343a40\",\r\n \"10\": \"#212529\",\r\n \"11\": \"#16191d\",\r\n \"12\": \"#0d0f12\",\r\n \"13\": \"#000000\",\r\n};\r\n","import { AppTheme } from \"../types\";\r\nimport {\r\n BorderSizeTokens,\r\n FontSizeTokens,\r\n NeutralColorTokens,\r\n RadiiTokens,\r\n SpaceTokens,\r\n} from \"./tokens.theme\";\r\n\r\nexport const DarkTheme: AppTheme = {\r\n colors: {\r\n primary: \"#f55d6b\",\r\n secondary: \"#f55d6b\",\r\n neutral: NeutralColorTokens,\r\n white: NeutralColorTokens[\"0\"],\r\n black: NeutralColorTokens[\"13\"],\r\n error: \"#c92a2a\",\r\n warning: \"#e67700\",\r\n success: \"#7a9908\",\r\n info: \"#1864ab\",\r\n text: {\r\n primary: NeutralColorTokens[\"11\"],\r\n secondary: NeutralColorTokens[\"10\"],\r\n },\r\n background: {\r\n primary: NeutralColorTokens[\"2\"],\r\n secondary: NeutralColorTokens[\"0\"],\r\n },\r\n },\r\n spacing: SpaceTokens,\r\n radii: RadiiTokens,\r\n borderSize: BorderSizeTokens,\r\n fontSize: FontSizeTokens,\r\n};\r\n","import { AppTheme } from \"../types\";\r\nimport {\r\n BorderSizeTokens,\r\n FontSizeTokens,\r\n NeutralColorTokens,\r\n RadiiTokens,\r\n SpaceTokens,\r\n} from \"./tokens.theme\";\r\n\r\nexport const LightTheme: AppTheme = {\r\n colors: {\r\n primary: \"#f55d6b\",\r\n secondary: \"#f55d6b\",\r\n neutral: NeutralColorTokens,\r\n white: NeutralColorTokens[\"0\"],\r\n black: NeutralColorTokens[\"13\"],\r\n error: \"#c92a2a\",\r\n warning: \"#e67700\",\r\n success: \"#7a9908\",\r\n info: \"#1864ab\",\r\n text: {\r\n primary: NeutralColorTokens[\"11\"],\r\n secondary: NeutralColorTokens[\"10\"],\r\n },\r\n background: {\r\n primary: NeutralColorTokens[\"2\"],\r\n secondary: NeutralColorTokens[\"0\"],\r\n },\r\n },\r\n spacing: SpaceTokens,\r\n radii: RadiiTokens,\r\n borderSize: BorderSizeTokens,\r\n fontSize: FontSizeTokens,\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { ThemeColors } from \"../types\";\r\n\r\nexport function useColors(): ThemeColors {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.colors, [context.theme.colors]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { Radii } from \"../types\";\r\n\r\nexport function useRadii(): Radii {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.radii, [context.theme.radii]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { Space } from \"../types\";\r\n\r\nexport function useSpace(): Space {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.spacing, [context.theme.spacing]);\r\n}\r\n","import { useMemo } from 'react';\r\nimport { createStyleKey, extractStyleProps } from '../utils';\r\n\r\nexport function useStyleProps<Props extends object>(props: Props) {\r\n const key = createStyleKey(props);\r\n\r\n return useMemo(() => extractStyleProps(props), [key]);\r\n}\r\n","import { StylePropsSet } from '../constants';\r\nimport { StylePropKey, StyleProps } from '../types';\r\n\r\nconst isStylePropKey = (k: string): k is StylePropKey =>\r\n StylePropsSet.has(k as StylePropKey);\r\n\r\nexport const extractStyleProps = <Props extends object>(\r\n props: Props\r\n): StyleProps => {\r\n const style: StyleProps = {};\r\n \r\n for (const k in props) {\r\n if (isStylePropKey(k) && props[k] !== undefined) {\r\n style[k] = props[k] as any;\r\n }\r\n }\r\n \r\n return style;\r\n};\r\n\r\nexport const createStyleKey = <Props extends object>(props: Props) => {\r\n let key = '';\r\n\r\n for (const k in props) {\r\n if (isStylePropKey(k)) {\r\n key += String(props[k as keyof Props]);\r\n }\r\n }\r\n \r\n return key;\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { AppTheme } from \"../types\";\r\n\r\nexport function useTheme(): AppTheme {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme, [context.theme]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { StyleSheet } from \"react-native\";\r\nimport { AppTheme } from \"../types\";\r\nimport { useTheme } from \"./use-theme.hook\";\r\n\r\ntype ThemedStyles<T extends StyleSheet.NamedStyles<T>> = T;\r\n\r\ntype StyledFunction<\r\n Props extends object,\r\n T extends StyleSheet.NamedStyles<T>\r\n> = (theme: AppTheme, props: Props) => ThemedStyles<T>;\r\n\r\nexport const useThemedStyles = <\r\n Props extends object,\r\n T extends StyleSheet.NamedStyles<T>\r\n>(\r\n styledFunction: StyledFunction<Props, T>,\r\n props: Props\r\n): ThemedStyles<T> => {\r\n const theme = useTheme();\r\n\r\n return useMemo(() => styledFunction(theme, props), [theme, props]);\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,gBAAgB,oBAAI,IAAsB;AAAA;AAAA,EAErD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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AAI,CAAiB;AAE9B,IAAM,oBAAoB,CAC/B,UACe;AACf,QAAM,QAAoB,CAAC;AAE3B,aAAW,KAAK,OAAO;AACrB,QAAI,eAAe,CAAC,KAAK,MAAM,CAAC,MAAM,QAAW;AAC/C,YAAM,CAAC,IAAI,MAAM,CAAC;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAuB,UAAiB;AACpE,MAAI,MAAM;AAEV,aAAW,KAAK,OAAO;AACrB,QAAI,eAAe,CAAC,GAAG;AACrB,aAAO,OAAO,MAAM,CAAgB,CAAC;AAAA,IACvC;AAAA,EACF;AAEA,SAAO;AACT;;;AD3BO,SAAS,cAAoC,OAAc;AAChE,QAAM,MAAM,eAAe,KAAK;AAEhC,aAAO,uBAAQ,MAAM,kBAAkB,KAAK,GAAG,CAAC,GAAG,CAAC;AACtD;;;AEPA,IAAAC,gBAAwB;AAIjB,SAAS,WAAqB;AACnC,QAAM,UAAU,gBAAgB;AAEhC,aAAO,uBAAQ,MAAM,QAAQ,OAAO,CAAC,QAAQ,KAAK,CAAC;AACrD;;;ACRA,IAAAC,gBAAwB;AAYjB,IAAM,kBAAkB,CAI7B,gBACA,UACoB;AACpB,QAAM,QAAQ,SAAS;AAEvB,aAAO,uBAAQ,MAAM,eAAe,OAAO,KAAK,GAAG,CAAC,OAAO,KAAK,CAAC;AACnE;","names":["import_react","ThemeProvider","import_react","import_react","import_react","import_react","import_react","import_react"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/constants/style.constants.ts","../src/constants/typography.constants.ts","../src/hooks/use-border.hook.ts","../src/providers/theme.provider.tsx","../src/theme/tokens.theme.ts","../src/theme/dark.theme.ts","../src/theme/light.theme.ts","../src/hooks/use-colors.hook.ts","../src/hooks/use-components-theme.hook.ts","../src/hooks/use-radii.hook.ts","../src/hooks/use-space.hook.ts","../src/hooks/use-style-props.hook.ts","../src/utils/style.utils.ts","../src/hooks/use-theme.hook.ts","../src/hooks/use-themed-styles.ts"],"sourcesContent":["export * from \"./constants\";\r\nexport * from \"./hooks\";\r\nexport * from \"./providers\";\r\nexport * from \"./theme\";\r\nexport * from \"./types\";\r\nexport * from \"./utils\";\r\n","import { StyleProps } from \"../types\";\r\n\r\nexport const StylePropsSet = new Set<keyof StyleProps>([\r\n // Spacing\r\n \"margin\",\r\n \"marginTop\",\r\n \"marginBottom\",\r\n \"marginLeft\",\r\n \"marginRight\",\r\n \"marginHorizontal\",\r\n \"marginVertical\",\r\n \"padding\",\r\n \"paddingTop\",\r\n \"paddingBottom\",\r\n \"paddingLeft\",\r\n \"paddingRight\",\r\n \"paddingHorizontal\",\r\n \"paddingVertical\",\r\n\r\n // Appearance\r\n \"color\",\r\n \"backgroundColor\",\r\n \"opacity\",\r\n \"borderRadius\",\r\n \"borderColor\",\r\n \"borderWidth\",\r\n \"borderStyle\",\r\n \"shadowColor\",\r\n \"shadowOpacity\",\r\n \"shadowRadius\",\r\n \"shadowOffset\",\r\n \"elevation\",\r\n\r\n // Typography (TextStyle)\r\n \"fontSize\",\r\n \"fontFamily\",\r\n \"fontWeight\",\r\n \"fontStyle\",\r\n \"letterSpacing\",\r\n \"lineHeight\",\r\n \"textAlign\",\r\n \"textDecorationLine\",\r\n \"textDecorationStyle\",\r\n \"textDecorationColor\",\r\n \"textTransform\",\r\n \"includeFontPadding\",\r\n \"textAlignVertical\",\r\n \"writingDirection\",\r\n\r\n // Flex (ViewStyle)\r\n \"flex\",\r\n \"flexGrow\",\r\n \"flexShrink\",\r\n \"flexBasis\",\r\n \"flexDirection\",\r\n \"flexWrap\",\r\n \"justifyContent\",\r\n \"alignItems\",\r\n \"alignSelf\",\r\n \"alignContent\",\r\n \"gap\",\r\n \"rowGap\",\r\n \"columnGap\",\r\n\r\n // Positioning (commonly used with flex layouts)\r\n \"position\",\r\n \"top\",\r\n \"right\",\r\n \"bottom\",\r\n \"left\",\r\n\r\n // Dimensions (ViewStyle)\r\n \"width\",\r\n \"height\",\r\n \"minWidth\",\r\n \"maxWidth\",\r\n \"minHeight\",\r\n \"maxHeight\",\r\n \"aspectRatio\",\r\n]);\r\n","import { FontWeightItalic, FontWeightKey, FontWeightNormal } from \"../types\";\r\n\r\nexport const FontWeightsNormal: Record<FontWeightKey, FontWeightNormal> = {\r\n 100: \"Montserrat_100Thin\",\r\n 200: \"Montserrat_200ExtraLight\",\r\n 300: \"Montserrat_300Light\",\r\n 400: \"Montserrat_400Regular\",\r\n 500: \"Montserrat_500Medium\",\r\n 600: \"Montserrat_600SemiBold\",\r\n 700: \"Montserrat_700Bold\",\r\n 800: \"Montserrat_800ExtraBold\",\r\n 900: \"Montserrat_900Black\",\r\n};\r\n\r\nexport const FontWeightsItalic: Record<FontWeightKey, FontWeightItalic> = {\r\n 100: \"Montserrat_100Thin_Italic\",\r\n 200: \"Montserrat_200ExtraLight_Italic\",\r\n 300: \"Montserrat_300Light_Italic\",\r\n 400: \"Montserrat_400Regular_Italic\",\r\n 500: \"Montserrat_500Medium_Italic\",\r\n 600: \"Montserrat_600SemiBold_Italic\",\r\n 700: \"Montserrat_700Bold_Italic\",\r\n 800: \"Montserrat_800ExtraBold_Italic\",\r\n 900: \"Montserrat_900Black_Italic\",\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { BorderSizes } from \"../types\";\r\n\r\nexport function useBorder(): BorderSizes {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.borderSize, [context.theme.borderSize]);\r\n}\r\n","import { DeepPartial, merge } from \"@impulse-ui-native/core\";\r\nimport {\r\n createContext,\r\n memo,\r\n PropsWithChildren,\r\n useContext,\r\n useMemo,\r\n} from \"react\";\r\nimport { DarkTheme, LightTheme } from \"../theme\";\r\nimport {\r\n AppTheme,\r\n ColorScheme,\r\n ComponentsThemes,\r\n CustomComponentsTheme,\r\n ThemeContextData,\r\n} from \"../types\";\r\n\r\nimport {\r\n Montserrat_100Thin,\r\n Montserrat_100Thin_Italic,\r\n Montserrat_200ExtraLight,\r\n Montserrat_200ExtraLight_Italic,\r\n Montserrat_300Light,\r\n Montserrat_300Light_Italic,\r\n Montserrat_400Regular,\r\n Montserrat_400Regular_Italic,\r\n Montserrat_500Medium,\r\n Montserrat_500Medium_Italic,\r\n Montserrat_600SemiBold,\r\n Montserrat_600SemiBold_Italic,\r\n Montserrat_700Bold,\r\n Montserrat_700Bold_Italic,\r\n Montserrat_800ExtraBold,\r\n Montserrat_800ExtraBold_Italic,\r\n Montserrat_900Black,\r\n Montserrat_900Black_Italic,\r\n useFonts,\r\n} from \"@expo-google-fonts/montserrat\";\r\n\r\nconst ThemeContext = createContext<ThemeContextData | undefined>(undefined);\r\n\r\ninterface ThemeProviderProps {\r\n scheme?: ColorScheme;\r\n theme?: DeepPartial<{\r\n light: AppTheme;\r\n dark: AppTheme;\r\n }>;\r\n components?: CustomComponentsTheme;\r\n}\r\n\r\nexport const ThemeProvider = memo(function ThemeProvider(\r\n props: PropsWithChildren<ThemeProviderProps>\r\n) {\r\n const scheme = props.scheme ?? \"light\";\r\n\r\n const [loaded] = useFonts({\r\n Montserrat_100Thin,\r\n Montserrat_100Thin_Italic,\r\n Montserrat_200ExtraLight,\r\n Montserrat_200ExtraLight_Italic,\r\n Montserrat_300Light,\r\n Montserrat_300Light_Italic,\r\n Montserrat_400Regular,\r\n Montserrat_400Regular_Italic,\r\n Montserrat_500Medium,\r\n Montserrat_500Medium_Italic,\r\n Montserrat_600SemiBold,\r\n Montserrat_600SemiBold_Italic,\r\n Montserrat_700Bold,\r\n Montserrat_700Bold_Italic,\r\n Montserrat_800ExtraBold,\r\n Montserrat_800ExtraBold_Italic,\r\n Montserrat_900Black,\r\n Montserrat_900Black_Italic,\r\n });\r\n\r\n const context = useMemo<ThemeContextData>(() => {\r\n const baseTheme = scheme === \"light\" ? LightTheme : DarkTheme;\r\n const customBaseTheme = props.theme?.[scheme];\r\n const theme = merge(baseTheme, customBaseTheme);\r\n\r\n let componentsTheme: DeepPartial<ComponentsThemes> | undefined;\r\n\r\n if (typeof props.components === \"function\") {\r\n componentsTheme = props.components(theme);\r\n } else {\r\n componentsTheme = props.components;\r\n }\r\n\r\n return {\r\n loaded,\r\n theme,\r\n components: componentsTheme,\r\n };\r\n }, [props.theme?.light, props.theme?.dark, props.components]);\r\n\r\n return (\r\n <ThemeContext.Provider value={context}>\r\n {props.children}\r\n </ThemeContext.Provider>\r\n );\r\n});\r\n\r\nexport function useThemeContext() {\r\n const context = useContext(ThemeContext);\r\n\r\n if (!context) {\r\n throw new Error(\"useThemeContext must be used within a ThemeProvider\");\r\n }\r\n\r\n return context;\r\n}\r\n","import { BorderSizes, FontSizes, NeutralColors, Radii, Space } from \"../types\";\r\n\r\nexport const SpaceTokens: Space = {\r\n none: 0,\r\n auto: \"auto\",\r\n xxs: 4,\r\n xs: 8,\r\n mxs: 12,\r\n sm: 16,\r\n msm: 24,\r\n md: 32,\r\n lg: 48,\r\n xl: 64,\r\n xxl: 96,\r\n};\r\n\r\nexport const BorderSizeTokens: BorderSizes = {\r\n sm: 1,\r\n md: 2,\r\n lg: 3,\r\n xl: 5,\r\n xxl: 10,\r\n};\r\n\r\nexport const RadiiTokens: Radii = {\r\n sm: 4,\r\n md: 8,\r\n lg: 16,\r\n xl: 32,\r\n xxl: 64,\r\n xxxl: 128,\r\n round: 100000,\r\n};\r\n\r\nexport const FontSizeTokens: FontSizes = {\r\n xxs: 8,\r\n xs: 12,\r\n xsm: 14,\r\n sm: 16,\r\n md: 18,\r\n lg: 20,\r\n xl: 24,\r\n xxl: 32,\r\n xxxl: 40,\r\n huge: 48,\r\n massive: 56,\r\n};\r\n\r\nexport const NeutralColorTokens: NeutralColors = {\r\n \"0\": \"#ffffff\",\r\n \"1\": \"#f8f9fa\",\r\n \"2\": \"#f1f3f5\",\r\n \"3\": \"#e9ecef\",\r\n \"4\": \"#dee2e6\",\r\n \"5\": \"#ced4da\",\r\n \"6\": \"#adb5bd\",\r\n \"7\": \"#868e96\",\r\n \"8\": \"#495057\",\r\n \"9\": \"#343a40\",\r\n \"10\": \"#212529\",\r\n \"11\": \"#16191d\",\r\n \"12\": \"#0d0f12\",\r\n \"13\": \"#000000\",\r\n};\r\n","import { FontWeightsItalic, FontWeightsNormal } from \"../constants\";\r\nimport { AppTheme } from \"../types\";\r\nimport {\r\n BorderSizeTokens,\r\n FontSizeTokens,\r\n NeutralColorTokens,\r\n RadiiTokens,\r\n SpaceTokens,\r\n} from \"./tokens.theme\";\r\n\r\nexport const DarkTheme: AppTheme = {\r\n colors: {\r\n primary: \"#f55d6b\",\r\n secondary: \"#f55d6b\",\r\n neutral: NeutralColorTokens,\r\n white: NeutralColorTokens[\"0\"],\r\n black: NeutralColorTokens[\"13\"],\r\n error: \"#c92a2a\",\r\n warning: \"#e67700\",\r\n success: \"#7a9908\",\r\n info: \"#1864ab\",\r\n text: {\r\n primary: NeutralColorTokens[\"11\"],\r\n secondary: NeutralColorTokens[\"10\"],\r\n },\r\n background: {\r\n primary: NeutralColorTokens[\"2\"],\r\n secondary: NeutralColorTokens[\"0\"],\r\n },\r\n },\r\n spacing: SpaceTokens,\r\n radii: RadiiTokens,\r\n fontWeights: {\r\n normal: FontWeightsNormal,\r\n italic: FontWeightsItalic,\r\n },\r\n borderSize: BorderSizeTokens,\r\n fontSize: FontSizeTokens,\r\n};\r\n","import { FontWeightsItalic, FontWeightsNormal } from \"../constants\";\r\nimport { AppTheme } from \"../types\";\r\nimport {\r\n BorderSizeTokens,\r\n FontSizeTokens,\r\n NeutralColorTokens,\r\n RadiiTokens,\r\n SpaceTokens,\r\n} from \"./tokens.theme\";\r\n\r\nexport const LightTheme: AppTheme = {\r\n colors: {\r\n primary: \"#f55d6b\",\r\n secondary: \"#f55d6b\",\r\n neutral: NeutralColorTokens,\r\n white: NeutralColorTokens[\"0\"],\r\n black: NeutralColorTokens[\"13\"],\r\n error: \"#c92a2a\",\r\n warning: \"#e67700\",\r\n success: \"#7a9908\",\r\n info: \"#1864ab\",\r\n text: {\r\n primary: NeutralColorTokens[\"11\"],\r\n secondary: NeutralColorTokens[\"10\"],\r\n },\r\n background: {\r\n primary: NeutralColorTokens[\"2\"],\r\n secondary: NeutralColorTokens[\"0\"],\r\n },\r\n },\r\n spacing: SpaceTokens,\r\n radii: RadiiTokens,\r\n fontWeights: {\r\n normal: FontWeightsNormal,\r\n italic: FontWeightsItalic,\r\n },\r\n borderSize: BorderSizeTokens,\r\n fontSize: FontSizeTokens,\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { ThemeColors } from \"../types\";\r\n\r\nexport function useColors(): ThemeColors {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.colors, [context.theme.colors]);\r\n}\r\n","import { DeepPartial } from \"@impulse-ui-native/core\";\r\nimport { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { ComponentsThemes } from \"../types\";\r\n\r\nexport function useComponentsTheme():\r\n | DeepPartial<ComponentsThemes>\r\n | undefined {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.components, [context.components]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { Radii } from \"../types\";\r\n\r\nexport function useRadii(): Radii {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.radii, [context.theme.radii]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { Space } from \"../types\";\r\n\r\nexport function useSpace(): Space {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.spacing, [context.theme.spacing]);\r\n}\r\n","import { useMemo } from 'react';\r\nimport { createStyleKey, extractStyleProps } from '../utils';\r\n\r\nexport function useStyleProps<Props extends object>(props: Props) {\r\n const key = createStyleKey(props);\r\n\r\n return useMemo(() => extractStyleProps(props), [key]);\r\n}\r\n","import { StylePropsSet } from '../constants';\r\nimport { StylePropKey, StyleProps } from '../types';\r\n\r\nconst isStylePropKey = (k: string): k is StylePropKey =>\r\n StylePropsSet.has(k as StylePropKey);\r\n\r\nexport const extractStyleProps = <Props extends object>(\r\n props: Props\r\n): StyleProps => {\r\n const style: StyleProps = {};\r\n \r\n for (const k in props) {\r\n if (isStylePropKey(k) && props[k] !== undefined) {\r\n style[k] = props[k] as any;\r\n }\r\n }\r\n \r\n return style;\r\n};\r\n\r\nexport const createStyleKey = <Props extends object>(props: Props) => {\r\n let key = '';\r\n\r\n for (const k in props) {\r\n if (isStylePropKey(k)) {\r\n key += String(props[k as keyof Props]);\r\n }\r\n }\r\n \r\n return key;\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { AppTheme } from \"../types\";\r\n\r\nexport function useTheme(): AppTheme {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme, [context.theme]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { StyleSheet } from \"react-native\";\r\nimport { AppTheme } from \"../types\";\r\nimport { useTheme } from \"./use-theme.hook\";\r\n\r\ntype ThemedStyles<T extends StyleSheet.NamedStyles<T>> = T;\r\n\r\ntype StyledFunction<\r\n Props extends object,\r\n T extends StyleSheet.NamedStyles<T>\r\n> = (theme: AppTheme, props: Props) => ThemedStyles<T>;\r\n\r\nexport const useThemedStyles = <\r\n Props extends object,\r\n T extends StyleSheet.NamedStyles<T>\r\n>(\r\n styledFunction: StyledFunction<Props, T>,\r\n props: Props\r\n): ThemedStyles<T> => {\r\n const theme = useTheme();\r\n\r\n return useMemo(() => styledFunction(theme, props), [theme, props]);\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,gBAAgB,oBAAI,IAAsB;AAAA;AAAA,EAErD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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,SAAS,CAAC,QAAQ,MAAM,OAAO,CAAC;AACrE;;;ACRA,IAAAC,gBAAwB;;;ACGxB,IAAM,iBAAiB,CAAC,MACtB,cAAc,IAAI,CAAiB;AAE9B,IAAM,oBAAoB,CAC/B,UACe;AACf,QAAM,QAAoB,CAAC;AAE3B,aAAW,KAAK,OAAO;AACrB,QAAI,eAAe,CAAC,KAAK,MAAM,CAAC,MAAM,QAAW;AAC/C,YAAM,CAAC,IAAI,MAAM,CAAC;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAuB,UAAiB;AACpE,MAAI,MAAM;AAEV,aAAW,KAAK,OAAO;AACrB,QAAI,eAAe,CAAC,GAAG;AACrB,aAAO,OAAO,MAAM,CAAgB,CAAC;AAAA,IACvC;AAAA,EACF;AAEA,SAAO;AACT;;;AD3BO,SAAS,cAAoC,OAAc;AAChE,QAAM,MAAM,eAAe,KAAK;AAEhC,aAAO,uBAAQ,MAAM,kBAAkB,KAAK,GAAG,CAAC,GAAG,CAAC;AACtD;;;AEPA,IAAAC,gBAAwB;AAIjB,SAAS,WAAqB;AACnC,QAAM,UAAU,gBAAgB;AAEhC,aAAO,uBAAQ,MAAM,QAAQ,OAAO,CAAC,QAAQ,KAAK,CAAC;AACrD;;;ACRA,IAAAC,gBAAwB;AAYjB,IAAM,kBAAkB,CAI7B,gBACA,UACoB;AACpB,QAAM,QAAQ,SAAS;AAEvB,aAAO,uBAAQ,MAAM,eAAe,OAAO,KAAK,GAAG,CAAC,OAAO,KAAK,CAAC;AACnE;","names":["import_react","ThemeProvider","import_react","import_react","import_react","import_react","import_react","import_react","import_react"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -124,6 +124,7 @@ type NeutralColors = Record<NeutralColorKey, string>;
|
|
|
124
124
|
interface ThemeContextData {
|
|
125
125
|
loaded: boolean;
|
|
126
126
|
theme: AppTheme;
|
|
127
|
+
components?: DeepPartial<ComponentsThemes>;
|
|
127
128
|
}
|
|
128
129
|
type ColorScheme = "light" | "dark";
|
|
129
130
|
type ThemeColors = {
|
|
@@ -155,14 +156,20 @@ interface AppTheme {
|
|
|
155
156
|
spacing: Space;
|
|
156
157
|
radii: Radii;
|
|
157
158
|
borderSize: BorderSizes;
|
|
159
|
+
fontWeights: Record<"normal" | "italic", Record<FontWeightKey, string>>;
|
|
158
160
|
fontSize: FontSizes;
|
|
159
|
-
components?: DeepPartial<ComponentsThemes>;
|
|
160
161
|
}
|
|
162
|
+
type CustomComponentsTheme = ((theme: AppTheme) => DeepPartial<ComponentsThemes>) | DeepPartial<ComponentsThemes>;
|
|
163
|
+
|
|
164
|
+
declare const FontWeightsNormal: Record<FontWeightKey, FontWeightNormal>;
|
|
165
|
+
declare const FontWeightsItalic: Record<FontWeightKey, FontWeightItalic>;
|
|
161
166
|
|
|
162
167
|
declare function useBorder(): BorderSizes;
|
|
163
168
|
|
|
164
169
|
declare function useColors(): ThemeColors;
|
|
165
170
|
|
|
171
|
+
declare function useComponentsTheme(): DeepPartial<ComponentsThemes> | undefined;
|
|
172
|
+
|
|
166
173
|
declare function useRadii(): Radii;
|
|
167
174
|
|
|
168
175
|
declare function useSpace(): Space;
|
|
@@ -176,20 +183,27 @@ type StyledFunction<Props extends object, T extends StyleSheet.NamedStyles<T>> =
|
|
|
176
183
|
declare const useThemedStyles: <Props extends object, T extends StyleSheet.NamedStyles<T>>(styledFunction: StyledFunction<Props, T>, props: Props) => ThemedStyles<T>;
|
|
177
184
|
|
|
178
185
|
interface ThemeProviderProps {
|
|
179
|
-
scheme
|
|
180
|
-
theme
|
|
186
|
+
scheme?: ColorScheme;
|
|
187
|
+
theme?: DeepPartial<{
|
|
181
188
|
light: AppTheme;
|
|
182
189
|
dark: AppTheme;
|
|
183
|
-
}
|
|
190
|
+
}>;
|
|
191
|
+
components?: CustomComponentsTheme;
|
|
184
192
|
}
|
|
185
|
-
declare const ThemeProvider: react.NamedExoticComponent<PropsWithChildren<
|
|
193
|
+
declare const ThemeProvider: react.NamedExoticComponent<PropsWithChildren<ThemeProviderProps>>;
|
|
186
194
|
declare function useThemeContext(): ThemeContextData;
|
|
187
195
|
|
|
188
196
|
declare const DarkTheme: AppTheme;
|
|
189
197
|
|
|
190
198
|
declare const LightTheme: AppTheme;
|
|
191
199
|
|
|
200
|
+
declare const SpaceTokens: Space;
|
|
201
|
+
declare const BorderSizeTokens: BorderSizes;
|
|
202
|
+
declare const RadiiTokens: Radii;
|
|
203
|
+
declare const FontSizeTokens: FontSizes;
|
|
204
|
+
declare const NeutralColorTokens: NeutralColors;
|
|
205
|
+
|
|
192
206
|
declare const extractStyleProps: <Props extends object>(props: Props) => StyleProps;
|
|
193
207
|
declare const createStyleKey: <Props extends object>(props: Props) => string;
|
|
194
208
|
|
|
195
|
-
export { type AppTheme, type BorderProps, type BorderSizeKey, type BorderSizes, type ColorProps, type ColorScheme, type ComponentSize, type ComponentsThemes, DarkTheme, type DimensionProps, type ExtendedThemeColors, type FlexProps, type FontSizes, type FontSizesKeys, type FontWeightItalic, type FontWeightKey, type FontWeightNormal, type LetterSpacingKey, type LetterSpacings, LightTheme, type LineHeightKeys, type LineHeights, type NeutralColorKey, type NeutralColors, type Radii, type RadiiBlob, type RadiiConditional, type RadiiDrawn, type RadiusBlobKey, type RadiusConditionalKey, type RadiusDrawnKey, type RadiusKey, type ShadowProps, type Space, type SpaceSizesKeys, type SpacingProps, type StylePropKey, type StyleProps, StylePropsSet, type ThemeColors, type ThemeContextData, ThemeProvider, type TypographyPresetKey, type TypographyProps, createStyleKey, extractStyleProps, useBorder, useColors, useRadii, useSpace, useStyleProps, useTheme, useThemeContext, useThemedStyles };
|
|
209
|
+
export { type AppTheme, type BorderProps, type BorderSizeKey, BorderSizeTokens, type BorderSizes, type ColorProps, type ColorScheme, type ComponentSize, type ComponentsThemes, type CustomComponentsTheme, DarkTheme, type DimensionProps, type ExtendedThemeColors, type FlexProps, FontSizeTokens, type FontSizes, type FontSizesKeys, type FontWeightItalic, type FontWeightKey, type FontWeightNormal, FontWeightsItalic, FontWeightsNormal, type LetterSpacingKey, type LetterSpacings, LightTheme, type LineHeightKeys, type LineHeights, type NeutralColorKey, NeutralColorTokens, type NeutralColors, type Radii, type RadiiBlob, type RadiiConditional, type RadiiDrawn, RadiiTokens, type RadiusBlobKey, type RadiusConditionalKey, type RadiusDrawnKey, type RadiusKey, type ShadowProps, type Space, type SpaceSizesKeys, SpaceTokens, type SpacingProps, type StylePropKey, type StyleProps, StylePropsSet, type ThemeColors, type ThemeContextData, ThemeProvider, type TypographyPresetKey, type TypographyProps, createStyleKey, extractStyleProps, useBorder, useColors, useComponentsTheme, useRadii, useSpace, useStyleProps, useTheme, useThemeContext, useThemedStyles };
|
package/dist/index.d.ts
CHANGED
|
@@ -124,6 +124,7 @@ type NeutralColors = Record<NeutralColorKey, string>;
|
|
|
124
124
|
interface ThemeContextData {
|
|
125
125
|
loaded: boolean;
|
|
126
126
|
theme: AppTheme;
|
|
127
|
+
components?: DeepPartial<ComponentsThemes>;
|
|
127
128
|
}
|
|
128
129
|
type ColorScheme = "light" | "dark";
|
|
129
130
|
type ThemeColors = {
|
|
@@ -155,14 +156,20 @@ interface AppTheme {
|
|
|
155
156
|
spacing: Space;
|
|
156
157
|
radii: Radii;
|
|
157
158
|
borderSize: BorderSizes;
|
|
159
|
+
fontWeights: Record<"normal" | "italic", Record<FontWeightKey, string>>;
|
|
158
160
|
fontSize: FontSizes;
|
|
159
|
-
components?: DeepPartial<ComponentsThemes>;
|
|
160
161
|
}
|
|
162
|
+
type CustomComponentsTheme = ((theme: AppTheme) => DeepPartial<ComponentsThemes>) | DeepPartial<ComponentsThemes>;
|
|
163
|
+
|
|
164
|
+
declare const FontWeightsNormal: Record<FontWeightKey, FontWeightNormal>;
|
|
165
|
+
declare const FontWeightsItalic: Record<FontWeightKey, FontWeightItalic>;
|
|
161
166
|
|
|
162
167
|
declare function useBorder(): BorderSizes;
|
|
163
168
|
|
|
164
169
|
declare function useColors(): ThemeColors;
|
|
165
170
|
|
|
171
|
+
declare function useComponentsTheme(): DeepPartial<ComponentsThemes> | undefined;
|
|
172
|
+
|
|
166
173
|
declare function useRadii(): Radii;
|
|
167
174
|
|
|
168
175
|
declare function useSpace(): Space;
|
|
@@ -176,20 +183,27 @@ type StyledFunction<Props extends object, T extends StyleSheet.NamedStyles<T>> =
|
|
|
176
183
|
declare const useThemedStyles: <Props extends object, T extends StyleSheet.NamedStyles<T>>(styledFunction: StyledFunction<Props, T>, props: Props) => ThemedStyles<T>;
|
|
177
184
|
|
|
178
185
|
interface ThemeProviderProps {
|
|
179
|
-
scheme
|
|
180
|
-
theme
|
|
186
|
+
scheme?: ColorScheme;
|
|
187
|
+
theme?: DeepPartial<{
|
|
181
188
|
light: AppTheme;
|
|
182
189
|
dark: AppTheme;
|
|
183
|
-
}
|
|
190
|
+
}>;
|
|
191
|
+
components?: CustomComponentsTheme;
|
|
184
192
|
}
|
|
185
|
-
declare const ThemeProvider: react.NamedExoticComponent<PropsWithChildren<
|
|
193
|
+
declare const ThemeProvider: react.NamedExoticComponent<PropsWithChildren<ThemeProviderProps>>;
|
|
186
194
|
declare function useThemeContext(): ThemeContextData;
|
|
187
195
|
|
|
188
196
|
declare const DarkTheme: AppTheme;
|
|
189
197
|
|
|
190
198
|
declare const LightTheme: AppTheme;
|
|
191
199
|
|
|
200
|
+
declare const SpaceTokens: Space;
|
|
201
|
+
declare const BorderSizeTokens: BorderSizes;
|
|
202
|
+
declare const RadiiTokens: Radii;
|
|
203
|
+
declare const FontSizeTokens: FontSizes;
|
|
204
|
+
declare const NeutralColorTokens: NeutralColors;
|
|
205
|
+
|
|
192
206
|
declare const extractStyleProps: <Props extends object>(props: Props) => StyleProps;
|
|
193
207
|
declare const createStyleKey: <Props extends object>(props: Props) => string;
|
|
194
208
|
|
|
195
|
-
export { type AppTheme, type BorderProps, type BorderSizeKey, type BorderSizes, type ColorProps, type ColorScheme, type ComponentSize, type ComponentsThemes, DarkTheme, type DimensionProps, type ExtendedThemeColors, type FlexProps, type FontSizes, type FontSizesKeys, type FontWeightItalic, type FontWeightKey, type FontWeightNormal, type LetterSpacingKey, type LetterSpacings, LightTheme, type LineHeightKeys, type LineHeights, type NeutralColorKey, type NeutralColors, type Radii, type RadiiBlob, type RadiiConditional, type RadiiDrawn, type RadiusBlobKey, type RadiusConditionalKey, type RadiusDrawnKey, type RadiusKey, type ShadowProps, type Space, type SpaceSizesKeys, type SpacingProps, type StylePropKey, type StyleProps, StylePropsSet, type ThemeColors, type ThemeContextData, ThemeProvider, type TypographyPresetKey, type TypographyProps, createStyleKey, extractStyleProps, useBorder, useColors, useRadii, useSpace, useStyleProps, useTheme, useThemeContext, useThemedStyles };
|
|
209
|
+
export { type AppTheme, type BorderProps, type BorderSizeKey, BorderSizeTokens, type BorderSizes, type ColorProps, type ColorScheme, type ComponentSize, type ComponentsThemes, type CustomComponentsTheme, DarkTheme, type DimensionProps, type ExtendedThemeColors, type FlexProps, FontSizeTokens, type FontSizes, type FontSizesKeys, type FontWeightItalic, type FontWeightKey, type FontWeightNormal, FontWeightsItalic, FontWeightsNormal, type LetterSpacingKey, type LetterSpacings, LightTheme, type LineHeightKeys, type LineHeights, type NeutralColorKey, NeutralColorTokens, type NeutralColors, type Radii, type RadiiBlob, type RadiiConditional, type RadiiDrawn, RadiiTokens, type RadiusBlobKey, type RadiusConditionalKey, type RadiusDrawnKey, type RadiusKey, type ShadowProps, type Space, type SpaceSizesKeys, SpaceTokens, type SpacingProps, type StylePropKey, type StyleProps, StylePropsSet, type ThemeColors, type ThemeContextData, ThemeProvider, type TypographyPresetKey, type TypographyProps, createStyleKey, extractStyleProps, useBorder, useColors, useComponentsTheme, useRadii, useSpace, useStyleProps, useTheme, useThemeContext, useThemedStyles };
|
package/dist/index.esm.js
CHANGED
|
@@ -73,6 +73,30 @@ var StylePropsSet = /* @__PURE__ */ new Set([
|
|
|
73
73
|
"aspectRatio"
|
|
74
74
|
]);
|
|
75
75
|
|
|
76
|
+
// src/constants/typography.constants.ts
|
|
77
|
+
var FontWeightsNormal = {
|
|
78
|
+
100: "Montserrat_100Thin",
|
|
79
|
+
200: "Montserrat_200ExtraLight",
|
|
80
|
+
300: "Montserrat_300Light",
|
|
81
|
+
400: "Montserrat_400Regular",
|
|
82
|
+
500: "Montserrat_500Medium",
|
|
83
|
+
600: "Montserrat_600SemiBold",
|
|
84
|
+
700: "Montserrat_700Bold",
|
|
85
|
+
800: "Montserrat_800ExtraBold",
|
|
86
|
+
900: "Montserrat_900Black"
|
|
87
|
+
};
|
|
88
|
+
var FontWeightsItalic = {
|
|
89
|
+
100: "Montserrat_100Thin_Italic",
|
|
90
|
+
200: "Montserrat_200ExtraLight_Italic",
|
|
91
|
+
300: "Montserrat_300Light_Italic",
|
|
92
|
+
400: "Montserrat_400Regular_Italic",
|
|
93
|
+
500: "Montserrat_500Medium_Italic",
|
|
94
|
+
600: "Montserrat_600SemiBold_Italic",
|
|
95
|
+
700: "Montserrat_700Bold_Italic",
|
|
96
|
+
800: "Montserrat_800ExtraBold_Italic",
|
|
97
|
+
900: "Montserrat_900Black_Italic"
|
|
98
|
+
};
|
|
99
|
+
|
|
76
100
|
// src/hooks/use-border.hook.ts
|
|
77
101
|
import { useMemo as useMemo2 } from "react";
|
|
78
102
|
|
|
@@ -168,6 +192,10 @@ var DarkTheme = {
|
|
|
168
192
|
},
|
|
169
193
|
spacing: SpaceTokens,
|
|
170
194
|
radii: RadiiTokens,
|
|
195
|
+
fontWeights: {
|
|
196
|
+
normal: FontWeightsNormal,
|
|
197
|
+
italic: FontWeightsItalic
|
|
198
|
+
},
|
|
171
199
|
borderSize: BorderSizeTokens,
|
|
172
200
|
fontSize: FontSizeTokens
|
|
173
201
|
};
|
|
@@ -195,6 +223,10 @@ var LightTheme = {
|
|
|
195
223
|
},
|
|
196
224
|
spacing: SpaceTokens,
|
|
197
225
|
radii: RadiiTokens,
|
|
226
|
+
fontWeights: {
|
|
227
|
+
normal: FontWeightsNormal,
|
|
228
|
+
italic: FontWeightsItalic
|
|
229
|
+
},
|
|
198
230
|
borderSize: BorderSizeTokens,
|
|
199
231
|
fontSize: FontSizeTokens
|
|
200
232
|
};
|
|
@@ -246,11 +278,20 @@ var ThemeProvider = memo(function ThemeProvider2(props) {
|
|
|
246
278
|
});
|
|
247
279
|
const context = useMemo(() => {
|
|
248
280
|
const baseTheme = scheme === "light" ? LightTheme : DarkTheme;
|
|
281
|
+
const customBaseTheme = props.theme?.[scheme];
|
|
282
|
+
const theme = merge(baseTheme, customBaseTheme);
|
|
283
|
+
let componentsTheme;
|
|
284
|
+
if (typeof props.components === "function") {
|
|
285
|
+
componentsTheme = props.components(theme);
|
|
286
|
+
} else {
|
|
287
|
+
componentsTheme = props.components;
|
|
288
|
+
}
|
|
249
289
|
return {
|
|
250
290
|
loaded,
|
|
251
|
-
theme
|
|
291
|
+
theme,
|
|
292
|
+
components: componentsTheme
|
|
252
293
|
};
|
|
253
|
-
}, [props.theme?.light, props.theme?.dark]);
|
|
294
|
+
}, [props.theme?.light, props.theme?.dark, props.components]);
|
|
254
295
|
return /* @__PURE__ */ React.createElement(ThemeContext.Provider, { value: context }, props.children);
|
|
255
296
|
});
|
|
256
297
|
function useThemeContext() {
|
|
@@ -274,22 +315,29 @@ function useColors() {
|
|
|
274
315
|
return useMemo3(() => context.theme.colors, [context.theme.colors]);
|
|
275
316
|
}
|
|
276
317
|
|
|
277
|
-
// src/hooks/use-
|
|
318
|
+
// src/hooks/use-components-theme.hook.ts
|
|
278
319
|
import { useMemo as useMemo4 } from "react";
|
|
320
|
+
function useComponentsTheme() {
|
|
321
|
+
const context = useThemeContext();
|
|
322
|
+
return useMemo4(() => context.components, [context.components]);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/hooks/use-radii.hook.ts
|
|
326
|
+
import { useMemo as useMemo5 } from "react";
|
|
279
327
|
function useRadii() {
|
|
280
328
|
const context = useThemeContext();
|
|
281
|
-
return
|
|
329
|
+
return useMemo5(() => context.theme.radii, [context.theme.radii]);
|
|
282
330
|
}
|
|
283
331
|
|
|
284
332
|
// src/hooks/use-space.hook.ts
|
|
285
|
-
import { useMemo as
|
|
333
|
+
import { useMemo as useMemo6 } from "react";
|
|
286
334
|
function useSpace() {
|
|
287
335
|
const context = useThemeContext();
|
|
288
|
-
return
|
|
336
|
+
return useMemo6(() => context.theme.spacing, [context.theme.spacing]);
|
|
289
337
|
}
|
|
290
338
|
|
|
291
339
|
// src/hooks/use-style-props.hook.ts
|
|
292
|
-
import { useMemo as
|
|
340
|
+
import { useMemo as useMemo7 } from "react";
|
|
293
341
|
|
|
294
342
|
// src/utils/style.utils.ts
|
|
295
343
|
var isStylePropKey = (k) => StylePropsSet.has(k);
|
|
@@ -315,31 +363,39 @@ var createStyleKey = (props) => {
|
|
|
315
363
|
// src/hooks/use-style-props.hook.ts
|
|
316
364
|
function useStyleProps(props) {
|
|
317
365
|
const key = createStyleKey(props);
|
|
318
|
-
return
|
|
366
|
+
return useMemo7(() => extractStyleProps(props), [key]);
|
|
319
367
|
}
|
|
320
368
|
|
|
321
369
|
// src/hooks/use-theme.hook.ts
|
|
322
|
-
import { useMemo as
|
|
370
|
+
import { useMemo as useMemo8 } from "react";
|
|
323
371
|
function useTheme() {
|
|
324
372
|
const context = useThemeContext();
|
|
325
|
-
return
|
|
373
|
+
return useMemo8(() => context.theme, [context.theme]);
|
|
326
374
|
}
|
|
327
375
|
|
|
328
376
|
// src/hooks/use-themed-styles.ts
|
|
329
|
-
import { useMemo as
|
|
377
|
+
import { useMemo as useMemo9 } from "react";
|
|
330
378
|
var useThemedStyles = (styledFunction, props) => {
|
|
331
379
|
const theme = useTheme();
|
|
332
|
-
return
|
|
380
|
+
return useMemo9(() => styledFunction(theme, props), [theme, props]);
|
|
333
381
|
};
|
|
334
382
|
export {
|
|
383
|
+
BorderSizeTokens,
|
|
335
384
|
DarkTheme,
|
|
385
|
+
FontSizeTokens,
|
|
386
|
+
FontWeightsItalic,
|
|
387
|
+
FontWeightsNormal,
|
|
336
388
|
LightTheme,
|
|
389
|
+
NeutralColorTokens,
|
|
390
|
+
RadiiTokens,
|
|
391
|
+
SpaceTokens,
|
|
337
392
|
StylePropsSet,
|
|
338
393
|
ThemeProvider,
|
|
339
394
|
createStyleKey,
|
|
340
395
|
extractStyleProps,
|
|
341
396
|
useBorder,
|
|
342
397
|
useColors,
|
|
398
|
+
useComponentsTheme,
|
|
343
399
|
useRadii,
|
|
344
400
|
useSpace,
|
|
345
401
|
useStyleProps,
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants/style.constants.ts","../src/hooks/use-border.hook.ts","../src/providers/theme.provider.tsx","../src/theme/tokens.theme.ts","../src/theme/dark.theme.ts","../src/theme/light.theme.ts","../src/hooks/use-colors.hook.ts","../src/hooks/use-radii.hook.ts","../src/hooks/use-space.hook.ts","../src/hooks/use-style-props.hook.ts","../src/utils/style.utils.ts","../src/hooks/use-theme.hook.ts","../src/hooks/use-themed-styles.ts"],"sourcesContent":["import { StyleProps } from \"../types\";\r\n\r\nexport const StylePropsSet = new Set<keyof StyleProps>([\r\n // Spacing\r\n \"margin\",\r\n \"marginTop\",\r\n \"marginBottom\",\r\n \"marginLeft\",\r\n \"marginRight\",\r\n \"marginHorizontal\",\r\n \"marginVertical\",\r\n \"padding\",\r\n \"paddingTop\",\r\n \"paddingBottom\",\r\n \"paddingLeft\",\r\n \"paddingRight\",\r\n \"paddingHorizontal\",\r\n \"paddingVertical\",\r\n\r\n // Appearance\r\n \"color\",\r\n \"backgroundColor\",\r\n \"opacity\",\r\n \"borderRadius\",\r\n \"borderColor\",\r\n \"borderWidth\",\r\n \"borderStyle\",\r\n \"shadowColor\",\r\n \"shadowOpacity\",\r\n \"shadowRadius\",\r\n \"shadowOffset\",\r\n \"elevation\",\r\n\r\n // Typography (TextStyle)\r\n \"fontSize\",\r\n \"fontFamily\",\r\n \"fontWeight\",\r\n \"fontStyle\",\r\n \"letterSpacing\",\r\n \"lineHeight\",\r\n \"textAlign\",\r\n \"textDecorationLine\",\r\n \"textDecorationStyle\",\r\n \"textDecorationColor\",\r\n \"textTransform\",\r\n \"includeFontPadding\",\r\n \"textAlignVertical\",\r\n \"writingDirection\",\r\n\r\n // Flex (ViewStyle)\r\n \"flex\",\r\n \"flexGrow\",\r\n \"flexShrink\",\r\n \"flexBasis\",\r\n \"flexDirection\",\r\n \"flexWrap\",\r\n \"justifyContent\",\r\n \"alignItems\",\r\n \"alignSelf\",\r\n \"alignContent\",\r\n \"gap\",\r\n \"rowGap\",\r\n \"columnGap\",\r\n\r\n // Positioning (commonly used with flex layouts)\r\n \"position\",\r\n \"top\",\r\n \"right\",\r\n \"bottom\",\r\n \"left\",\r\n\r\n // Dimensions (ViewStyle)\r\n \"width\",\r\n \"height\",\r\n \"minWidth\",\r\n \"maxWidth\",\r\n \"minHeight\",\r\n \"maxHeight\",\r\n \"aspectRatio\",\r\n]);\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { BorderSizes } from \"../types\";\r\n\r\nexport function useBorder(): BorderSizes {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.borderSize, [context.theme.borderSize]);\r\n}\r\n","import { DeepPartial, merge } from \"@impulse-ui-native/core\";\r\nimport {\r\n createContext,\r\n memo,\r\n PropsWithChildren,\r\n useContext,\r\n useMemo,\r\n} from \"react\";\r\nimport { DarkTheme, LightTheme } from \"../theme\";\r\nimport { AppTheme, ColorScheme, ThemeContextData } from \"../types\";\r\n\r\nimport {\r\n Montserrat_100Thin,\r\n Montserrat_100Thin_Italic,\r\n Montserrat_200ExtraLight,\r\n Montserrat_200ExtraLight_Italic,\r\n Montserrat_300Light,\r\n Montserrat_300Light_Italic,\r\n Montserrat_400Regular,\r\n Montserrat_400Regular_Italic,\r\n Montserrat_500Medium,\r\n Montserrat_500Medium_Italic,\r\n Montserrat_600SemiBold,\r\n Montserrat_600SemiBold_Italic,\r\n Montserrat_700Bold,\r\n Montserrat_700Bold_Italic,\r\n Montserrat_800ExtraBold,\r\n Montserrat_800ExtraBold_Italic,\r\n Montserrat_900Black,\r\n Montserrat_900Black_Italic,\r\n useFonts,\r\n} from \"@expo-google-fonts/montserrat\";\r\n\r\nconst ThemeContext = createContext<ThemeContextData | undefined>(undefined);\r\n\r\ninterface ThemeProviderProps {\r\n scheme: ColorScheme;\r\n theme: {\r\n light: AppTheme;\r\n dark: AppTheme;\r\n };\r\n}\r\n\r\nexport const ThemeProvider = memo(function ThemeProvider(\r\n props: PropsWithChildren<DeepPartial<ThemeProviderProps>>\r\n) {\r\n const scheme = props.scheme ?? \"light\";\r\n\r\n const [loaded] = useFonts({\r\n Montserrat_100Thin,\r\n Montserrat_100Thin_Italic,\r\n Montserrat_200ExtraLight,\r\n Montserrat_200ExtraLight_Italic,\r\n Montserrat_300Light,\r\n Montserrat_300Light_Italic,\r\n Montserrat_400Regular,\r\n Montserrat_400Regular_Italic,\r\n Montserrat_500Medium,\r\n Montserrat_500Medium_Italic,\r\n Montserrat_600SemiBold,\r\n Montserrat_600SemiBold_Italic,\r\n Montserrat_700Bold,\r\n Montserrat_700Bold_Italic,\r\n Montserrat_800ExtraBold,\r\n Montserrat_800ExtraBold_Italic,\r\n Montserrat_900Black,\r\n Montserrat_900Black_Italic,\r\n });\r\n\r\n const context = useMemo<ThemeContextData>(() => {\r\n const baseTheme = scheme === \"light\" ? LightTheme : DarkTheme;\r\n\r\n return {\r\n loaded,\r\n theme: merge(baseTheme, props.theme?.[scheme]),\r\n };\r\n }, [props.theme?.light, props.theme?.dark]);\r\n\r\n return (\r\n <ThemeContext.Provider value={context}>\r\n {props.children}\r\n </ThemeContext.Provider>\r\n );\r\n});\r\n\r\nexport function useThemeContext() {\r\n const context = useContext(ThemeContext);\r\n\r\n if (!context) {\r\n throw new Error(\"useThemeContext must be used within a ThemeProvider\");\r\n }\r\n\r\n return context;\r\n}\r\n","import { BorderSizes, FontSizes, NeutralColors, Radii, Space } from \"../types\";\r\n\r\nexport const SpaceTokens: Space = {\r\n none: 0,\r\n auto: \"auto\",\r\n xxs: 4,\r\n xs: 8,\r\n mxs: 12,\r\n sm: 16,\r\n msm: 24,\r\n md: 32,\r\n lg: 48,\r\n xl: 64,\r\n xxl: 96,\r\n};\r\n\r\nexport const BorderSizeTokens: BorderSizes = {\r\n sm: 1,\r\n md: 2,\r\n lg: 3,\r\n xl: 5,\r\n xxl: 10,\r\n};\r\n\r\nexport const RadiiTokens: Radii = {\r\n sm: 4,\r\n md: 8,\r\n lg: 16,\r\n xl: 32,\r\n xxl: 64,\r\n xxxl: 128,\r\n round: 100000,\r\n};\r\n\r\nexport const FontSizeTokens: FontSizes = {\r\n xxs: 8,\r\n xs: 12,\r\n xsm: 14,\r\n sm: 16,\r\n md: 18,\r\n lg: 20,\r\n xl: 24,\r\n xxl: 32,\r\n xxxl: 40,\r\n huge: 48,\r\n massive: 56,\r\n};\r\n\r\nexport const NeutralColorTokens: NeutralColors = {\r\n \"0\": \"#ffffff\",\r\n \"1\": \"#f8f9fa\",\r\n \"2\": \"#f1f3f5\",\r\n \"3\": \"#e9ecef\",\r\n \"4\": \"#dee2e6\",\r\n \"5\": \"#ced4da\",\r\n \"6\": \"#adb5bd\",\r\n \"7\": \"#868e96\",\r\n \"8\": \"#495057\",\r\n \"9\": \"#343a40\",\r\n \"10\": \"#212529\",\r\n \"11\": \"#16191d\",\r\n \"12\": \"#0d0f12\",\r\n \"13\": \"#000000\",\r\n};\r\n","import { AppTheme } from \"../types\";\r\nimport {\r\n BorderSizeTokens,\r\n FontSizeTokens,\r\n NeutralColorTokens,\r\n RadiiTokens,\r\n SpaceTokens,\r\n} from \"./tokens.theme\";\r\n\r\nexport const DarkTheme: AppTheme = {\r\n colors: {\r\n primary: \"#f55d6b\",\r\n secondary: \"#f55d6b\",\r\n neutral: NeutralColorTokens,\r\n white: NeutralColorTokens[\"0\"],\r\n black: NeutralColorTokens[\"13\"],\r\n error: \"#c92a2a\",\r\n warning: \"#e67700\",\r\n success: \"#7a9908\",\r\n info: \"#1864ab\",\r\n text: {\r\n primary: NeutralColorTokens[\"11\"],\r\n secondary: NeutralColorTokens[\"10\"],\r\n },\r\n background: {\r\n primary: NeutralColorTokens[\"2\"],\r\n secondary: NeutralColorTokens[\"0\"],\r\n },\r\n },\r\n spacing: SpaceTokens,\r\n radii: RadiiTokens,\r\n borderSize: BorderSizeTokens,\r\n fontSize: FontSizeTokens,\r\n};\r\n","import { AppTheme } from \"../types\";\r\nimport {\r\n BorderSizeTokens,\r\n FontSizeTokens,\r\n NeutralColorTokens,\r\n RadiiTokens,\r\n SpaceTokens,\r\n} from \"./tokens.theme\";\r\n\r\nexport const LightTheme: AppTheme = {\r\n colors: {\r\n primary: \"#f55d6b\",\r\n secondary: \"#f55d6b\",\r\n neutral: NeutralColorTokens,\r\n white: NeutralColorTokens[\"0\"],\r\n black: NeutralColorTokens[\"13\"],\r\n error: \"#c92a2a\",\r\n warning: \"#e67700\",\r\n success: \"#7a9908\",\r\n info: \"#1864ab\",\r\n text: {\r\n primary: NeutralColorTokens[\"11\"],\r\n secondary: NeutralColorTokens[\"10\"],\r\n },\r\n background: {\r\n primary: NeutralColorTokens[\"2\"],\r\n secondary: NeutralColorTokens[\"0\"],\r\n },\r\n },\r\n spacing: SpaceTokens,\r\n radii: RadiiTokens,\r\n borderSize: BorderSizeTokens,\r\n fontSize: FontSizeTokens,\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { ThemeColors } from \"../types\";\r\n\r\nexport function useColors(): ThemeColors {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.colors, [context.theme.colors]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { Radii } from \"../types\";\r\n\r\nexport function useRadii(): Radii {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.radii, [context.theme.radii]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { Space } from \"../types\";\r\n\r\nexport function useSpace(): Space {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.spacing, [context.theme.spacing]);\r\n}\r\n","import { useMemo } from 'react';\r\nimport { createStyleKey, extractStyleProps } from '../utils';\r\n\r\nexport function useStyleProps<Props extends object>(props: Props) {\r\n const key = createStyleKey(props);\r\n\r\n return useMemo(() => extractStyleProps(props), [key]);\r\n}\r\n","import { StylePropsSet } from '../constants';\r\nimport { StylePropKey, StyleProps } from '../types';\r\n\r\nconst isStylePropKey = (k: string): k is StylePropKey =>\r\n StylePropsSet.has(k as StylePropKey);\r\n\r\nexport const extractStyleProps = <Props extends object>(\r\n props: Props\r\n): StyleProps => {\r\n const style: StyleProps = {};\r\n \r\n for (const k in props) {\r\n if (isStylePropKey(k) && props[k] !== undefined) {\r\n style[k] = props[k] as any;\r\n }\r\n }\r\n \r\n return style;\r\n};\r\n\r\nexport const createStyleKey = <Props extends object>(props: Props) => {\r\n let key = '';\r\n\r\n for (const k in props) {\r\n if (isStylePropKey(k)) {\r\n key += String(props[k as keyof Props]);\r\n }\r\n }\r\n \r\n return key;\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { AppTheme } from \"../types\";\r\n\r\nexport function useTheme(): AppTheme {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme, [context.theme]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { StyleSheet } from \"react-native\";\r\nimport { AppTheme } from \"../types\";\r\nimport { useTheme } from \"./use-theme.hook\";\r\n\r\ntype ThemedStyles<T extends StyleSheet.NamedStyles<T>> = T;\r\n\r\ntype StyledFunction<\r\n Props extends object,\r\n T extends StyleSheet.NamedStyles<T>\r\n> = (theme: AppTheme, props: Props) => ThemedStyles<T>;\r\n\r\nexport const useThemedStyles = <\r\n Props extends object,\r\n T extends StyleSheet.NamedStyles<T>\r\n>(\r\n styledFunction: StyledFunction<Props, T>,\r\n props: Props\r\n): ThemedStyles<T> => {\r\n const theme = useTheme();\r\n\r\n return useMemo(() => styledFunction(theme, props), [theme, props]);\r\n};\r\n"],"mappings":";AAEO,IAAM,gBAAgB,oBAAI,IAAsB;AAAA;AAAA,EAErD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;;;AC/ED,SAAS,WAAAA,gBAAe;;;ACAxB,SAAsB,aAAa;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;;;ACLA,IAAM,cAAqB;AAAA,EAChC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,KAAK;AACP;AAEO,IAAM,mBAAgC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ACpE,MAAI,MAAM;AAEV,aAAW,KAAK,OAAO;AACrB,QAAI,eAAe,CAAC,GAAG;AACrB,aAAO,OAAO,MAAM,CAAgB,CAAC;AAAA,IACvC;AAAA,EACF;AAEA,SAAO;AACT;;;AD3BO,SAAS,cAAoC,OAAc;AAChE,QAAM,MAAM,eAAe,KAAK;AAEhC,SAAOC,SAAQ,MAAM,kBAAkB,KAAK,GAAG,CAAC,GAAG,CAAC;AACtD;;;AEPA,SAAS,WAAAC,gBAAe;AAIjB,SAAS,WAAqB;AACnC,QAAM,UAAU,gBAAgB;AAEhC,SAAOC,SAAQ,MAAM,QAAQ,OAAO,CAAC,QAAQ,KAAK,CAAC;AACrD;;;ACRA,SAAS,WAAAC,gBAAe;AAYjB,IAAM,kBAAkB,CAI7B,gBACA,UACoB;AACpB,QAAM,QAAQ,SAAS;AAEvB,SAAOC,SAAQ,MAAM,eAAe,OAAO,KAAK,GAAG,CAAC,OAAO,KAAK,CAAC;AACnE;","names":["useMemo","ThemeProvider","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo"]}
|
|
1
|
+
{"version":3,"sources":["../src/constants/style.constants.ts","../src/constants/typography.constants.ts","../src/hooks/use-border.hook.ts","../src/providers/theme.provider.tsx","../src/theme/tokens.theme.ts","../src/theme/dark.theme.ts","../src/theme/light.theme.ts","../src/hooks/use-colors.hook.ts","../src/hooks/use-components-theme.hook.ts","../src/hooks/use-radii.hook.ts","../src/hooks/use-space.hook.ts","../src/hooks/use-style-props.hook.ts","../src/utils/style.utils.ts","../src/hooks/use-theme.hook.ts","../src/hooks/use-themed-styles.ts"],"sourcesContent":["import { StyleProps } from \"../types\";\r\n\r\nexport const StylePropsSet = new Set<keyof StyleProps>([\r\n // Spacing\r\n \"margin\",\r\n \"marginTop\",\r\n \"marginBottom\",\r\n \"marginLeft\",\r\n \"marginRight\",\r\n \"marginHorizontal\",\r\n \"marginVertical\",\r\n \"padding\",\r\n \"paddingTop\",\r\n \"paddingBottom\",\r\n \"paddingLeft\",\r\n \"paddingRight\",\r\n \"paddingHorizontal\",\r\n \"paddingVertical\",\r\n\r\n // Appearance\r\n \"color\",\r\n \"backgroundColor\",\r\n \"opacity\",\r\n \"borderRadius\",\r\n \"borderColor\",\r\n \"borderWidth\",\r\n \"borderStyle\",\r\n \"shadowColor\",\r\n \"shadowOpacity\",\r\n \"shadowRadius\",\r\n \"shadowOffset\",\r\n \"elevation\",\r\n\r\n // Typography (TextStyle)\r\n \"fontSize\",\r\n \"fontFamily\",\r\n \"fontWeight\",\r\n \"fontStyle\",\r\n \"letterSpacing\",\r\n \"lineHeight\",\r\n \"textAlign\",\r\n \"textDecorationLine\",\r\n \"textDecorationStyle\",\r\n \"textDecorationColor\",\r\n \"textTransform\",\r\n \"includeFontPadding\",\r\n \"textAlignVertical\",\r\n \"writingDirection\",\r\n\r\n // Flex (ViewStyle)\r\n \"flex\",\r\n \"flexGrow\",\r\n \"flexShrink\",\r\n \"flexBasis\",\r\n \"flexDirection\",\r\n \"flexWrap\",\r\n \"justifyContent\",\r\n \"alignItems\",\r\n \"alignSelf\",\r\n \"alignContent\",\r\n \"gap\",\r\n \"rowGap\",\r\n \"columnGap\",\r\n\r\n // Positioning (commonly used with flex layouts)\r\n \"position\",\r\n \"top\",\r\n \"right\",\r\n \"bottom\",\r\n \"left\",\r\n\r\n // Dimensions (ViewStyle)\r\n \"width\",\r\n \"height\",\r\n \"minWidth\",\r\n \"maxWidth\",\r\n \"minHeight\",\r\n \"maxHeight\",\r\n \"aspectRatio\",\r\n]);\r\n","import { FontWeightItalic, FontWeightKey, FontWeightNormal } from \"../types\";\r\n\r\nexport const FontWeightsNormal: Record<FontWeightKey, FontWeightNormal> = {\r\n 100: \"Montserrat_100Thin\",\r\n 200: \"Montserrat_200ExtraLight\",\r\n 300: \"Montserrat_300Light\",\r\n 400: \"Montserrat_400Regular\",\r\n 500: \"Montserrat_500Medium\",\r\n 600: \"Montserrat_600SemiBold\",\r\n 700: \"Montserrat_700Bold\",\r\n 800: \"Montserrat_800ExtraBold\",\r\n 900: \"Montserrat_900Black\",\r\n};\r\n\r\nexport const FontWeightsItalic: Record<FontWeightKey, FontWeightItalic> = {\r\n 100: \"Montserrat_100Thin_Italic\",\r\n 200: \"Montserrat_200ExtraLight_Italic\",\r\n 300: \"Montserrat_300Light_Italic\",\r\n 400: \"Montserrat_400Regular_Italic\",\r\n 500: \"Montserrat_500Medium_Italic\",\r\n 600: \"Montserrat_600SemiBold_Italic\",\r\n 700: \"Montserrat_700Bold_Italic\",\r\n 800: \"Montserrat_800ExtraBold_Italic\",\r\n 900: \"Montserrat_900Black_Italic\",\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { BorderSizes } from \"../types\";\r\n\r\nexport function useBorder(): BorderSizes {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.borderSize, [context.theme.borderSize]);\r\n}\r\n","import { DeepPartial, merge } from \"@impulse-ui-native/core\";\r\nimport {\r\n createContext,\r\n memo,\r\n PropsWithChildren,\r\n useContext,\r\n useMemo,\r\n} from \"react\";\r\nimport { DarkTheme, LightTheme } from \"../theme\";\r\nimport {\r\n AppTheme,\r\n ColorScheme,\r\n ComponentsThemes,\r\n CustomComponentsTheme,\r\n ThemeContextData,\r\n} from \"../types\";\r\n\r\nimport {\r\n Montserrat_100Thin,\r\n Montserrat_100Thin_Italic,\r\n Montserrat_200ExtraLight,\r\n Montserrat_200ExtraLight_Italic,\r\n Montserrat_300Light,\r\n Montserrat_300Light_Italic,\r\n Montserrat_400Regular,\r\n Montserrat_400Regular_Italic,\r\n Montserrat_500Medium,\r\n Montserrat_500Medium_Italic,\r\n Montserrat_600SemiBold,\r\n Montserrat_600SemiBold_Italic,\r\n Montserrat_700Bold,\r\n Montserrat_700Bold_Italic,\r\n Montserrat_800ExtraBold,\r\n Montserrat_800ExtraBold_Italic,\r\n Montserrat_900Black,\r\n Montserrat_900Black_Italic,\r\n useFonts,\r\n} from \"@expo-google-fonts/montserrat\";\r\n\r\nconst ThemeContext = createContext<ThemeContextData | undefined>(undefined);\r\n\r\ninterface ThemeProviderProps {\r\n scheme?: ColorScheme;\r\n theme?: DeepPartial<{\r\n light: AppTheme;\r\n dark: AppTheme;\r\n }>;\r\n components?: CustomComponentsTheme;\r\n}\r\n\r\nexport const ThemeProvider = memo(function ThemeProvider(\r\n props: PropsWithChildren<ThemeProviderProps>\r\n) {\r\n const scheme = props.scheme ?? \"light\";\r\n\r\n const [loaded] = useFonts({\r\n Montserrat_100Thin,\r\n Montserrat_100Thin_Italic,\r\n Montserrat_200ExtraLight,\r\n Montserrat_200ExtraLight_Italic,\r\n Montserrat_300Light,\r\n Montserrat_300Light_Italic,\r\n Montserrat_400Regular,\r\n Montserrat_400Regular_Italic,\r\n Montserrat_500Medium,\r\n Montserrat_500Medium_Italic,\r\n Montserrat_600SemiBold,\r\n Montserrat_600SemiBold_Italic,\r\n Montserrat_700Bold,\r\n Montserrat_700Bold_Italic,\r\n Montserrat_800ExtraBold,\r\n Montserrat_800ExtraBold_Italic,\r\n Montserrat_900Black,\r\n Montserrat_900Black_Italic,\r\n });\r\n\r\n const context = useMemo<ThemeContextData>(() => {\r\n const baseTheme = scheme === \"light\" ? LightTheme : DarkTheme;\r\n const customBaseTheme = props.theme?.[scheme];\r\n const theme = merge(baseTheme, customBaseTheme);\r\n\r\n let componentsTheme: DeepPartial<ComponentsThemes> | undefined;\r\n\r\n if (typeof props.components === \"function\") {\r\n componentsTheme = props.components(theme);\r\n } else {\r\n componentsTheme = props.components;\r\n }\r\n\r\n return {\r\n loaded,\r\n theme,\r\n components: componentsTheme,\r\n };\r\n }, [props.theme?.light, props.theme?.dark, props.components]);\r\n\r\n return (\r\n <ThemeContext.Provider value={context}>\r\n {props.children}\r\n </ThemeContext.Provider>\r\n );\r\n});\r\n\r\nexport function useThemeContext() {\r\n const context = useContext(ThemeContext);\r\n\r\n if (!context) {\r\n throw new Error(\"useThemeContext must be used within a ThemeProvider\");\r\n }\r\n\r\n return context;\r\n}\r\n","import { BorderSizes, FontSizes, NeutralColors, Radii, Space } from \"../types\";\r\n\r\nexport const SpaceTokens: Space = {\r\n none: 0,\r\n auto: \"auto\",\r\n xxs: 4,\r\n xs: 8,\r\n mxs: 12,\r\n sm: 16,\r\n msm: 24,\r\n md: 32,\r\n lg: 48,\r\n xl: 64,\r\n xxl: 96,\r\n};\r\n\r\nexport const BorderSizeTokens: BorderSizes = {\r\n sm: 1,\r\n md: 2,\r\n lg: 3,\r\n xl: 5,\r\n xxl: 10,\r\n};\r\n\r\nexport const RadiiTokens: Radii = {\r\n sm: 4,\r\n md: 8,\r\n lg: 16,\r\n xl: 32,\r\n xxl: 64,\r\n xxxl: 128,\r\n round: 100000,\r\n};\r\n\r\nexport const FontSizeTokens: FontSizes = {\r\n xxs: 8,\r\n xs: 12,\r\n xsm: 14,\r\n sm: 16,\r\n md: 18,\r\n lg: 20,\r\n xl: 24,\r\n xxl: 32,\r\n xxxl: 40,\r\n huge: 48,\r\n massive: 56,\r\n};\r\n\r\nexport const NeutralColorTokens: NeutralColors = {\r\n \"0\": \"#ffffff\",\r\n \"1\": \"#f8f9fa\",\r\n \"2\": \"#f1f3f5\",\r\n \"3\": \"#e9ecef\",\r\n \"4\": \"#dee2e6\",\r\n \"5\": \"#ced4da\",\r\n \"6\": \"#adb5bd\",\r\n \"7\": \"#868e96\",\r\n \"8\": \"#495057\",\r\n \"9\": \"#343a40\",\r\n \"10\": \"#212529\",\r\n \"11\": \"#16191d\",\r\n \"12\": \"#0d0f12\",\r\n \"13\": \"#000000\",\r\n};\r\n","import { FontWeightsItalic, FontWeightsNormal } from \"../constants\";\r\nimport { AppTheme } from \"../types\";\r\nimport {\r\n BorderSizeTokens,\r\n FontSizeTokens,\r\n NeutralColorTokens,\r\n RadiiTokens,\r\n SpaceTokens,\r\n} from \"./tokens.theme\";\r\n\r\nexport const DarkTheme: AppTheme = {\r\n colors: {\r\n primary: \"#f55d6b\",\r\n secondary: \"#f55d6b\",\r\n neutral: NeutralColorTokens,\r\n white: NeutralColorTokens[\"0\"],\r\n black: NeutralColorTokens[\"13\"],\r\n error: \"#c92a2a\",\r\n warning: \"#e67700\",\r\n success: \"#7a9908\",\r\n info: \"#1864ab\",\r\n text: {\r\n primary: NeutralColorTokens[\"11\"],\r\n secondary: NeutralColorTokens[\"10\"],\r\n },\r\n background: {\r\n primary: NeutralColorTokens[\"2\"],\r\n secondary: NeutralColorTokens[\"0\"],\r\n },\r\n },\r\n spacing: SpaceTokens,\r\n radii: RadiiTokens,\r\n fontWeights: {\r\n normal: FontWeightsNormal,\r\n italic: FontWeightsItalic,\r\n },\r\n borderSize: BorderSizeTokens,\r\n fontSize: FontSizeTokens,\r\n};\r\n","import { FontWeightsItalic, FontWeightsNormal } from \"../constants\";\r\nimport { AppTheme } from \"../types\";\r\nimport {\r\n BorderSizeTokens,\r\n FontSizeTokens,\r\n NeutralColorTokens,\r\n RadiiTokens,\r\n SpaceTokens,\r\n} from \"./tokens.theme\";\r\n\r\nexport const LightTheme: AppTheme = {\r\n colors: {\r\n primary: \"#f55d6b\",\r\n secondary: \"#f55d6b\",\r\n neutral: NeutralColorTokens,\r\n white: NeutralColorTokens[\"0\"],\r\n black: NeutralColorTokens[\"13\"],\r\n error: \"#c92a2a\",\r\n warning: \"#e67700\",\r\n success: \"#7a9908\",\r\n info: \"#1864ab\",\r\n text: {\r\n primary: NeutralColorTokens[\"11\"],\r\n secondary: NeutralColorTokens[\"10\"],\r\n },\r\n background: {\r\n primary: NeutralColorTokens[\"2\"],\r\n secondary: NeutralColorTokens[\"0\"],\r\n },\r\n },\r\n spacing: SpaceTokens,\r\n radii: RadiiTokens,\r\n fontWeights: {\r\n normal: FontWeightsNormal,\r\n italic: FontWeightsItalic,\r\n },\r\n borderSize: BorderSizeTokens,\r\n fontSize: FontSizeTokens,\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { ThemeColors } from \"../types\";\r\n\r\nexport function useColors(): ThemeColors {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.colors, [context.theme.colors]);\r\n}\r\n","import { DeepPartial } from \"@impulse-ui-native/core\";\r\nimport { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { ComponentsThemes } from \"../types\";\r\n\r\nexport function useComponentsTheme():\r\n | DeepPartial<ComponentsThemes>\r\n | undefined {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.components, [context.components]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { Radii } from \"../types\";\r\n\r\nexport function useRadii(): Radii {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.radii, [context.theme.radii]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { Space } from \"../types\";\r\n\r\nexport function useSpace(): Space {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme.spacing, [context.theme.spacing]);\r\n}\r\n","import { useMemo } from 'react';\r\nimport { createStyleKey, extractStyleProps } from '../utils';\r\n\r\nexport function useStyleProps<Props extends object>(props: Props) {\r\n const key = createStyleKey(props);\r\n\r\n return useMemo(() => extractStyleProps(props), [key]);\r\n}\r\n","import { StylePropsSet } from '../constants';\r\nimport { StylePropKey, StyleProps } from '../types';\r\n\r\nconst isStylePropKey = (k: string): k is StylePropKey =>\r\n StylePropsSet.has(k as StylePropKey);\r\n\r\nexport const extractStyleProps = <Props extends object>(\r\n props: Props\r\n): StyleProps => {\r\n const style: StyleProps = {};\r\n \r\n for (const k in props) {\r\n if (isStylePropKey(k) && props[k] !== undefined) {\r\n style[k] = props[k] as any;\r\n }\r\n }\r\n \r\n return style;\r\n};\r\n\r\nexport const createStyleKey = <Props extends object>(props: Props) => {\r\n let key = '';\r\n\r\n for (const k in props) {\r\n if (isStylePropKey(k)) {\r\n key += String(props[k as keyof Props]);\r\n }\r\n }\r\n \r\n return key;\r\n};\r\n","import { useMemo } from \"react\";\r\nimport { useThemeContext } from \"../providers\";\r\nimport { AppTheme } from \"../types\";\r\n\r\nexport function useTheme(): AppTheme {\r\n const context = useThemeContext();\r\n\r\n return useMemo(() => context.theme, [context.theme]);\r\n}\r\n","import { useMemo } from \"react\";\r\nimport { StyleSheet } from \"react-native\";\r\nimport { AppTheme } from \"../types\";\r\nimport { useTheme } from \"./use-theme.hook\";\r\n\r\ntype ThemedStyles<T extends StyleSheet.NamedStyles<T>> = T;\r\n\r\ntype StyledFunction<\r\n Props extends object,\r\n T extends StyleSheet.NamedStyles<T>\r\n> = (theme: AppTheme, props: Props) => ThemedStyles<T>;\r\n\r\nexport const useThemedStyles = <\r\n Props extends object,\r\n T extends StyleSheet.NamedStyles<T>\r\n>(\r\n styledFunction: StyledFunction<Props, T>,\r\n props: Props\r\n): ThemedStyles<T> => {\r\n const theme = useTheme();\r\n\r\n return useMemo(() => styledFunction(theme, props), [theme, props]);\r\n};\r\n"],"mappings":";AAEO,IAAM,gBAAgB,oBAAI,IAAsB;AAAA;AAAA,EAErD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAC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AAe,CAAC,KAAK,MAAM,CAAC,MAAM,QAAW;AAC/C,YAAM,CAAC,IAAI,MAAM,CAAC;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAuB,UAAiB;AACpE,MAAI,MAAM;AAEV,aAAW,KAAK,OAAO;AACrB,QAAI,eAAe,CAAC,GAAG;AACrB,aAAO,OAAO,MAAM,CAAgB,CAAC;AAAA,IACvC;AAAA,EACF;AAEA,SAAO;AACT;;;AD3BO,SAAS,cAAoC,OAAc;AAChE,QAAM,MAAM,eAAe,KAAK;AAEhC,SAAOC,SAAQ,MAAM,kBAAkB,KAAK,GAAG,CAAC,GAAG,CAAC;AACtD;;;AEPA,SAAS,WAAAC,gBAAe;AAIjB,SAAS,WAAqB;AACnC,QAAM,UAAU,gBAAgB;AAEhC,SAAOC,SAAQ,MAAM,QAAQ,OAAO,CAAC,QAAQ,KAAK,CAAC;AACrD;;;ACRA,SAAS,WAAAC,gBAAe;AAYjB,IAAM,kBAAkB,CAI7B,gBACA,UACoB;AACpB,QAAM,QAAQ,SAAS;AAEvB,SAAOC,SAAQ,MAAM,eAAe,OAAO,KAAK,GAAG,CAAC,OAAO,KAAK,CAAC;AACnE;","names":["useMemo","ThemeProvider","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo","useMemo"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@impulse-ui-native/theme",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@expo-google-fonts/montserrat": "^0.4.1",
|
|
25
|
-
"@impulse-ui-native/core": "1.0.
|
|
25
|
+
"@impulse-ui-native/core": "1.0.8"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=18",
|
package/src/constants/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./style.constants";
|
|
2
|
+
export * from "./typography.constants";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FontWeightItalic, FontWeightKey, FontWeightNormal } from "../types";
|
|
2
|
+
|
|
3
|
+
export const FontWeightsNormal: Record<FontWeightKey, FontWeightNormal> = {
|
|
4
|
+
100: "Montserrat_100Thin",
|
|
5
|
+
200: "Montserrat_200ExtraLight",
|
|
6
|
+
300: "Montserrat_300Light",
|
|
7
|
+
400: "Montserrat_400Regular",
|
|
8
|
+
500: "Montserrat_500Medium",
|
|
9
|
+
600: "Montserrat_600SemiBold",
|
|
10
|
+
700: "Montserrat_700Bold",
|
|
11
|
+
800: "Montserrat_800ExtraBold",
|
|
12
|
+
900: "Montserrat_900Black",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const FontWeightsItalic: Record<FontWeightKey, FontWeightItalic> = {
|
|
16
|
+
100: "Montserrat_100Thin_Italic",
|
|
17
|
+
200: "Montserrat_200ExtraLight_Italic",
|
|
18
|
+
300: "Montserrat_300Light_Italic",
|
|
19
|
+
400: "Montserrat_400Regular_Italic",
|
|
20
|
+
500: "Montserrat_500Medium_Italic",
|
|
21
|
+
600: "Montserrat_600SemiBold_Italic",
|
|
22
|
+
700: "Montserrat_700Bold_Italic",
|
|
23
|
+
800: "Montserrat_800ExtraBold_Italic",
|
|
24
|
+
900: "Montserrat_900Black_Italic",
|
|
25
|
+
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { useBorder } from "./use-border.hook";
|
|
2
2
|
export { useColors } from "./use-colors.hook";
|
|
3
|
+
export { useComponentsTheme } from "./use-components-theme.hook";
|
|
3
4
|
export { useRadii } from "./use-radii.hook";
|
|
4
5
|
export { useSpace } from "./use-space.hook";
|
|
5
6
|
export { useStyleProps } from "./use-style-props.hook";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DeepPartial } from "@impulse-ui-native/core";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { useThemeContext } from "../providers";
|
|
4
|
+
import { ComponentsThemes } from "../types";
|
|
5
|
+
|
|
6
|
+
export function useComponentsTheme():
|
|
7
|
+
| DeepPartial<ComponentsThemes>
|
|
8
|
+
| undefined {
|
|
9
|
+
const context = useThemeContext();
|
|
10
|
+
|
|
11
|
+
return useMemo(() => context.components, [context.components]);
|
|
12
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
1
|
+
export * from "./constants";
|
|
2
|
+
export * from "./hooks";
|
|
3
|
+
export * from "./providers";
|
|
4
|
+
export * from "./theme";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
export * from "./utils";
|
|
@@ -7,7 +7,13 @@ import {
|
|
|
7
7
|
useMemo,
|
|
8
8
|
} from "react";
|
|
9
9
|
import { DarkTheme, LightTheme } from "../theme";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
AppTheme,
|
|
12
|
+
ColorScheme,
|
|
13
|
+
ComponentsThemes,
|
|
14
|
+
CustomComponentsTheme,
|
|
15
|
+
ThemeContextData,
|
|
16
|
+
} from "../types";
|
|
11
17
|
|
|
12
18
|
import {
|
|
13
19
|
Montserrat_100Thin,
|
|
@@ -34,15 +40,16 @@ import {
|
|
|
34
40
|
const ThemeContext = createContext<ThemeContextData | undefined>(undefined);
|
|
35
41
|
|
|
36
42
|
interface ThemeProviderProps {
|
|
37
|
-
scheme
|
|
38
|
-
theme
|
|
43
|
+
scheme?: ColorScheme;
|
|
44
|
+
theme?: DeepPartial<{
|
|
39
45
|
light: AppTheme;
|
|
40
46
|
dark: AppTheme;
|
|
41
|
-
}
|
|
47
|
+
}>;
|
|
48
|
+
components?: CustomComponentsTheme;
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
export const ThemeProvider = memo(function ThemeProvider(
|
|
45
|
-
props: PropsWithChildren<
|
|
52
|
+
props: PropsWithChildren<ThemeProviderProps>
|
|
46
53
|
) {
|
|
47
54
|
const scheme = props.scheme ?? "light";
|
|
48
55
|
|
|
@@ -69,12 +76,23 @@ export const ThemeProvider = memo(function ThemeProvider(
|
|
|
69
76
|
|
|
70
77
|
const context = useMemo<ThemeContextData>(() => {
|
|
71
78
|
const baseTheme = scheme === "light" ? LightTheme : DarkTheme;
|
|
79
|
+
const customBaseTheme = props.theme?.[scheme];
|
|
80
|
+
const theme = merge(baseTheme, customBaseTheme);
|
|
81
|
+
|
|
82
|
+
let componentsTheme: DeepPartial<ComponentsThemes> | undefined;
|
|
83
|
+
|
|
84
|
+
if (typeof props.components === "function") {
|
|
85
|
+
componentsTheme = props.components(theme);
|
|
86
|
+
} else {
|
|
87
|
+
componentsTheme = props.components;
|
|
88
|
+
}
|
|
72
89
|
|
|
73
90
|
return {
|
|
74
91
|
loaded,
|
|
75
|
-
theme
|
|
92
|
+
theme,
|
|
93
|
+
components: componentsTheme,
|
|
76
94
|
};
|
|
77
|
-
}, [props.theme?.light, props.theme?.dark]);
|
|
95
|
+
}, [props.theme?.light, props.theme?.dark, props.components]);
|
|
78
96
|
|
|
79
97
|
return (
|
|
80
98
|
<ThemeContext.Provider value={context}>
|
package/src/theme/dark.theme.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FontWeightsItalic, FontWeightsNormal } from "../constants";
|
|
1
2
|
import { AppTheme } from "../types";
|
|
2
3
|
import {
|
|
3
4
|
BorderSizeTokens,
|
|
@@ -29,6 +30,10 @@ export const DarkTheme: AppTheme = {
|
|
|
29
30
|
},
|
|
30
31
|
spacing: SpaceTokens,
|
|
31
32
|
radii: RadiiTokens,
|
|
33
|
+
fontWeights: {
|
|
34
|
+
normal: FontWeightsNormal,
|
|
35
|
+
italic: FontWeightsItalic,
|
|
36
|
+
},
|
|
32
37
|
borderSize: BorderSizeTokens,
|
|
33
38
|
fontSize: FontSizeTokens,
|
|
34
39
|
};
|
package/src/theme/index.ts
CHANGED
package/src/theme/light.theme.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FontWeightsItalic, FontWeightsNormal } from "../constants";
|
|
1
2
|
import { AppTheme } from "../types";
|
|
2
3
|
import {
|
|
3
4
|
BorderSizeTokens,
|
|
@@ -29,6 +30,10 @@ export const LightTheme: AppTheme = {
|
|
|
29
30
|
},
|
|
30
31
|
spacing: SpaceTokens,
|
|
31
32
|
radii: RadiiTokens,
|
|
33
|
+
fontWeights: {
|
|
34
|
+
normal: FontWeightsNormal,
|
|
35
|
+
italic: FontWeightsItalic,
|
|
36
|
+
},
|
|
32
37
|
borderSize: BorderSizeTokens,
|
|
33
38
|
fontSize: FontSizeTokens,
|
|
34
39
|
};
|
|
@@ -6,11 +6,16 @@ import {
|
|
|
6
6
|
Radii,
|
|
7
7
|
Space,
|
|
8
8
|
} from "./tokens.types";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
FontWeightKey,
|
|
11
|
+
TypographyPresetKey,
|
|
12
|
+
TypographyProps,
|
|
13
|
+
} from "./typography.types";
|
|
10
14
|
|
|
11
15
|
export interface ThemeContextData {
|
|
12
16
|
loaded: boolean;
|
|
13
17
|
theme: AppTheme;
|
|
18
|
+
components?: DeepPartial<ComponentsThemes>;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
export type ColorScheme = "light" | "dark";
|
|
@@ -50,6 +55,10 @@ export interface AppTheme {
|
|
|
50
55
|
spacing: Space;
|
|
51
56
|
radii: Radii;
|
|
52
57
|
borderSize: BorderSizes;
|
|
58
|
+
fontWeights: Record<"normal" | "italic", Record<FontWeightKey, string>>;
|
|
53
59
|
fontSize: FontSizes;
|
|
54
|
-
components?: DeepPartial<ComponentsThemes>;
|
|
55
60
|
}
|
|
61
|
+
|
|
62
|
+
export type CustomComponentsTheme =
|
|
63
|
+
| ((theme: AppTheme) => DeepPartial<ComponentsThemes>)
|
|
64
|
+
| DeepPartial<ComponentsThemes>;
|