@workday/canvas-kit-docs 5.3.0 → 5.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/lib/specs.js +18 -232
- package/dist/es6/lib/specs.js +18 -232
- package/dist/mdx/COMPOUND_COMPONENTS.mdx +30 -31
- package/dist/mdx/react/button/button/Button.mdx +2 -27
- package/dist/mdx/react/button/button/examples/Primary.tsx +1 -10
- package/dist/mdx/react/button/button/examples/Secondary.tsx +1 -10
- package/dist/mdx/react/button/button/examples/Tertiary.tsx +1 -10
- package/dist/mdx/react/loading-animation/LoadingAnimation.mdx +5 -0
- package/dist/mdx/react/loading-animation/examples/RTL.tsx +16 -0
- package/dist/mdx/react/tabs/Tabs.mdx +5 -31
- package/dist/mdx/react/tabs/examples/DisabledTab.tsx +1 -1
- package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +13 -41
- package/dist/mdx/react/tabs/examples/HoistedModel.tsx +4 -4
- package/dist/mdx/react/tabs/examples/{NamedTabs.tsx → NamedKeys.tsx} +0 -0
- package/dist/mdx/react/tabs/examples/SinglePanel.tsx +1 -1
- package/dist/mdx/react/text-area/TextArea.mdx +1 -1
- package/dist/mdx/react/tooltip/Tooltip.mdx +8 -0
- package/dist/mdx/react/tooltip/examples/DelayedTooltip.tsx +16 -0
- package/package.json +3 -3
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +0 -554
- package/dist/mdx/labs-react/search-form/SearchForm.mdx +0 -64
- package/dist/mdx/labs-react/search-form/examples/Basic.tsx +0 -61
- package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +0 -72
- package/dist/mdx/labs-react/search-form/examples/Grow.tsx +0 -62
- package/dist/mdx/labs-react/search-form/examples/PropTables.splitProps.tsx +0 -4
- package/dist/mdx/labs-react/search-form/examples/RTL.tsx +0 -70
- package/dist/mdx/labs-react/search-form/examples/Theming.tsx +0 -64
- package/dist/mdx/labs-react/text-input/TextInput.mdx +0 -123
- package/dist/mdx/labs-react/text-input/examples/Alert.tsx +0 -46
- package/dist/mdx/labs-react/text-input/examples/Basic.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Error.tsx +0 -43
- package/dist/mdx/labs-react/text-input/examples/Grow.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/HiddenLabel.tsx +0 -17
- package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/LoginForm.tsx +0 -100
- package/dist/mdx/labs-react/text-input/examples/Password.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/RefForwarding.tsx +0 -27
- package/dist/mdx/labs-react/text-input/examples/Required.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +0 -51
- package/dist/mdx/labs-react/text-input/examples/ThemedError.tsx +0 -40
- package/dist/mdx/react/button/button/examples/PrimaryInverse.tsx +0 -14
- package/dist/mdx/react/button/button/examples/SecondaryInverse.tsx +0 -14
- package/dist/mdx/react/button/button/examples/TertiaryInverse.tsx +0 -14
- package/dist/mdx/react/tabs/examples/Icons.tsx +0 -36
- package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +0 -58
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {useFormik} from 'formik';
|
|
4
|
-
import * as yup from 'yup';
|
|
5
|
-
|
|
6
|
-
import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
|
|
7
|
-
import {HStack, VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
8
|
-
import {IconButton, PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
9
|
-
import {visibleIcon, invisibleIcon} from '@workday/canvas-system-icons-web';
|
|
10
|
-
import {useUniqueId} from '@workday/canvas-kit-react/common';
|
|
11
|
-
|
|
12
|
-
export default () => {
|
|
13
|
-
const passwordMinimum = 8;
|
|
14
|
-
const passwordHint = `Password should be of minimum ${passwordMinimum} characters length`;
|
|
15
|
-
const emailRequired = 'Email is required';
|
|
16
|
-
const passwordRequired = 'Password is required';
|
|
17
|
-
|
|
18
|
-
const validationSchema = yup.object({
|
|
19
|
-
email: yup
|
|
20
|
-
.string()
|
|
21
|
-
.email('Enter a valid email')
|
|
22
|
-
.required(emailRequired),
|
|
23
|
-
password: yup
|
|
24
|
-
.string()
|
|
25
|
-
.min(passwordMinimum, passwordHint)
|
|
26
|
-
.required(passwordRequired),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const passwordRef = React.useRef<HTMLInputElement>(null);
|
|
30
|
-
const [showPassword, setShowPassword] = React.useState(false);
|
|
31
|
-
const passwordId = useUniqueId();
|
|
32
|
-
|
|
33
|
-
const formik = useFormik({
|
|
34
|
-
initialValues: {
|
|
35
|
-
email: 'example@baz.com',
|
|
36
|
-
password: 'foobarbaz',
|
|
37
|
-
},
|
|
38
|
-
validationSchema: validationSchema,
|
|
39
|
-
onSubmit: values => {
|
|
40
|
-
passwordRef.current.type = 'password';
|
|
41
|
-
|
|
42
|
-
// Send data to server
|
|
43
|
-
setTimeout(() => {
|
|
44
|
-
alert(JSON.stringify(values, null, 2));
|
|
45
|
-
}, 0);
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<form onSubmit={formik.handleSubmit} action=".">
|
|
51
|
-
<VStack spacing="xs" alignItems="flex-start">
|
|
52
|
-
<TextInput isRequired={true} hasError={formik.touched.email && !!formik.errors.email}>
|
|
53
|
-
<TextInput.Label>Email</TextInput.Label>
|
|
54
|
-
<TextInput.Field
|
|
55
|
-
name="email"
|
|
56
|
-
autoComplete="username"
|
|
57
|
-
placeholder="yourName@example.com"
|
|
58
|
-
onChange={formik.handleChange}
|
|
59
|
-
onBlur={formik.handleBlur}
|
|
60
|
-
value={formik.values.email}
|
|
61
|
-
/>
|
|
62
|
-
<TextInput.Hint>{formik.touched.email && formik.errors.email}</TextInput.Hint>
|
|
63
|
-
</TextInput>
|
|
64
|
-
<TextInput
|
|
65
|
-
inputId={passwordId}
|
|
66
|
-
hasError={formik.touched.password && !!formik.errors.password}
|
|
67
|
-
isRequired={true}
|
|
68
|
-
>
|
|
69
|
-
<TextInput.Label>Password</TextInput.Label>
|
|
70
|
-
<HStack spacing="xxs">
|
|
71
|
-
<TextInput.Field
|
|
72
|
-
type={showPassword ? 'text' : 'password'}
|
|
73
|
-
name="password"
|
|
74
|
-
autoComplete="current-password"
|
|
75
|
-
ref={passwordRef}
|
|
76
|
-
onChange={formik.handleChange}
|
|
77
|
-
onBlur={formik.handleBlur}
|
|
78
|
-
value={formik.values.password}
|
|
79
|
-
/>
|
|
80
|
-
<IconButton
|
|
81
|
-
type="button"
|
|
82
|
-
icon={showPassword ? invisibleIcon : visibleIcon}
|
|
83
|
-
aria-label={showPassword ? 'Hide Password' : 'Show Password'}
|
|
84
|
-
aria-controls={passwordId}
|
|
85
|
-
onClick={() => {
|
|
86
|
-
setShowPassword(state => !state);
|
|
87
|
-
passwordRef.current.focus();
|
|
88
|
-
}}
|
|
89
|
-
/>
|
|
90
|
-
</HStack>
|
|
91
|
-
<TextInput.Hint>
|
|
92
|
-
{(formik.touched.password && formik.errors.password) || passwordHint}
|
|
93
|
-
</TextInput.Hint>
|
|
94
|
-
</TextInput>
|
|
95
|
-
|
|
96
|
-
<PrimaryButton type="submit">Submit</PrimaryButton>
|
|
97
|
-
</VStack>
|
|
98
|
-
</form>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
|
|
3
|
-
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
4
|
-
|
|
5
|
-
export default () => {
|
|
6
|
-
const [value, setValue] = React.useState('SuperSecret1');
|
|
7
|
-
|
|
8
|
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
9
|
-
setValue(event.target.value);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<VStack spacing="xxxs" alignItems="flex-start">
|
|
14
|
-
<TextInput>
|
|
15
|
-
<TextInput.Label>Password</TextInput.Label>
|
|
16
|
-
<TextInput.Field onChange={handleChange} value={value} type="password" />
|
|
17
|
-
</TextInput>
|
|
18
|
-
</VStack>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
|
|
3
|
-
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
4
|
-
|
|
5
|
-
export default () => {
|
|
6
|
-
const [value, setValue] = React.useState('');
|
|
7
|
-
|
|
8
|
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
9
|
-
setValue(event.target.value);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<VStack spacing="xxxs" alignItems="flex-start">
|
|
14
|
-
<TextInput>
|
|
15
|
-
<TextInput.Label>Email</TextInput.Label>
|
|
16
|
-
<TextInput.Field onChange={handleChange} value={value} placeholder="user@email.com" />
|
|
17
|
-
</TextInput>
|
|
18
|
-
</VStack>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
|
|
3
|
-
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
4
|
-
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
5
|
-
|
|
6
|
-
export default () => {
|
|
7
|
-
const [value, setValue] = React.useState('');
|
|
8
|
-
const ref = React.useRef(null);
|
|
9
|
-
|
|
10
|
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
11
|
-
setValue(event.target.value);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const handleClick = () => {
|
|
15
|
-
ref.current.focus();
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<VStack spacing="xxxs" alignItems="flex-start">
|
|
20
|
-
<TextInput>
|
|
21
|
-
<TextInput.Label>Email</TextInput.Label>
|
|
22
|
-
<TextInput.Field onChange={handleChange} value={value} ref={ref} />
|
|
23
|
-
</TextInput>
|
|
24
|
-
<PrimaryButton onClick={handleClick}>Focus Text Input</PrimaryButton>
|
|
25
|
-
</VStack>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
|
|
3
|
-
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
4
|
-
|
|
5
|
-
export default () => {
|
|
6
|
-
const [value, setValue] = React.useState('');
|
|
7
|
-
|
|
8
|
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
9
|
-
setValue(event.target.value);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<VStack spacing="xxxs" alignItems="flex-start">
|
|
14
|
-
<TextInput isRequired={true}>
|
|
15
|
-
<TextInput.Label>Email</TextInput.Label>
|
|
16
|
-
<TextInput.Field onChange={handleChange} value={value} />
|
|
17
|
-
</TextInput>
|
|
18
|
-
</VStack>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
|
|
3
|
-
import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
|
|
4
|
-
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
-
import {CanvasProvider, PartialEmotionCanvasTheme, styled} from '@workday/canvas-kit-react/common';
|
|
6
|
-
import {colors, CSSProperties, space} from '@workday/canvas-kit-react/tokens';
|
|
7
|
-
|
|
8
|
-
export default () => {
|
|
9
|
-
const theme: PartialEmotionCanvasTheme = {
|
|
10
|
-
canvas: {
|
|
11
|
-
palette: {
|
|
12
|
-
common: {
|
|
13
|
-
focusOutline: colors.grapeSoda300,
|
|
14
|
-
},
|
|
15
|
-
alert: {
|
|
16
|
-
main: colors.kiwi500,
|
|
17
|
-
darkest: colors.kiwi600,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
return (
|
|
23
|
-
<CanvasProvider theme={theme}>
|
|
24
|
-
<AlertInput />
|
|
25
|
-
</CanvasProvider>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const StyledField = styled(TextInput.Field)<{alertStyles?: CSSProperties}>(
|
|
30
|
-
({alertStyles}) => alertStyles
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const AlertInput = () => {
|
|
34
|
-
const [value, setValue] = React.useState('invalid@email');
|
|
35
|
-
|
|
36
|
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
37
|
-
setValue(event.target.value);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const alertStyles = useThemedRing('alert');
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<VStack spacing="xxxs" alignItems="flex-start">
|
|
44
|
-
<TextInput>
|
|
45
|
-
<TextInput.Label>Email</TextInput.Label>
|
|
46
|
-
<StyledField alertStyles={alertStyles} onChange={handleChange} value={value} />
|
|
47
|
-
<TextInput.Hint paddingTop={space.xxs}>Please enter a valid email.</TextInput.Hint>
|
|
48
|
-
</TextInput>
|
|
49
|
-
</VStack>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
|
|
3
|
-
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
4
|
-
import {CanvasProvider, PartialEmotionCanvasTheme} from '@workday/canvas-kit-react/common';
|
|
5
|
-
import {colors, space} from '@workday/canvas-kit-react/tokens';
|
|
6
|
-
|
|
7
|
-
export default () => {
|
|
8
|
-
const [value, setValue] = React.useState('');
|
|
9
|
-
|
|
10
|
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
11
|
-
setValue(event.target.value);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const theme: PartialEmotionCanvasTheme = {
|
|
15
|
-
canvas: {
|
|
16
|
-
palette: {
|
|
17
|
-
common: {
|
|
18
|
-
focusOutline: colors.grapeSoda300,
|
|
19
|
-
},
|
|
20
|
-
error: {
|
|
21
|
-
main: colors.islandPunch400,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<CanvasProvider theme={theme}>
|
|
29
|
-
<VStack spacing="xxxs" alignItems="flex-start">
|
|
30
|
-
<TextInput hasError={!value} isRequired={true}>
|
|
31
|
-
<TextInput.Label>Email</TextInput.Label>
|
|
32
|
-
<TextInput.Field onChange={handleChange} value={value} />
|
|
33
|
-
<TextInput.Hint paddingTop={space.xxs}>
|
|
34
|
-
{!value && 'Please enter an email.'}
|
|
35
|
-
</TextInput.Hint>
|
|
36
|
-
</TextInput>
|
|
37
|
-
</VStack>
|
|
38
|
-
</CanvasProvider>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
-
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
|
-
|
|
7
|
-
export default () => (
|
|
8
|
-
<HStack spacing="s" backgroundColor="blueberry400" padding="s">
|
|
9
|
-
<PrimaryButton variant="inverse">Primary</PrimaryButton>
|
|
10
|
-
<PrimaryButton icon={plusIcon} iconPosition="right" variant="inverse">
|
|
11
|
-
Primary
|
|
12
|
-
</PrimaryButton>
|
|
13
|
-
</HStack>
|
|
14
|
-
);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
-
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
|
-
|
|
7
|
-
export default () => (
|
|
8
|
-
<HStack spacing="s" backgroundColor="blueberry400" padding="s">
|
|
9
|
-
<SecondaryButton variant="inverse">Secondary</SecondaryButton>
|
|
10
|
-
<SecondaryButton icon={plusIcon} iconPosition="right" variant="inverse">
|
|
11
|
-
Secondary
|
|
12
|
-
</SecondaryButton>
|
|
13
|
-
</HStack>
|
|
14
|
-
);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
-
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
|
-
|
|
7
|
-
export default () => (
|
|
8
|
-
<HStack spacing="s" backgroundColor="blueberry400" padding="s">
|
|
9
|
-
<TertiaryButton variant="inverse">Tertiary</TertiaryButton>
|
|
10
|
-
<TertiaryButton icon={plusIcon} iconPosition="right" variant="inverse">
|
|
11
|
-
Tertiary
|
|
12
|
-
</TertiaryButton>
|
|
13
|
-
</HStack>
|
|
14
|
-
);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {space} from '@workday/canvas-kit-react/tokens';
|
|
4
|
-
import {starIcon, searchIcon, selectIcon, shareIcon} from '@workday/canvas-system-icons-web';
|
|
5
|
-
import {Tabs} from '@workday/canvas-kit-react/tabs';
|
|
6
|
-
|
|
7
|
-
export default () => {
|
|
8
|
-
return (
|
|
9
|
-
<Tabs>
|
|
10
|
-
<Tabs.List>
|
|
11
|
-
<Tabs.Item hasIcon>
|
|
12
|
-
<Tabs.Item.Icon icon={starIcon} />
|
|
13
|
-
<Tabs.Item.Text>First Tab</Tabs.Item.Text>
|
|
14
|
-
</Tabs.Item>
|
|
15
|
-
<Tabs.Item hasIcon>
|
|
16
|
-
<Tabs.Item.Icon icon={searchIcon} />
|
|
17
|
-
<Tabs.Item.Text>Second Tab</Tabs.Item.Text>
|
|
18
|
-
</Tabs.Item>
|
|
19
|
-
<Tabs.Item hasIcon>
|
|
20
|
-
<Tabs.Item.Icon icon={selectIcon} />
|
|
21
|
-
<Tabs.Item.Text>Third Tab</Tabs.Item.Text>
|
|
22
|
-
</Tabs.Item>
|
|
23
|
-
<Tabs.Item hasIcon>
|
|
24
|
-
<Tabs.Item.Icon icon={shareIcon} />
|
|
25
|
-
<Tabs.Item.Text>Fourth Tab</Tabs.Item.Text>
|
|
26
|
-
</Tabs.Item>
|
|
27
|
-
</Tabs.List>
|
|
28
|
-
<div style={{marginTop: space.m}}>
|
|
29
|
-
<Tabs.Panel>Contents of First Tab</Tabs.Panel>
|
|
30
|
-
<Tabs.Panel>Contents of Second Tab</Tabs.Panel>
|
|
31
|
-
<Tabs.Panel>Contents of Third Tab</Tabs.Panel>
|
|
32
|
-
<Tabs.Panel>Contents of Fourth Tab</Tabs.Panel>
|
|
33
|
-
</div>
|
|
34
|
-
</Tabs>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {Tabs, useTabsModel} from '@workday/canvas-kit-react/tabs';
|
|
4
|
-
import {HStack} from '@workday/canvas-kit-labs-react';
|
|
5
|
-
import {SecondaryButton} from '../../../button';
|
|
6
|
-
|
|
7
|
-
type MyTabItem = {
|
|
8
|
-
id: string;
|
|
9
|
-
text: React.ReactNode;
|
|
10
|
-
contents: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default () => {
|
|
14
|
-
const [items] = React.useState<MyTabItem[]>([
|
|
15
|
-
{id: 'first', text: 'First Tab', contents: 'Contents of First Tab'},
|
|
16
|
-
{id: 'second', text: 'Second Tab', contents: 'Contents of Second Tab'},
|
|
17
|
-
{id: 'third', text: 'Third Tab', contents: 'Contents of Third Tab'},
|
|
18
|
-
{id: 'fourth', text: 'Fourth Tab', contents: 'Contents of Fourth Tab'},
|
|
19
|
-
{id: 'fifth', text: 'Fifth Tab', contents: 'Contents of Fifth Tab'},
|
|
20
|
-
{id: 'sixth', text: 'Sixth Tab', contents: 'Contents of Sixth Tab'},
|
|
21
|
-
{id: 'seventh', text: 'Seventh Tab', contents: 'Contents of Seventh Tab'},
|
|
22
|
-
]);
|
|
23
|
-
const model = useTabsModel({
|
|
24
|
-
items,
|
|
25
|
-
});
|
|
26
|
-
const [containerWidth, setContainerWidth] = React.useState('100%');
|
|
27
|
-
return (
|
|
28
|
-
<div style={{width: containerWidth}}>
|
|
29
|
-
<Tabs model={model}>
|
|
30
|
-
<Tabs.List overflowButton={<Tabs.OverflowButton>More</Tabs.OverflowButton>}>
|
|
31
|
-
{(item: MyTabItem) => <Tabs.Item name={item.id}>{item.text}</Tabs.Item>}
|
|
32
|
-
</Tabs.List>
|
|
33
|
-
<Tabs.Menu.Popper>
|
|
34
|
-
<Tabs.Menu.Card maxWidth={300} maxHeight={200}>
|
|
35
|
-
<Tabs.Menu.List>
|
|
36
|
-
{(item: MyTabItem) => <Tabs.Menu.Item name={item.id}>{item.text}</Tabs.Menu.Item>}
|
|
37
|
-
</Tabs.Menu.List>
|
|
38
|
-
</Tabs.Menu.Card>
|
|
39
|
-
</Tabs.Menu.Popper>
|
|
40
|
-
<Tabs.Panels>
|
|
41
|
-
{(item: MyTabItem) => (
|
|
42
|
-
<Tabs.Panel marginTop="m" name={item.id}>
|
|
43
|
-
{item.contents}
|
|
44
|
-
</Tabs.Panel>
|
|
45
|
-
)}
|
|
46
|
-
</Tabs.Panels>
|
|
47
|
-
</Tabs>
|
|
48
|
-
<hr />
|
|
49
|
-
<h4>Change tab container size</h4>
|
|
50
|
-
<HStack spacing="xs">
|
|
51
|
-
<SecondaryButton onClick={() => setContainerWidth('100%')}>100%</SecondaryButton>
|
|
52
|
-
<SecondaryButton onClick={() => setContainerWidth('500px')}>500px</SecondaryButton>
|
|
53
|
-
<SecondaryButton onClick={() => setContainerWidth('235px')}>235px</SecondaryButton>
|
|
54
|
-
<SecondaryButton onClick={() => setContainerWidth('150px')}>150px</SecondaryButton>
|
|
55
|
-
</HStack>
|
|
56
|
-
</div>
|
|
57
|
-
);
|
|
58
|
-
};
|