Skip to content

Commit 1e21e1d

Browse files
committed
docs(tabs-primitive): add usage guidelines
1 parent a9045e7 commit 1e21e1d

File tree

3 files changed

+585
-0
lines changed

3 files changed

+585
-0
lines changed

packages/paste-website/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
"@twilio-paste/style-props": "^1.8.6",
6565
"@twilio-paste/styling-library": "^0.1.4",
6666
"@twilio-paste/table": "^0.1.5",
67+
"@twilio-paste/tabs-primitive": "^0.1.9",
68+
"@twilio-paste/tabs":"^0.3.16",
6769
"@twilio-paste/text": "^2.3.13",
6870
"@twilio-paste/textarea": "^1.1.7",
6971
"@twilio-paste/theme": "^3.2.27",
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
export const horizontalExample = `
2+
const HorizontalExample = () => {
3+
const tab = useTabPrimitiveState();
4+
return (
5+
<>
6+
<TabPrimitiveList {...tab} aria-label="My tabs">
7+
<TabPrimitive {...tab}>
8+
Tab 1
9+
</TabPrimitive>
10+
<TabPrimitive {...tab} disabled>
11+
Tab 2 (disabled)
12+
</TabPrimitive>
13+
<TabPrimitive {...tab}>
14+
Tab 3
15+
</TabPrimitive>
16+
</TabPrimitiveList>
17+
<TabPrimitivePanel {...tab}>Tab 1</TabPrimitivePanel>
18+
<TabPrimitivePanel {...tab}>Tab 2</TabPrimitivePanel>
19+
<TabPrimitivePanel {...tab}>Tab 3</TabPrimitivePanel>
20+
</>
21+
)
22+
};
23+
24+
render(
25+
<HorizontalExample />
26+
)
27+
`.trim();
28+
29+
export const verticalExample = `
30+
const VerticalExample = () => {
31+
const tab = useTabPrimitiveState({orientation: 'vertical'});
32+
return (
33+
<Stack orientation="horizontal" spacing="space40">
34+
<Box>
35+
<TabPrimitiveList {...tab} aria-label="My tabs">
36+
<Stack orientation="vertical" spacing="space20">
37+
<TabPrimitive {...tab}>
38+
Tab 1
39+
</TabPrimitive>
40+
<TabPrimitive {...tab}>
41+
Tab 2
42+
</TabPrimitive>
43+
<TabPrimitive {...tab}>
44+
Tab 3
45+
</TabPrimitive>
46+
</Stack>
47+
</TabPrimitiveList>
48+
</Box>
49+
<Box>
50+
<TabPrimitivePanel {...tab}>Tab 1</TabPrimitivePanel>
51+
<TabPrimitivePanel {...tab}>Tab 2</TabPrimitivePanel>
52+
<TabPrimitivePanel {...tab}>Tab 3</TabPrimitivePanel>
53+
</Box>
54+
</Stack>
55+
)
56+
};
57+
render(
58+
<VerticalExample />
59+
)
60+
`.trim();
61+
62+
export const styledExample = `
63+
const CustomTab = React.forwardRef((props, ref) => (
64+
<Box
65+
as="div"
66+
ref={ref}
67+
borderBottomColor="transparent"
68+
borderRadius="borderRadius0"
69+
borderBottomStyle="solid"
70+
borderBottomWidth="borderWidth20"
71+
cursor="pointer"
72+
padding="space20"
73+
outline="none"
74+
_selected={{
75+
borderColor:"colorBorderPrimary"
76+
}}
77+
_focus={{
78+
textDecoration: 'underline'
79+
}}
80+
_disabled={{
81+
color: 'colorTextWeaker'
82+
}}
83+
{...props}
84+
/>
85+
));
86+
const StyledExample = () => {
87+
const tab = useTabPrimitiveState();
88+
return (
89+
<>
90+
<TabPrimitiveList {...tab} aria-label="My tabs">
91+
<Stack orientation="horizontal" spacing="space20">
92+
<TabPrimitive {...tab} as={CustomTab}>
93+
Tab 1
94+
</TabPrimitive>
95+
<TabPrimitive {...tab} disabled as={CustomTab}>
96+
Tab 2
97+
</TabPrimitive>
98+
<TabPrimitive {...tab} as={CustomTab}>
99+
Tab 3
100+
</TabPrimitive>
101+
</Stack>
102+
</TabPrimitiveList>
103+
<TabPrimitivePanel {...tab}>Tab 1</TabPrimitivePanel>
104+
<TabPrimitivePanel {...tab}>Tab 2</TabPrimitivePanel>
105+
<TabPrimitivePanel {...tab}>Tab 3</TabPrimitivePanel>
106+
</>
107+
)
108+
};
109+
render(
110+
<StyledExample />
111+
)
112+
`.trim();

0 commit comments

Comments
 (0)