@draftbit/theme 50.6.2-8430ca.2 → 50.6.2-98b4e5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/DefaultTheme.js +1 -1
- package/lib/commonjs/Provider.js +1 -1
- package/lib/commonjs/createTheme.js +1 -1
- package/lib/commonjs/createThemeValuesProxy.js +1 -1
- package/lib/commonjs/types.js +1 -0
- package/lib/commonjs/validators.js +1 -1
- package/lib/typescript/src/DefaultTheme.js +38 -38
- package/lib/typescript/src/DefaultTheme.js.map +1 -1
- package/lib/typescript/src/Provider.js +10 -1
- package/lib/typescript/src/Provider.js.map +1 -1
- package/lib/typescript/src/createTheme.d.ts +13 -1
- package/lib/typescript/src/createTheme.js +17 -6
- package/lib/typescript/src/createTheme.js.map +1 -1
- package/lib/typescript/src/createThemeValuesProxy.js +34 -22
- package/lib/typescript/src/createThemeValuesProxy.js.map +1 -1
- package/lib/typescript/src/types.d.ts +30 -2
- package/lib/typescript/src/validators.d.ts +3 -1
- package/lib/typescript/src/validators.js +10 -45
- package/lib/typescript/src/validators.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/src/DefaultTheme.js +38 -38
- package/src/DefaultTheme.js.map +1 -1
- package/src/DefaultTheme.ts +38 -38
- package/src/Provider.js +10 -1
- package/src/Provider.js.map +1 -1
- package/src/Provider.tsx +10 -1
- package/src/createTheme.js +17 -6
- package/src/createTheme.js.map +1 -1
- package/src/createTheme.ts +19 -12
- package/src/createThemeValuesProxy.js +34 -22
- package/src/createThemeValuesProxy.js.map +1 -1
- package/src/createThemeValuesProxy.ts +49 -31
- package/src/types.ts +33 -2
- package/src/validators.js +10 -45
- package/src/validators.js.map +1 -1
- package/src/validators.ts +12 -49
|
@@ -1 +1 @@
|
|
|
1
|
-
import{systemWeights}from"react-native-typography";import createTheme from"./createTheme";var palettes={draftbit:{primary:"rgb(90, 69, 255)",secondary:"rgb(59, 201, 234)",tertiary:"rgb(90,69,255)",background:"rgba(251, 252, 253, 1)",error:"rgba(255, 69, 100, 1)",divider:"rgba(200, 200, 200, 1)",strong:"rgba(18, 20, 44, 1)",medium:"rgba(70, 78, 88, 1)",light:"rgba(165, 173, 183, 1)",text:"#000",success:"#22bb33",warning:"#f0ad4e",info:"#aaaaaa"}};var DraftbitTheme=createTheme({breakpoints:{},palettes:palettes,theme:{name:"Draftbit",colors:{branding:{primary:palettes.draftbit.primary,secondary:palettes.draftbit.secondary,tertiary:palettes.draftbit.tertiary,accent:palettes.draftbit.secondary},text:{strong:palettes.draftbit.strong,medium:palettes.draftbit.medium,normal:palettes.draftbit.text,light:palettes.draftbit.light,success:palettes.draftbit.success,warning:palettes.draftbit.warning,danger:palettes.draftbit.error},background:{brand:palettes.draftbit.background,info:palettes.draftbit.info,success:palettes.draftbit.success,warning:palettes.draftbit.warning,danger:palettes.draftbit.error},foreground:{brand:palettes.draftbit.light,info:palettes.draftbit.strong,success:palettes.draftbit.light,warning:palettes.draftbit.light,danger:palettes.draftbit.light},border:{brand:palettes.draftbit.divider,info:palettes.draftbit.divider,success:palettes.draftbit.divider,warning:palettes.draftbit.divider,danger:palettes.draftbit.divider}},typography:{
|
|
1
|
+
import{systemWeights}from"react-native-typography";import createTheme from"./createTheme";var palettes={draftbit:{primary:"rgb(90, 69, 255)",secondary:"rgb(59, 201, 234)",tertiary:"rgb(90,69,255)",background:"rgba(251, 252, 253, 1)",error:"rgba(255, 69, 100, 1)",divider:"rgba(200, 200, 200, 1)",strong:"rgba(18, 20, 44, 1)",medium:"rgba(70, 78, 88, 1)",light:"rgba(165, 173, 183, 1)",text:"#000",success:"#22bb33",warning:"#f0ad4e",info:"#aaaaaa"}};var DraftbitTheme=createTheme({breakpoints:{},palettes:palettes,theme:{name:"Draftbit",colors:{branding:{primary:palettes.draftbit.primary,secondary:palettes.draftbit.secondary,tertiary:palettes.draftbit.tertiary,accent:palettes.draftbit.secondary},text:{strong:palettes.draftbit.strong,medium:palettes.draftbit.medium,normal:palettes.draftbit.text,light:palettes.draftbit.light,success:palettes.draftbit.success,warning:palettes.draftbit.warning,danger:palettes.draftbit.error},background:{brand:palettes.draftbit.background,info:palettes.draftbit.info,success:palettes.draftbit.success,warning:palettes.draftbit.warning,danger:palettes.draftbit.error},foreground:{brand:palettes.draftbit.light,info:palettes.draftbit.strong,success:palettes.draftbit.light,warning:palettes.draftbit.light,danger:palettes.draftbit.light},border:{brand:palettes.draftbit.divider,info:palettes.draftbit.divider,success:palettes.draftbit.divider,warning:palettes.draftbit.divider,danger:palettes.draftbit.divider}},typography:{body1:Object.assign({},systemWeights.regular,{fontSize:16,letterSpacing:0,lineHeight:26}),body2:Object.assign({},systemWeights.regular,{fontSize:14,letterSpacing:0,lineHeight:22}),button:Object.assign({},systemWeights.bold,{fontSize:14,letterSpacing:0,lineHeight:16}),caption:Object.assign({},systemWeights.regular,{fontSize:12,letterSpacing:0,lineHeight:16}),headline1:Object.assign({},systemWeights.bold,{fontSize:60,letterSpacing:0,lineHeight:71}),headline2:Object.assign({},systemWeights.bold,{fontSize:48,letterSpacing:0,lineHeight:58}),headline3:Object.assign({},systemWeights.bold,{fontSize:34,letterSpacing:0,lineHeight:40}),headline4:Object.assign({},systemWeights.bold,{fontSize:24,letterSpacing:0,lineHeight:34}),headline5:Object.assign({},systemWeights.bold,{fontSize:20,letterSpacing:0,lineHeight:26}),headline6:Object.assign({},systemWeights.bold,{fontSize:16,letterSpacing:0,lineHeight:24}),overline:Object.assign({},systemWeights.regular,{fontSize:12,letterSpacing:2,lineHeight:16}),subtitle1:Object.assign({},systemWeights.regular,{fontSize:16,letterSpacing:0,lineHeight:26}),subtitle2:Object.assign({},systemWeights.regular,{fontSize:14,letterSpacing:0,lineHeight:22})}}});export default DraftbitTheme;
|
package/lib/commonjs/Provider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/theme/src/Provider.tsx";import React from"react";import{Dimensions,Platform,useColorScheme}from"react-native";import AsyncStorage from"@react-native-async-storage/async-storage";import createThemeValuesProxy from"./createThemeValuesProxy";import DefaultTheme from"./DefaultTheme";import{jsx as _jsx}from"react/jsx-runtime";var SAVED_SELECTED_THEME_KEY="saved_selected_theme";var ThemeContext=React.createContext({theme:DefaultTheme,changeTheme:function changeTheme(){}});var Provider=function Provider(_ref){var _themes$find;var themes=_ref.themes,breakpoints=_ref.breakpoints,initialThemeName=_ref.initialThemeName,children=_ref.children;var initialTheme=(_themes$find=themes.find(function(theme){return theme.name===initialThemeName;}))!=null?_themes$find:DefaultTheme;var _React$useState=React.useState(initialTheme),_React$useState2=_slicedToArray(_React$useState,2),currentTheme=_React$useState2[0],setCurrentTheme=_React$useState2[1];var _React$useState3=React.useState(Dimensions.get("window").width),_React$useState4=_slicedToArray(_React$useState3,2),deviceWidth=_React$useState4[0],setDeviceWidth=_React$useState4[1];var colorScheme=useColorScheme();var lightDarkSelection=colorScheme!=null?colorScheme:"light";var changeTheme=React.useCallback(function(themeName,options){var theme=themes.find(function(t){return t.name===themeName;});if(!theme){console.warn("Theme with name",themeName,"not found. Make sure it's passed into the top level ThemeProvider");return;}setCurrentTheme(theme);if((options==null?void 0:options.persistent)===true){AsyncStorage.setItem(SAVED_SELECTED_THEME_KEY,themeName).catch(function(e){console.warn("Failed to persist selected theme",e);});}},[themes,setCurrentTheme]);var proxiedTheme=React.useMemo(function(){return Object.assign({},currentTheme,{colors:{branding:createThemeValuesProxy(currentTheme.colors.branding,breakpoints,deviceWidth,Platform.OS,lightDarkSelection),text:createThemeValuesProxy(currentTheme.colors.text,breakpoints,deviceWidth,Platform.OS,lightDarkSelection),background:createThemeValuesProxy(currentTheme.colors.background,breakpoints,deviceWidth,Platform.OS,lightDarkSelection),foreground:createThemeValuesProxy(currentTheme.colors.foreground,breakpoints,deviceWidth,Platform.OS,lightDarkSelection),border:createThemeValuesProxy(currentTheme.colors.border,breakpoints,deviceWidth,Platform.OS,lightDarkSelection)}});},[currentTheme,deviceWidth,breakpoints,lightDarkSelection]);React.useEffect(function(){var listener=Dimensions.addEventListener("change",function(_ref2){var window=_ref2.window;return setDeviceWidth(window.width);});return function(){listener.remove();};});React.useEffect(function(){var run=function(){var _ref3=_asyncToGenerator(function*(){var savedSelectedThemeName=yield AsyncStorage.getItem(SAVED_SELECTED_THEME_KEY);if(savedSelectedThemeName){changeTheme(savedSelectedThemeName);}});return function run(){return _ref3.apply(this,arguments);};}();run();},[]);return _jsx(ThemeContext.Provider,{value:{theme:proxiedTheme,changeTheme:changeTheme},children:children});};var useTheme=function useTheme(){var _React$useContext=React.useContext(ThemeContext),theme=_React$useContext.theme;return theme;};var useChangeTheme=function useChangeTheme(){var _React$useContext2=React.useContext(ThemeContext),changeTheme=_React$useContext2.changeTheme;return changeTheme;};var withTheme=function withTheme(Component){return React.forwardRef(function(props,ref){var _React$useContext3=React.useContext(ThemeContext),theme=_React$useContext3.theme;return _jsx(Component,Object.assign({},props,{theme:theme,ref:ref}));});};export{Provider,useTheme,useChangeTheme,withTheme};
|
|
1
|
+
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/theme/src/Provider.tsx";import React from"react";import{Dimensions,Platform,useColorScheme}from"react-native";import AsyncStorage from"@react-native-async-storage/async-storage";import createThemeValuesProxy from"./createThemeValuesProxy";import DefaultTheme from"./DefaultTheme";import{jsx as _jsx}from"react/jsx-runtime";var SAVED_SELECTED_THEME_KEY="saved_selected_theme";var ThemeContext=React.createContext({theme:DefaultTheme,changeTheme:function changeTheme(){}});var Provider=function Provider(_ref){var _themes$find;var themes=_ref.themes,breakpoints=_ref.breakpoints,initialThemeName=_ref.initialThemeName,children=_ref.children;var initialTheme=(_themes$find=themes.find(function(theme){return theme.name===initialThemeName;}))!=null?_themes$find:DefaultTheme;var _React$useState=React.useState(initialTheme),_React$useState2=_slicedToArray(_React$useState,2),currentTheme=_React$useState2[0],setCurrentTheme=_React$useState2[1];var _React$useState3=React.useState(Dimensions.get("window").width),_React$useState4=_slicedToArray(_React$useState3,2),deviceWidth=_React$useState4[0],setDeviceWidth=_React$useState4[1];var colorScheme=useColorScheme();var lightDarkSelection=colorScheme!=null?colorScheme:"light";var changeTheme=React.useCallback(function(themeName,options){var theme=themes.find(function(t){return t.name===themeName;});if(!theme){console.warn("Theme with name",themeName,"not found. Make sure it's passed into the top level ThemeProvider");return;}setCurrentTheme(theme);if((options==null?void 0:options.persistent)===true){AsyncStorage.setItem(SAVED_SELECTED_THEME_KEY,themeName).catch(function(e){console.warn("Failed to persist selected theme",e);});}},[themes,setCurrentTheme]);var proxiedTheme=React.useMemo(function(){return Object.assign({},currentTheme,{colors:{branding:createThemeValuesProxy(currentTheme.colors.branding,breakpoints,deviceWidth,Platform.OS,lightDarkSelection),text:createThemeValuesProxy(currentTheme.colors.text,breakpoints,deviceWidth,Platform.OS,lightDarkSelection),background:createThemeValuesProxy(currentTheme.colors.background,breakpoints,deviceWidth,Platform.OS,lightDarkSelection),foreground:createThemeValuesProxy(currentTheme.colors.foreground,breakpoints,deviceWidth,Platform.OS,lightDarkSelection),border:createThemeValuesProxy(currentTheme.colors.border,breakpoints,deviceWidth,Platform.OS,lightDarkSelection)},typography:currentTheme.typography});},[currentTheme,deviceWidth,breakpoints,lightDarkSelection]);React.useEffect(function(){var listener=Dimensions.addEventListener("change",function(_ref2){var window=_ref2.window;return setDeviceWidth(window.width);});return function(){listener.remove();};});React.useEffect(function(){var run=function(){var _ref3=_asyncToGenerator(function*(){var savedSelectedThemeName=yield AsyncStorage.getItem(SAVED_SELECTED_THEME_KEY);var themeExists=themes.some(function(t){return t.name===savedSelectedThemeName;});if(savedSelectedThemeName){if(themeExists){changeTheme(savedSelectedThemeName);}else{AsyncStorage.removeItem(SAVED_SELECTED_THEME_KEY).catch(function(e){console.warn("Failed to reset persisted selected theme",e);});}}});return function run(){return _ref3.apply(this,arguments);};}();run();},[]);return _jsx(ThemeContext.Provider,{value:{theme:proxiedTheme,changeTheme:changeTheme},children:children});};var useTheme=function useTheme(){var _React$useContext=React.useContext(ThemeContext),theme=_React$useContext.theme;return theme;};var useChangeTheme=function useChangeTheme(){var _React$useContext2=React.useContext(ThemeContext),changeTheme=_React$useContext2.changeTheme;return changeTheme;};var withTheme=function withTheme(Component){return React.forwardRef(function(props,ref){var _React$useContext3=React.useContext(ThemeContext),theme=_React$useContext3.theme;return _jsx(Component,Object.assign({},props,{theme:theme,ref:ref}));});};export{Provider,useTheme,useChangeTheme,withTheme};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import merge from"deepmerge";
|
|
1
|
+
import merge from"deepmerge";export default function createTheme(_ref){var theme=_ref.theme,baseTheme=_ref.baseTheme;var resultTheme=theme;if(baseTheme){resultTheme=merge(baseTheme,theme);}return Object.assign({},resultTheme,{validated:true});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{isObject}from"lodash";export default function createThemeValuesProxy(value,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection){if(value===undefined||value===null){return undefined;}return new Proxy(value,{get:function get(target,key){var currentValue=target[key];
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{isObject}from"lodash";export default function createThemeValuesProxy(value,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection){if(value===undefined||value===null){return undefined;}return new Proxy(value,{get:function get(target,key){var currentValue=target[key];var valueAsThemeValues=isObject(currentValue)?currentValue:undefined;if(valueAsThemeValues){var platformKeys=["ios","android","web","macos","windows"];var breakpointKeys=Object.keys(breakpoints);var lightDarkKeys=["light","dark"];var keysType=getKeysType(valueAsThemeValues,platformKeys,breakpointKeys,lightDarkKeys);if(keysType==="default"){return createThemeValuesProxy(valueAsThemeValues,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection);}else if(keysType==="platform"){return getPlatformValue(valueAsThemeValues,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection);}else if(keysType==="breakpoint"){return getBreakpointValue(valueAsThemeValues,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection);}else if(keysType==="lightDark"){return getLightDarkValue(valueAsThemeValues,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection);}else{return undefined;}}else{return currentValue;}},set:function set(){throw new Error("Theme is read only, cannot be modified at runtime");}});}function getKeysType(value,platformKeys,breakpointKeys,lightDarkKeys){var hasPlatformKeys=platformKeys.some(function(key){return value[key]!==undefined;});var hasBreakpointKeys=breakpointKeys.some(function(key){return value[key]!==undefined;});var hasLightDarkKeys=lightDarkKeys.some(function(key){return value[key]!==undefined;});var hasUserDefinedKeys=Object.keys(value).some(function(key){return!platformKeys.includes(key)&&!breakpointKeys.includes(key)&&!lightDarkKeys.includes(key)&&key!=="default";});if(!onlyOneTrue(hasPlatformKeys,hasBreakpointKeys,hasUserDefinedKeys,hasLightDarkKeys)&&!allFalse(hasPlatformKeys,hasBreakpointKeys,hasUserDefinedKeys,hasLightDarkKeys)){throw new Error("Cannot mix usage of platform keys, breakpoint keys, light/dark keys, and custom defined keys on the same level"+`\nKeys: ${Object.keys(value).join(", ")}`);}else if(hasPlatformKeys){return"platform";}else if(hasBreakpointKeys){return"breakpoint";}else if(hasLightDarkKeys){return"lightDark";}else{return"default";}}function onlyOneTrue(a,b,c,d){return[a,b,c,d].filter(function(x){return x;}).length===1;}function allFalse(a,b,c,d){return[a,b,c,d].filter(function(x){return x;}).length===0;}function getPlatformValue(value,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection){var _value$devicePlatform;var currentPlatformValue=(_value$devicePlatform=value==null?void 0:value[devicePlatform])!=null?_value$devicePlatform:value==null?void 0:value.default;var valueAsThemeValues=isObject(currentPlatformValue)?currentPlatformValue:undefined;if(valueAsThemeValues){return createThemeValuesProxy(valueAsThemeValues,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection);}else{return currentPlatformValue;}}function getBreakpointValue(value,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection){var _value$currentBreakpo;var keysToBreakpointValue=Object.keys(value!=null?value:{}).map(function(key){return[key,breakpoints[key]];});var orderedBreakpoints=keysToBreakpointValue.sort(function(_ref){var _ref2=_slicedToArray(_ref,2),_=_ref2[0],val=_ref2[1];return val;});var currentBreakpointKey="";for(var _ref3 of orderedBreakpoints){var _ref4=_slicedToArray(_ref3,2);var breakpointKey=_ref4[0];var breakpointValue=_ref4[1];if(deviceWidth>=breakpointValue){currentBreakpointKey=breakpointKey;}}var currentBreakpointValue=(_value$currentBreakpo=value==null?void 0:value[currentBreakpointKey])!=null?_value$currentBreakpo:value==null?void 0:value.default;var valueAsThemeValues=isObject(currentBreakpointKey)?currentBreakpointKey:undefined;if(valueAsThemeValues){return createThemeValuesProxy(valueAsThemeValues,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection);}else{return currentBreakpointValue;}}function getLightDarkValue(value,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection){var _value$currentLightDa;var currentLightDarkValue=(_value$currentLightDa=value==null?void 0:value[currentLightDarkSelection])!=null?_value$currentLightDa:value==null?void 0:value.default;var valueAsThemeValues=isObject(currentLightDarkSelection)?currentLightDarkSelection:undefined;if(valueAsThemeValues){return createThemeValuesProxy(valueAsThemeValues,breakpoints,deviceWidth,devicePlatform,currentLightDarkSelection);}else{return currentLightDarkValue;}}
|
package/lib/commonjs/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function validatePalettes(palettes){palettes;}export function validateBreakpoints(breakpoints){breakpoints;}export function validateTheme(theme){theme;}export function isTextStyleObject(value){value;return true;}export function asThemeValuesObject(value){return value;}
|
|
@@ -61,84 +61,84 @@ const DraftbitTheme = createTheme({
|
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
typography: {
|
|
64
|
-
|
|
64
|
+
body1: {
|
|
65
65
|
...systemWeights.regular,
|
|
66
|
+
fontSize: 16,
|
|
67
|
+
letterSpacing: 0,
|
|
68
|
+
lineHeight: 26,
|
|
69
|
+
},
|
|
70
|
+
body2: {
|
|
71
|
+
...systemWeights.regular,
|
|
72
|
+
fontSize: 14,
|
|
73
|
+
letterSpacing: 0,
|
|
74
|
+
lineHeight: 22,
|
|
75
|
+
},
|
|
76
|
+
button: {
|
|
77
|
+
...systemWeights.bold,
|
|
78
|
+
fontSize: 14,
|
|
79
|
+
letterSpacing: 0,
|
|
80
|
+
lineHeight: 16,
|
|
81
|
+
},
|
|
82
|
+
caption: {
|
|
83
|
+
...systemWeights.regular,
|
|
84
|
+
fontSize: 12,
|
|
85
|
+
letterSpacing: 0,
|
|
86
|
+
lineHeight: 16,
|
|
87
|
+
},
|
|
88
|
+
headline1: {
|
|
89
|
+
...systemWeights.bold,
|
|
66
90
|
fontSize: 60,
|
|
67
91
|
letterSpacing: 0,
|
|
68
92
|
lineHeight: 71,
|
|
69
93
|
},
|
|
70
94
|
headline2: {
|
|
71
|
-
...systemWeights.
|
|
95
|
+
...systemWeights.bold,
|
|
72
96
|
fontSize: 48,
|
|
73
97
|
letterSpacing: 0,
|
|
74
98
|
lineHeight: 58,
|
|
75
99
|
},
|
|
76
100
|
headline3: {
|
|
77
|
-
...systemWeights.
|
|
101
|
+
...systemWeights.bold,
|
|
78
102
|
fontSize: 34,
|
|
79
103
|
letterSpacing: 0,
|
|
80
104
|
lineHeight: 40,
|
|
81
105
|
},
|
|
82
106
|
headline4: {
|
|
83
|
-
...systemWeights.
|
|
107
|
+
...systemWeights.bold,
|
|
84
108
|
fontSize: 24,
|
|
85
109
|
letterSpacing: 0,
|
|
86
110
|
lineHeight: 34,
|
|
87
111
|
},
|
|
88
112
|
headline5: {
|
|
89
|
-
...systemWeights.
|
|
113
|
+
...systemWeights.bold,
|
|
90
114
|
fontSize: 20,
|
|
91
115
|
letterSpacing: 0,
|
|
92
116
|
lineHeight: 26,
|
|
93
117
|
},
|
|
94
|
-
|
|
95
|
-
...systemWeights.
|
|
118
|
+
headline6: {
|
|
119
|
+
...systemWeights.bold,
|
|
96
120
|
fontSize: 16,
|
|
97
121
|
letterSpacing: 0,
|
|
98
|
-
lineHeight:
|
|
122
|
+
lineHeight: 24,
|
|
99
123
|
},
|
|
100
|
-
|
|
124
|
+
overline: {
|
|
101
125
|
...systemWeights.regular,
|
|
102
|
-
fontSize:
|
|
103
|
-
letterSpacing:
|
|
104
|
-
lineHeight:
|
|
126
|
+
fontSize: 12,
|
|
127
|
+
letterSpacing: 2,
|
|
128
|
+
lineHeight: 16,
|
|
105
129
|
},
|
|
106
|
-
|
|
130
|
+
subtitle1: {
|
|
107
131
|
...systemWeights.regular,
|
|
108
132
|
fontSize: 16,
|
|
109
133
|
letterSpacing: 0,
|
|
110
134
|
lineHeight: 26,
|
|
111
135
|
},
|
|
112
|
-
|
|
136
|
+
subtitle2: {
|
|
113
137
|
...systemWeights.regular,
|
|
114
138
|
fontSize: 14,
|
|
115
139
|
letterSpacing: 0,
|
|
116
140
|
lineHeight: 22,
|
|
117
141
|
},
|
|
118
|
-
button: {
|
|
119
|
-
...systemWeights.regular,
|
|
120
|
-
fontSize: 14,
|
|
121
|
-
letterSpacing: 0,
|
|
122
|
-
lineHeight: 16,
|
|
123
|
-
},
|
|
124
|
-
caption: {
|
|
125
|
-
...systemWeights.regular,
|
|
126
|
-
fontSize: 12,
|
|
127
|
-
letterSpacing: 0,
|
|
128
|
-
lineHeight: 16,
|
|
129
|
-
},
|
|
130
|
-
overline: {
|
|
131
|
-
...systemWeights.regular,
|
|
132
|
-
fontSize: 12,
|
|
133
|
-
letterSpacing: 2,
|
|
134
|
-
lineHeight: 16,
|
|
135
|
-
},
|
|
136
|
-
headline6: {
|
|
137
|
-
...systemWeights.regular,
|
|
138
|
-
fontSize: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aAAa,EAAE,CAAC;gBAChB,UAAU,EAAE,EAAE;aACf;SACF;KACF;CACF,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -37,6 +37,7 @@ const Provider = ({ themes, breakpoints, initialThemeName, children, }) => {
|
|
|
37
37
|
foreground: createThemeValuesProxy(currentTheme.colors.foreground, breakpoints, deviceWidth, Platform.OS, lightDarkSelection),
|
|
38
38
|
border: createThemeValuesProxy(currentTheme.colors.border, breakpoints, deviceWidth, Platform.OS, lightDarkSelection),
|
|
39
39
|
},
|
|
40
|
+
typography: currentTheme.typography,
|
|
40
41
|
}), [currentTheme, deviceWidth, breakpoints, lightDarkSelection]);
|
|
41
42
|
React.useEffect(() => {
|
|
42
43
|
const listener = Dimensions.addEventListener("change", ({ window }) => setDeviceWidth(window.width));
|
|
@@ -47,8 +48,16 @@ const Provider = ({ themes, breakpoints, initialThemeName, children, }) => {
|
|
|
47
48
|
React.useEffect(() => {
|
|
48
49
|
const run = async () => {
|
|
49
50
|
const savedSelectedThemeName = await AsyncStorage.getItem(SAVED_SELECTED_THEME_KEY);
|
|
51
|
+
const themeExists = themes.some((t) => t.name === savedSelectedThemeName);
|
|
50
52
|
if (savedSelectedThemeName) {
|
|
51
|
-
|
|
53
|
+
if (themeExists) {
|
|
54
|
+
changeTheme(savedSelectedThemeName);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
AsyncStorage.removeItem(SAVED_SELECTED_THEME_KEY).catch((e) => {
|
|
58
|
+
console.warn("Failed to reset persisted selected theme", e);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
};
|
|
54
63
|
run();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../src/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,cAAc,C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IAC/B,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACjD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,GAGZ,EAAE;IACX,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACvD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAChB,SAAqC,EACrC,EAAE;IACF,OAAO,KAAK,CAAC,UAAU,CACrB,CAAC,KAA2B,EAAE,GAAmB,EAAE,EAAE;QACnD,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QACjD,OAAO,oBAAC,SAAS,OAAM,KAAe,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;IACrE,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type { Breakpoints, Theme, ValidatedTheme, ColorPalettes } from "./types";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Custom deepmerge function to skip merging of typography/text style objects.
|
|
4
|
+
*
|
|
5
|
+
* The theme object allows for special keys that trigger variability depending
|
|
6
|
+
* on platform, breakpoint, color mode, etc.
|
|
7
|
+
*
|
|
8
|
+
* Text style objects can break this logic when merged with other objects.
|
|
9
|
+
* For example, if you merge a standard text style object with another object that
|
|
10
|
+
* has variability through the special keys, you get an object with both special
|
|
11
|
+
* keys and the keys of the style object which breaks how the proxy is able to
|
|
12
|
+
* return the correct value.
|
|
13
|
+
*/
|
|
14
|
+
export default function createTheme({ theme, baseTheme, }: {
|
|
3
15
|
breakpoints: Breakpoints;
|
|
4
16
|
palettes: ColorPalettes;
|
|
5
17
|
theme: Theme;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import merge from "deepmerge";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Custom deepmerge function to skip merging of typography/text style objects.
|
|
4
|
+
*
|
|
5
|
+
* The theme object allows for special keys that trigger variability depending
|
|
6
|
+
* on platform, breakpoint, color mode, etc.
|
|
7
|
+
*
|
|
8
|
+
* Text style objects can break this logic when merged with other objects.
|
|
9
|
+
* For example, if you merge a standard text style object with another object that
|
|
10
|
+
* has variability through the special keys, you get an object with both special
|
|
11
|
+
* keys and the keys of the style object which breaks how the proxy is able to
|
|
12
|
+
* return the correct value.
|
|
13
|
+
*/
|
|
14
|
+
export default function createTheme({ theme, baseTheme, }) {
|
|
15
|
+
// validateBreakpoints(breakpoints);
|
|
16
|
+
// validatePalettes(palettes);
|
|
17
|
+
// validateTheme(theme);
|
|
7
18
|
let resultTheme = theme;
|
|
8
19
|
if (baseTheme) {
|
|
9
|
-
validateTheme(baseTheme);
|
|
20
|
+
//validateTheme(baseTheme);
|
|
10
21
|
resultTheme = merge(baseTheme, theme);
|
|
11
22
|
}
|
|
12
23
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.js","sourceRoot":"","sources":["../../../src/createTheme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createTheme.js","sourceRoot":"","sources":["../../../src/createTheme.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,WAAW,CAAC;AAE9B;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,KAAK,EACL,SAAS,GAMV;IACC,oCAAoC;IACpC,8BAA8B;IAC9B,wBAAwB;IAExB,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,IAAI,SAAS,EAAE;QACb,2BAA2B;QAC3B,WAAW,GAAG,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;KACvC;IAED,OAAO;QACL,GAAG,WAAW;QACd,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -13,30 +13,33 @@ export default function createThemeValuesProxy(value, breakpoints, deviceWidth,
|
|
|
13
13
|
return new Proxy(value, {
|
|
14
14
|
get: (target, key) => {
|
|
15
15
|
const currentValue = target[key];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const valueAsThemeValues = isObject(currentValue)
|
|
17
|
+
? currentValue
|
|
18
|
+
: undefined;
|
|
19
|
+
if (valueAsThemeValues) {
|
|
20
20
|
const platformKeys = ["ios", "android", "web", "macos", "windows"];
|
|
21
21
|
const breakpointKeys = Object.keys(breakpoints);
|
|
22
22
|
const lightDarkKeys = ["light", "dark"];
|
|
23
|
-
const keysType = getKeysType(
|
|
23
|
+
const keysType = getKeysType(valueAsThemeValues, platformKeys, breakpointKeys, lightDarkKeys);
|
|
24
24
|
if (keysType === "default") {
|
|
25
|
-
return createThemeValuesProxy(
|
|
25
|
+
return createThemeValuesProxy(valueAsThemeValues, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection);
|
|
26
26
|
}
|
|
27
27
|
else if (keysType === "platform") {
|
|
28
|
-
return getPlatformValue(
|
|
28
|
+
return getPlatformValue(valueAsThemeValues, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection);
|
|
29
29
|
}
|
|
30
30
|
else if (keysType === "breakpoint") {
|
|
31
|
-
return getBreakpointValue(
|
|
31
|
+
return getBreakpointValue(valueAsThemeValues, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection);
|
|
32
32
|
}
|
|
33
33
|
else if (keysType === "lightDark") {
|
|
34
|
-
return getLightDarkValue(
|
|
34
|
+
return getLightDarkValue(valueAsThemeValues, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
return undefined;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
else {
|
|
41
|
+
return currentValue;
|
|
42
|
+
}
|
|
40
43
|
},
|
|
41
44
|
set: () => {
|
|
42
45
|
throw new Error("Theme is read only, cannot be modified at runtime");
|
|
@@ -77,17 +80,20 @@ function allFalse(a, b, c, d) {
|
|
|
77
80
|
}
|
|
78
81
|
function getPlatformValue(value, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection) {
|
|
79
82
|
var _a;
|
|
80
|
-
const currentPlatformValue = (_a = value[devicePlatform]) !== null && _a !== void 0 ? _a : value.default;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
const currentPlatformValue = (_a = value === null || value === void 0 ? void 0 : value[devicePlatform]) !== null && _a !== void 0 ? _a : value === null || value === void 0 ? void 0 : value.default;
|
|
84
|
+
const valueAsThemeValues = isObject(currentPlatformValue)
|
|
85
|
+
? currentPlatformValue
|
|
86
|
+
: undefined;
|
|
87
|
+
if (valueAsThemeValues) {
|
|
88
|
+
return createThemeValuesProxy(valueAsThemeValues, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection);
|
|
83
89
|
}
|
|
84
90
|
else {
|
|
85
|
-
return
|
|
91
|
+
return currentPlatformValue;
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
function getBreakpointValue(value, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection) {
|
|
89
95
|
var _a;
|
|
90
|
-
const keysToBreakpointValue = Object.keys(value).map((key) => [key, breakpoints[key]]);
|
|
96
|
+
const keysToBreakpointValue = Object.keys(value !== null && value !== void 0 ? value : {}).map((key) => [key, breakpoints[key]]);
|
|
91
97
|
const orderedBreakpoints = keysToBreakpointValue.sort(([_, val]) => val);
|
|
92
98
|
let currentBreakpointKey = "";
|
|
93
99
|
for (const [breakpointKey, breakpointValue] of orderedBreakpoints) {
|
|
@@ -95,22 +101,28 @@ function getBreakpointValue(value, breakpoints, deviceWidth, devicePlatform, cur
|
|
|
95
101
|
currentBreakpointKey = breakpointKey;
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
|
-
const currentBreakpointValue = (_a = value[currentBreakpointKey]) !== null && _a !== void 0 ? _a : value.default;
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
const currentBreakpointValue = (_a = value === null || value === void 0 ? void 0 : value[currentBreakpointKey]) !== null && _a !== void 0 ? _a : value === null || value === void 0 ? void 0 : value.default;
|
|
105
|
+
const valueAsThemeValues = isObject(currentBreakpointKey)
|
|
106
|
+
? currentBreakpointKey
|
|
107
|
+
: undefined;
|
|
108
|
+
if (valueAsThemeValues) {
|
|
109
|
+
return createThemeValuesProxy(valueAsThemeValues, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection);
|
|
101
110
|
}
|
|
102
111
|
else {
|
|
103
|
-
return
|
|
112
|
+
return currentBreakpointValue;
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
function getLightDarkValue(value, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection) {
|
|
107
116
|
var _a;
|
|
108
|
-
const currentLightDarkValue = (_a = value[currentLightDarkSelection]) !== null && _a !== void 0 ? _a : value.default;
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
const currentLightDarkValue = (_a = value === null || value === void 0 ? void 0 : value[currentLightDarkSelection]) !== null && _a !== void 0 ? _a : value === null || value === void 0 ? void 0 : value.default;
|
|
118
|
+
const valueAsThemeValues = isObject(currentLightDarkSelection)
|
|
119
|
+
? currentLightDarkSelection
|
|
120
|
+
: undefined;
|
|
121
|
+
if (valueAsThemeValues) {
|
|
122
|
+
return createThemeValuesProxy(valueAsThemeValues, breakpoints, deviceWidth, devicePlatform, currentLightDarkSelection);
|
|
111
123
|
}
|
|
112
124
|
else {
|
|
113
|
-
return
|
|
125
|
+
return currentLightDarkValue;
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
128
|
//# sourceMappingURL=createThemeValuesProxy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createThemeValuesProxy.js","sourceRoot":"","sources":["../../../src/createThemeValuesProxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,KAA8B,EAC9B,WAAwB,EACxB,WAAmB,EACnB,cAAkC,EAClC,yBAA2C;IAE3C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;QACzC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE;QACtB,GAAG,EAAE,CACH,MAAmB,EACnB,GAAW,
|
|
1
|
+
{"version":3,"file":"createThemeValuesProxy.js","sourceRoot":"","sources":["../../../src/createThemeValuesProxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,KAA8B,EAC9B,WAAwB,EACxB,WAAmB,EACnB,cAAkC,EAClC,yBAA2C;IAE3C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;QACzC,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE;QACtB,GAAG,EAAE,CACH,MAAmB,EACnB,GAAW,EAC4C,EAAE;YACzD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAEjC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,YAAY,CAAC;gBAC/C,CAAC,CAAE,YAA4B;gBAC/B,CAAC,CAAC,SAAS,CAAC;YAEd,IAAI,kBAAkB,EAAE;gBACtB,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;gBACnE,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBAChD,MAAM,aAAa,GA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E,IAAI,WAAW,IAAI,eAAe,EAAE;YAClC,oBAAoB,GAAG,aAAa,CAAC;SACtC;KACF;IACD,MAAM,sBAAsB,GAC1B,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,oBAAoB,CAAC,mCAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC;IAClD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,oBAAoB,CAAC;QACvD,CAAC,CAAE,oBAAoC;QACvC,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,kBAAkB,EAAE;QACtB,OAAO,sBAAsB,CAC3B,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,cAAc,EACd,yBAAyB,CAC1B,CAAC;KACH;SAAM;QACL,OAAO,sBAAsB,CAAC;KAC/B;AACH,CAAC;AAED,SAAS,iBAAiB,CACxB,KAA8B,EAC9B,WAAwB,EACxB,WAAmB,EACnB,cAAkC,EAClC,yBAA2C;;IAE3C,MAAM,qBAAqB,GACzB,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,yBAAyB,CAAC,mCAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC;IACvD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,yBAAyB,CAAC;QAC5D,CAAC,CAAE,yBAAyC;QAC5C,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,kBAAkB,EAAE;QACtB,OAAO,sBAAsB,CAC3B,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,cAAc,EACd,yBAAyB,CAC1B,CAAC;KACH;SAAM;QACL,OAAO,qBAAqB,CAAC;KAC9B;AACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { TextStyle } from "react-native";
|
|
1
2
|
export declare type ThemeValues = {
|
|
2
|
-
[key: string]: string | number | ThemeValues;
|
|
3
|
+
[key: string]: string | number | TextStyle | ThemeValues;
|
|
3
4
|
};
|
|
4
5
|
export declare type Theme = {
|
|
5
6
|
name: string;
|
|
@@ -11,7 +12,19 @@ export declare type Theme = {
|
|
|
11
12
|
border?: ThemeValues;
|
|
12
13
|
};
|
|
13
14
|
typography: {
|
|
14
|
-
|
|
15
|
+
body1?: ThemeValues | TextStyle;
|
|
16
|
+
body2?: ThemeValues | TextStyle;
|
|
17
|
+
button?: ThemeValues | TextStyle;
|
|
18
|
+
caption?: ThemeValues | TextStyle;
|
|
19
|
+
headline1?: ThemeValues | TextStyle;
|
|
20
|
+
headline2?: ThemeValues | TextStyle;
|
|
21
|
+
headline3?: ThemeValues | TextStyle;
|
|
22
|
+
headline4?: ThemeValues | TextStyle;
|
|
23
|
+
headline5?: ThemeValues | TextStyle;
|
|
24
|
+
headline6?: ThemeValues | TextStyle;
|
|
25
|
+
overline?: ThemeValues | TextStyle;
|
|
26
|
+
subtitle1?: ThemeValues | TextStyle;
|
|
27
|
+
subtitle2?: ThemeValues | TextStyle;
|
|
15
28
|
};
|
|
16
29
|
};
|
|
17
30
|
export declare type ValidatedTheme = Theme & {
|
|
@@ -25,6 +38,21 @@ export declare type ReadTheme = Theme & {
|
|
|
25
38
|
foreground?: any;
|
|
26
39
|
border?: any;
|
|
27
40
|
};
|
|
41
|
+
typography: {
|
|
42
|
+
body1?: any;
|
|
43
|
+
body2?: any;
|
|
44
|
+
button?: any;
|
|
45
|
+
caption?: any;
|
|
46
|
+
headline1?: any;
|
|
47
|
+
headline2?: any;
|
|
48
|
+
headline3?: any;
|
|
49
|
+
headline4?: any;
|
|
50
|
+
headline5?: any;
|
|
51
|
+
headline6?: any;
|
|
52
|
+
overline?: any;
|
|
53
|
+
subtitle1?: any;
|
|
54
|
+
subtitle2?: any;
|
|
55
|
+
};
|
|
28
56
|
};
|
|
29
57
|
export declare type ColorPaletteValues = {
|
|
30
58
|
[key: string]: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { ColorPalettes, Breakpoints, Theme } from "./types";
|
|
1
|
+
import { ColorPalettes, Breakpoints, Theme, ThemeValues } from "./types";
|
|
2
2
|
export declare function validatePalettes(palettes: ColorPalettes): void;
|
|
3
3
|
export declare function validateBreakpoints(breakpoints: Breakpoints): void;
|
|
4
4
|
export declare function validateTheme(theme: Theme): void;
|
|
5
|
+
export declare function isTextStyleObject(value: any): boolean;
|
|
6
|
+
export declare function asThemeValuesObject(value: any): ThemeValues | null;
|
|
@@ -1,52 +1,17 @@
|
|
|
1
1
|
export function validatePalettes(palettes) {
|
|
2
|
-
|
|
3
|
-
if (typeof key !== "string") {
|
|
4
|
-
throw new Error(`Invalid palettes object, ${key} is not a string`);
|
|
5
|
-
}
|
|
6
|
-
for (const [innerKey, value] of Object.entries(palettes[key])) {
|
|
7
|
-
if (typeof innerKey !== "string") {
|
|
8
|
-
throw new Error(`Invalid palette color key, ${innerKey} is not a string`);
|
|
9
|
-
}
|
|
10
|
-
if (typeof value !== "string") {
|
|
11
|
-
throw new Error(`Invalid palette color value, ${value} is not a string`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
2
|
+
palettes;
|
|
15
3
|
}
|
|
16
4
|
export function validateBreakpoints(breakpoints) {
|
|
17
|
-
|
|
18
|
-
if (typeof key !== "string") {
|
|
19
|
-
throw new Error(`Invalid breakpoint key, ${key} is not a string`);
|
|
20
|
-
}
|
|
21
|
-
if (typeof value !== "number") {
|
|
22
|
-
throw new Error(`Invalid breakpoint value, ${value} is not a number`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
5
|
+
breakpoints;
|
|
25
6
|
}
|
|
26
7
|
export function validateTheme(theme) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (value === undefined || value === null) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
else if (typeof value === "object") {
|
|
39
|
-
validateThemeValues(value);
|
|
40
|
-
}
|
|
41
|
-
else if (typeof value !== "string" && typeof value !== "number") {
|
|
42
|
-
throw new Error(`Invalid theme value, ${value} is not a string, number, or object`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
validateThemeValues(theme.colors.branding);
|
|
47
|
-
validateThemeValues(theme.colors.text);
|
|
48
|
-
validateThemeValues(theme.colors.foreground);
|
|
49
|
-
validateThemeValues(theme.colors.background);
|
|
50
|
-
validateThemeValues(theme.colors.border);
|
|
8
|
+
theme;
|
|
9
|
+
}
|
|
10
|
+
export function isTextStyleObject(value) {
|
|
11
|
+
value;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
export function asThemeValuesObject(value) {
|
|
15
|
+
return value;
|
|
51
16
|
}
|
|
52
17
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/validators.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,QAAuB;IACtD,
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/validators.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,QAAuB;IACtD,QAAQ,CAAC;AACX,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,WAAwB;IAC1D,WAAW,CAAC;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,KAAK,CAAC;AACR,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAU;IAC1C,KAAK,CAAC;IACN,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAU;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC"}
|