@alveole/theme 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +109 -0
  2. package/assets/fonts/Barlow/Barlow-Bold.ttf +0 -0
  3. package/assets/fonts/Barlow/Barlow-Light.ttf +0 -0
  4. package/assets/fonts/Barlow/Barlow-Medium.ttf +0 -0
  5. package/assets/fonts/Barlow/Barlow-Regular.ttf +0 -0
  6. package/assets/fonts/Barlow/Barlow-SemiBold.ttf +0 -0
  7. package/assets/fonts/Inter/Inter-Bold.ttf +0 -0
  8. package/assets/fonts/Inter/Inter-Light.ttf +0 -0
  9. package/assets/fonts/Inter/Inter-Medium.ttf +0 -0
  10. package/assets/fonts/Inter/Inter-Regular.ttf +0 -0
  11. package/assets/fonts/Inter/Inter-SemiBold.ttf +0 -0
  12. package/dist/ThemeProvider.d.ts +8 -0
  13. package/dist/ThemeProvider.d.ts.map +1 -0
  14. package/dist/ThemeProvider.js +32 -0
  15. package/dist/ThemeProviderLoader.d.ts +2 -0
  16. package/dist/ThemeProviderLoader.d.ts.map +1 -0
  17. package/dist/ThemeProviderLoader.js +5 -0
  18. package/dist/constants/Breakpoint.d.ts +10 -0
  19. package/dist/constants/Breakpoint.d.ts.map +1 -0
  20. package/dist/constants/Breakpoint.js +14 -0
  21. package/dist/constants/Color.d.ts +357 -0
  22. package/dist/constants/Color.d.ts.map +1 -0
  23. package/dist/constants/Color.js +352 -0
  24. package/dist/constants/Elevation.d.ts +81 -0
  25. package/dist/constants/Elevation.d.ts.map +1 -0
  26. package/dist/constants/Elevation.js +53 -0
  27. package/dist/constants/Font.d.ts +15 -0
  28. package/dist/constants/Font.d.ts.map +1 -0
  29. package/dist/constants/Font.js +15 -0
  30. package/dist/constants/Palette.d.ts +187 -0
  31. package/dist/constants/Palette.d.ts.map +1 -0
  32. package/dist/constants/Palette.js +180 -0
  33. package/dist/constants/Radius.d.ts +9 -0
  34. package/dist/constants/Radius.d.ts.map +1 -0
  35. package/dist/constants/Radius.js +6 -0
  36. package/dist/constants/Sizes.d.ts +35 -0
  37. package/dist/constants/Sizes.d.ts.map +1 -0
  38. package/dist/constants/Sizes.js +30 -0
  39. package/dist/constants/Spacing.d.ts +24 -0
  40. package/dist/constants/Spacing.d.ts.map +1 -0
  41. package/dist/constants/Spacing.js +21 -0
  42. package/dist/constants/Typography.d.ts +189 -0
  43. package/dist/constants/Typography.d.ts.map +1 -0
  44. package/dist/constants/Typography.js +190 -0
  45. package/dist/constants/UnsupportedCSSProperties.d.ts +4 -0
  46. package/dist/constants/UnsupportedCSSProperties.d.ts.map +1 -0
  47. package/dist/constants/UnsupportedCSSProperties.js +3 -0
  48. package/dist/constants/Variant.d.ts +8 -0
  49. package/dist/constants/Variant.d.ts.map +1 -0
  50. package/dist/constants/Variant.js +5 -0
  51. package/dist/constants/index.d.ts +11 -0
  52. package/dist/constants/index.d.ts.map +1 -0
  53. package/dist/constants/index.js +10 -0
  54. package/dist/helpers/alphaColor.d.ts +12 -0
  55. package/dist/helpers/alphaColor.d.ts.map +1 -0
  56. package/dist/helpers/alphaColor.js +20 -0
  57. package/dist/helpers/deepMerge.d.ts +6 -0
  58. package/dist/helpers/deepMerge.d.ts.map +1 -0
  59. package/dist/helpers/deepMerge.js +17 -0
  60. package/dist/helpers/elevationStyle.d.ts +19 -0
  61. package/dist/helpers/elevationStyle.d.ts.map +1 -0
  62. package/dist/helpers/elevationStyle.js +16 -0
  63. package/dist/helpers/injectVariableCSS.d.ts +3 -0
  64. package/dist/helpers/injectVariableCSS.d.ts.map +1 -0
  65. package/dist/helpers/injectVariableCSS.js +27 -0
  66. package/dist/helpers/isSpacingKey.d.ts +3 -0
  67. package/dist/helpers/isSpacingKey.d.ts.map +1 -0
  68. package/dist/helpers/isSpacingKey.js +2 -0
  69. package/dist/helpers/makeStyles.d.ts +15 -0
  70. package/dist/helpers/makeStyles.d.ts.map +1 -0
  71. package/dist/helpers/makeStyles.js +14 -0
  72. package/dist/helpers/removeUnsupportedCSSProperties.d.ts +8 -0
  73. package/dist/helpers/removeUnsupportedCSSProperties.d.ts.map +1 -0
  74. package/dist/helpers/removeUnsupportedCSSProperties.js +20 -0
  75. package/dist/helpers/useThemeBuilder.d.ts +9 -0
  76. package/dist/helpers/useThemeBuilder.d.ts.map +1 -0
  77. package/dist/helpers/useThemeBuilder.js +38 -0
  78. package/dist/index.d.ts +6 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +5 -0
  81. package/dist/type/Theme.d.ts +21 -0
  82. package/dist/type/Theme.d.ts.map +1 -0
  83. package/dist/type/Theme.js +1 -0
  84. package/dist/type/Typography.d.ts +8 -0
  85. package/dist/type/Typography.d.ts.map +1 -0
  86. package/dist/type/Typography.js +1 -0
  87. package/dist/type/index.d.ts +2 -0
  88. package/dist/type/index.d.ts.map +1 -0
  89. package/dist/type/index.js +1 -0
  90. package/package.json +26 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeUnsupportedCSSProperties.d.ts","sourceRoot":"","sources":["../../src/helpers/removeUnsupportedCSSProperties.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAUjG"}
