@razorpay/blade
Version:
The Design System that powers Razorpay
14 lines (11 loc) • 1.76 kB
JavaScript
import 'react-native';
import { useBreakpoint } from '../../utils/useBreakpoint/useBreakpoint.js';
import { useColorScheme } from '../../utils/useColorScheme/useColorScheme.js';
import 'react';
import { toTitleCase } from '../../utils/toTitleCase/toTitleCase.js';
import './useTheme.js';
import { colorSchemeNamesInput } from '../../tokens/theme/theme.js';
import { throwBladeError } from '../../utils/logger/logger.js';
var useBladeProvider=function useBladeProvider(_ref){var themeTokens=_ref.themeTokens,initialColorScheme=_ref.initialColorScheme;if(__DEV__){if(!themeTokens){throwBladeError({message:`Expected valid themeTokens of type ThemeTokens to be passed but found ${typeof themeTokens}`,moduleName:'BladeProvider'});}if(initialColorScheme&&!colorSchemeNamesInput.includes(initialColorScheme)){throwBladeError({message:`Expected color scheme to be one of [${colorSchemeNamesInput.toString()}] but received ${initialColorScheme}`,moduleName:'BladeProvider'});}}var _useColorScheme=useColorScheme(initialColorScheme),colorScheme=_useColorScheme.colorScheme,setColorScheme=_useColorScheme.setColorScheme;var _useBreakpoint=useBreakpoint({breakpoints:themeTokens.breakpoints}),matchedDeviceType=_useBreakpoint.matchedDeviceType;var onColorMode=`on${toTitleCase(colorScheme)}`;var onDeviceType=`on${toTitleCase(matchedDeviceType)}`;var theme=Object.assign({},themeTokens,{colors:themeTokens.colors[onColorMode],elevation:themeTokens.elevation[onColorMode],typography:themeTokens.typography[onDeviceType]});var themeContextValue={theme:theme,colorScheme:colorScheme,setColorScheme:setColorScheme,platform:onDeviceType};return {themeContextValue:themeContextValue,theme:theme};};
export { useBladeProvider };
//# sourceMappingURL=useBladeProvider.js.map