Skip to content

Commit 1d39c09

Browse files
committed
add text story
1 parent 24a4c31 commit 1d39c09

2 files changed

Lines changed: 165 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import {
2+
StyleSheet,
3+
View,
4+
} from "react-native"
5+
6+
import type {
7+
Meta,
8+
StoryFn,
9+
} from "@storybook/react-native"
10+
11+
import {
12+
Text,
13+
type TextProps,
14+
} from "@audira/carbon-react-native"
15+
16+
import {
17+
Spacing,
18+
} from "@audira/carbon-react-native-elements"
19+
20+
interface Props {
21+
children?: string,
22+
}
23+
24+
export default {
25+
title: "Components/Text/All Types",
26+
args: {
27+
children: "The quick brown fox jumps over the lazy dog",
28+
},
29+
argTypes: {
30+
children: {
31+
control: "text",
32+
},
33+
},
34+
} satisfies Meta<Props>
35+
36+
export const AllTypes: StoryFn<Props> = args => {
37+
return (
38+
<View
39+
style={ styleSheet.textsContainer }
40+
>
41+
<TextCompose type="body_01" { ...args }/>
42+
<TextCompose type="body_02" { ...args }/>
43+
<TextCompose type="body_compact_01" { ...args }/>
44+
<TextCompose type="body_compact_02" { ...args }/>
45+
<TextCompose type="code_01" { ...args }/>
46+
<TextCompose type="code_02" { ...args }/>
47+
<TextCompose type="heading_01" { ...args }/>
48+
<TextCompose type="heading_02" { ...args }/>
49+
<TextCompose type="heading_03" { ...args }/>
50+
<TextCompose type="heading_04" { ...args }/>
51+
<TextCompose type="heading_05" { ...args }/>
52+
<TextCompose type="heading_06" { ...args }/>
53+
<TextCompose type="heading_07" { ...args }/>
54+
<TextCompose type="heading_compact_01" { ...args }/>
55+
<TextCompose type="heading_compact_02" { ...args }/>
56+
<TextCompose type="helper_text_01" { ...args }/>
57+
<TextCompose type="helper_text_02" { ...args }/>
58+
<TextCompose type="label_01" { ...args }/>
59+
<TextCompose type="label_02" { ...args }/>
60+
<TextCompose type="legal_01" { ...args }/>
61+
<TextCompose type="legal_02" { ...args }/>
62+
</View>
63+
)
64+
}
65+
66+
const
67+
styleSheet =
68+
StyleSheet.create({
69+
textsContainer: {
70+
rowGap: Spacing.spacing_05,
71+
},
72+
})
73+
74+
function TextCompose({
75+
children,
76+
type,
77+
...props
78+
}: TextProps) {
79+
80+
return (
81+
<Text
82+
{ ...props }
83+
type={ type }
84+
>
85+
{ children } :: { `${type}` }
86+
</Text>
87+
)
88+
89+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import type {
2+
Meta,
3+
StoryFn,
4+
} from "@storybook/react-native"
5+
6+
import {
7+
Text as CarbonText,
8+
type TextProps,
9+
} from "@audira/carbon-react-native"
10+
11+
export default {
12+
title: "Components/Text",
13+
component: CarbonText,
14+
args: {
15+
type: "body_compact_02",
16+
italic: false,
17+
children: "The quick brown fox jumps over the lazy dog",
18+
},
19+
argTypes: {
20+
type: {
21+
control: "select",
22+
options: [
23+
"body_01",
24+
"body_02",
25+
"body_compact_01",
26+
"body_compact_02",
27+
"code_01",
28+
"code_02",
29+
"heading_01",
30+
"heading_02",
31+
"heading_03",
32+
"heading_04",
33+
"heading_05",
34+
"heading_06",
35+
"heading_07",
36+
"heading_compact_01",
37+
"heading_compact_02",
38+
"helper_text_01",
39+
"helper_text_02",
40+
"label_01",
41+
"label_02",
42+
"legal_01",
43+
"legal_02",
44+
] satisfies NonNullable<TextProps["type"]>[],
45+
},
46+
italic: {
47+
control: "boolean",
48+
},
49+
weight: {
50+
control: "select",
51+
options: [
52+
undefined,
53+
100,
54+
200,
55+
300,
56+
400,
57+
500,
58+
600,
59+
700,
60+
800,
61+
900,
62+
] satisfies TextProps["weight"][],
63+
},
64+
children: {
65+
control: "text",
66+
},
67+
},
68+
} satisfies Meta<TextProps>
69+
70+
export const Text: StoryFn<TextProps> = args => {
71+
return (
72+
<CarbonText
73+
{ ...args }
74+
/>
75+
)
76+
}

0 commit comments

Comments
 (0)