@@ -0,0 +1,20 @@
1
+ import { Platform } from 'react-native';
2
+ import { UnsupportedCSSProperties } from '../constants';
3
+ /**
4
+ * Retire les propriétés CSS non supportées pour une platforme
5
+ * @param styles Styles appliqués
6
+ * @returns Les styles sans les propriétés exclues pour la platform
7
+ */
8
+ export function removeUnsupportedCSSProperties(styles) {
9
+ const platform = Platform.OS;
10
+ const blocklist = UnsupportedCSSProperties[platform] ?? [];
11
+ const cleaned = {};
12
+ for (const key in styles) {
13
+ const style = { ...styles[key] };
14
+ for (const prop of blocklist)
15
+ if (prop in style)
16
+ style[prop] = undefined;
17
+ cleaned[key] = style;
18
+ }
19
+ return cleaned;
20
+ }
@@ -0,0 +1,9 @@
1
+ import type { Theme } from '../type';
2
+ import { DeepPartial, Palette } from '../constants';
3
+ export type CustomBuilder = {
4
+ color?: DeepPartial<Palette>;
5
+ };
6
+ export declare function useThemeBuilder(params: CustomBuilder): Theme & {
7
+ isReady: boolean;
8
+ };
9
+ //# sourceMappingURL=useThemeBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useThemeBuilder.d.ts","sourceRoot":"","sources":["../../src/helpers/useThemeBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKrC,OAAO,EAKL,WAAW,EAIX,OAAO,EAGR,MAAM,cAAc,CAAC;AAMtB,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAC9B,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,KAAK,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CA4CnF"}
@@ -0,0 +1,38 @@
1
+ import { useFonts } from 'expo-font';
2
+ import { useCallback, useMemo } from 'react';
3
+ import { useWindowDimensions } from 'react-native';
4
+ import { breakpointToVariant, Colors, CustomPalette, CustomTypography, Fonts, FontsMap, Heights, Sizes, Spacings, } from '../constants';
5
+ import { RadiusList } from '../constants/Radius';
6
+ import { alpha } from './alphaColor';
7
+ import { deepMerge } from './deepMerge';
8
+ import { elevationStyle } from './elevationStyle';
9
+ export function useThemeBuilder(params) {
10
+ const { width } = useWindowDimensions();
11
+ const [loadedFonts] = useFonts(FontsMap);
12
+ const variant = useMemo(() => breakpointToVariant(width), [width]);
13
+ const mergedPalette = useMemo(() => deepMerge(CustomPalette, params.color), [params.color]);
14
+ const isReady = useMemo(() => width != null && variant != null && width > 0 && loadedFonts, [loadedFonts, variant, width]);
15
+ return {
16
+ // Spacings
17
+ spacing: key => Spacings[key],
18
+ // Radius
19
+ radius: key => RadiusList[key],
20
+ // Breakpoints
21
+ variant,
22
+ isVariant: useCallback(match => variant === match, [variant]),
23
+ // Colors
24
+ color: { _constants: Colors, alpha, ...mergedPalette },
25
+ // Shadows
26
+ shadows: elevationStyle,
27
+ // Typographies
28
+ text: {
29
+ ...CustomTypography,
30
+ fontSize: Sizes,
31
+ lineHeight: Heights,
32
+ },
33
+ // Typographies
34
+ font: Fonts,
35
+ // Theme state
36
+ isReady,
37
+ };
38
+ }
@@ -0,0 +1,6 @@
1
+ export * from './constants';
2
+ export * from './helpers/isSpacingKey';
3
+ export * from './helpers/makeStyles';
4
+ export * from './ThemeProvider';
5
+ export * from './type';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './constants';
2
+ export * from './helpers/isSpacingKey';
3
+ export * from './helpers/makeStyles';
4
+ export * from './ThemeProvider';
5
+ export * from './type';
@@ -0,0 +1,21 @@
1
+ import type { Colors, CustomPalette, CustomTypography, Fonts, Spacing, SpacingKey, Variant } from '../constants';
2
+ import { Radius, RadiusKey } from '../constants/Radius';
3
+ import { alpha } from '../helpers/alphaColor';
4
+ import { elevationStyle } from '../helpers/elevationStyle';
5
+ import type { Typography } from './Typography';
6
+ export interface Theme {
7
+ spacing: (key: SpacingKey) => Spacing;
8
+ variant: Variant;
9
+ isVariant: (variant: Variant) => boolean;
10
+ shadows: typeof elevationStyle;
11
+ radius: (key: RadiusKey) => Radius;
12
+ text: Typography & typeof CustomTypography;
13
+ font: typeof Fonts;
14
+ color: {
15
+ /** @deprecated Utiliser la palette */
16
+ _constants: typeof Colors;
17
+ } & typeof CustomPalette & {
18
+ alpha: typeof alpha;
19
+ };
20
+ }
21
+ //# sourceMappingURL=Theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../src/type/Theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,KAAK;IAEpB,OAAO,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC;IAGtC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;IAGzC,OAAO,EAAE,OAAO,cAAc,CAAC;IAG/B,MAAM,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,MAAM,CAAC;IAGnC,IAAI,EAAE,UAAU,GAAG,OAAO,gBAAgB,CAAC;IAG3C,IAAI,EAAE,OAAO,KAAK,CAAC;IAGnB,KAAK,EAAE;QACL,sCAAsC;QACtC,UAAU,EAAE,OAAO,MAAM,CAAC;KAC3B,GAAG,OAAO,aAAa,GAAG;QACvB,KAAK,EAAE,OAAO,KAAK,CAAC;KACrB,CAAC;CACL"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { TextStyle } from 'react-native';
2
+ import type { Heights, Sizes } from '../constants';
3
+ export type CustomStyle = Pick<TextStyle, 'fontSize' | 'lineHeight' | 'fontWeight' | 'fontFamily'>;
4
+ export interface Typography {
5
+ fontSize: typeof Sizes;
6
+ lineHeight: typeof Heights;
7
+ }
8
+ //# sourceMappingURL=Typography.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Typography.d.ts","sourceRoot":"","sources":["../../src/type/Typography.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC,CAAC;AAEnG,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,OAAO,KAAK,CAAC;IACvB,UAAU,EAAE,OAAO,OAAO,CAAC;CAC5B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './Theme';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/type/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './Theme';
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@alveole/theme",
3
+ "version": "0.4.0",
4
+ "description": "Shared theme tokens and utilities.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "assets",
10
+ "README.md"
11
+ ],
12
+ "sideEffects": false,
13
+ "scripts": {
14
+ "build": "tsc -p tsconfig.build.json && rm -rf assets && cp -R src/assets assets"
15
+ },
16
+ "peerDependencies": {
17
+ "@tamagui/core": "*",
18
+ "expo-font": "*",
19
+ "expo-system-ui": "*",
20
+ "react": "*",
21
+ "react-native": "*"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ }
26
+ }