-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import type { Meta, StoryObj } from '@storybook/react-native'; | ||
import React from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
|
||
import { Label } from 'smartway-react-native-ui'; | ||
|
||
const textInside = ` | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab quisquam, nulla | ||
earum ut porro distinctio autem deleniti laborum nisi ex ipsum nihil beatae | ||
facilis. Vel unde molestias quibusdam dolorem libero. | ||
`; | ||
|
||
export default { | ||
title: 'typography/Label', | ||
component: Label, | ||
argTypes: { | ||
token: { | ||
control: { type: 'radio' }, | ||
options: ['n1', 'n2'], | ||
}, | ||
}, | ||
decorators: [ | ||
(Story) => { | ||
const styles = StyleSheet.create({ | ||
container: { | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
flex: 1, | ||
}, | ||
}); | ||
return ( | ||
<View style={styles.container}> | ||
<Story /> | ||
</View> | ||
); | ||
}, | ||
], | ||
} as Meta<typeof Label>; | ||
|
||
type Story = StoryObj<typeof Label>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: textInside, | ||
}, | ||
}; | ||
Default.parameters = { noSafeArea: false }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { StyleProp, Text, TextStyle } from 'react-native'; | ||
import type { TextProps } from 'react-native-paper'; | ||
import { useTheme } from '../../styles/themes'; | ||
import { tokens } from '@zerogachis/smartway-design-token'; | ||
import { getFont } from './utils'; | ||
|
||
type LabelTypography = keyof typeof tokens.typography.label; | ||
|
||
export interface LabelProps extends TextProps<Text> { | ||
typography?: LabelTypography; | ||
} | ||
|
||
export const Label = ({ typography = 'n1', children, style, ...props }: LabelProps) => { | ||
const theme = useTheme(); | ||
|
||
const bodyStyle: StyleProp<TextStyle> = { | ||
color: theme.sw.color.neutral[800], | ||
fontSize: tokens.typography.label[typography]?.fontSize, | ||
fontFamily: getFont(tokens.typography.label[typography]), | ||
}; | ||
|
||
return ( | ||
<Text {...props} style={[bodyStyle, style]}> | ||
{children} | ||
</Text> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ export { | |
Tag, | ||
Divider, | ||
LineChart, | ||
Label, | ||
Badge, | ||
DateField, | ||
DateSelector, | ||
|