@audira/carbon-react-native
Version:
Build React Native apps with component and shared patterns using Carbon
44 lines • 1.6 kB
TypeScript
import { type ImageStyle, type TextStyle, type ViewStyle } from 'react-native';
import { type BreakpointToken } from '@audira/carbon-react-native-elements';
type Style = ViewStyle | TextStyle | ImageStyle;
type StyleBreakpoint = Partial<Record<BreakpointToken, Omit<ViewStyle | TextStyle | ImageStyle, (typeof colorStyleProps)[number]>>>;
/**
* Create style sheet to help using color token of current color scheme and current breakpoint declaratively.
* It makes your code way more shorter which doesn't need to create conditional of current color scheme or current breakpoint in the style prop implementation
*
* @example
* ```tsx
* import {
* View,
* } from 'react-native'
*
* import {
* StyleSheet,
* } from '@audira/carbon-react-native'
*
* export function Component({ children }) {
* return (
* <View style={ style.foo }>
* { children }
* <View>
* )
* }
*
* const style = StyleSheet.create({
* foo: {
* backgroundColor: StyleSheet.color.background_inverse,
* // it will be resolved to the `background_inverse` of current color scheme
*
* [StyleSheet.breakpoint.medium]: {
* flexDirection: 'row',
* // this style will has row direction of flex box
* // for screen that equal and larger than the medium breakpoint
* },
* },
* })
* ```
*/
export declare function create<Styles extends Record<string, Style | StyleBreakpoint> = Record<string, Style | StyleBreakpoint>>(styles: Styles): Styles;
declare const colorStyleProps: ((keyof ViewStyle) | (keyof TextStyle) | (keyof ImageStyle))[];
export {};
//# sourceMappingURL=create.d.ts.map