$ yarn storybook
- Storyboard: Add storybook example for every ui components.
- Hooks: Replace class component by functional component with
React.memo. - useMemoStyle: Use
useMemoStyleor other memorized methods to improve performance. - Remove T: Remove the
Tprefix of each component props. - Interface: Replace the
typedefinition of each component props byinterface. - Renderer: Separate logic and pure renderer.
| Storybook | Hooks | useMemoStyle | Remove T | Interface | Renderer | |
|---|---|---|---|---|---|---|
| Alert | - | ✔️ | - | ✔️ | ✔️ | - |
| Badge | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| Button | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| Card | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| Flex | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | - |
| HeaderButtons | ✔️ | ✔️ | ||||
| KeyboardAvoidingView | App Only | ✔️ | - | ✔️ | ✔️ | - |
| Image | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| InputSpinner | ✔️ | ✔️ | ||||
| List | ✔️ | ✔️ | ✔️ | |||
| ListItem | ✔️ | ✔️ | ✔️ | |||
| LoadingSpinner | ✔️ | ✔️ | ✔️ | |||
| Modal | ✔️ | |||||
| Rating | ✔️ | ✔️ | ✔️ | |||
| ReadMore | ✔️ | ✔️ | ✔️ | |||
| Screen | - | ✔️ | ✔️ | ✔️ | ✔️ | |
| SearchBar | ✔️ | ✔️ | ✔️ | ✔️ | ||
| Separator | ✔️ | ✔️ | ✔️ | |||
| Stack | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | - |
| Text | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| TextInput | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
| Toolbar | ✔️ | ✔️ | ✔️ |
DON'T use defaultProps for any UI Component. It will break the overrides effect.
overrides should be something like this
const overrides = {
Badge: {
default: {
props: {
color: palette.primaryColor,
},
styles: StyleSheet.create({
text: {
color: 'white',
},
}),
},
slim: {
styles: StyleSheet.create({
badge: {
...someProps,
},
text: {
fontSize: 13,
},
}),
},
},
Button: {
...someProps,
},
Card: {
...
},
...
}
check /storybook/theme/light/overrides.ts for example
make sure your override object is "as const" literal typed
import { ExtractVariantKeys } from '@qubic-js/react-native-cask-ui-theme';
const overrides = {...} as const;
type ComponentVariantKeys = ExtractVariantKeys<overrides>;
if overrides is a function, make sure to ReturnType<typeof overrides>
const getOverrides = (palette) => {...} as const;
type ComponentVariantKeys = ExtractVariantKeys<ReturnType<typeof getOverrides>>;
create a theme.d.ts
declare module '@qubic-js/react-native-cask-ui-theme' {
interface ComponentVariants extends ComponentVariantKeys {}
}