@workday/canvas-kit-docs 6.0.0-alpha.0-next.33 → 6.0.0-alpha.0-next.39
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 +224 -2
- package/dist/es6/lib/specs.js +224 -2
- package/dist/mdx/5.0-MIGRATION-GUIDE.mdx +81 -7
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +18 -12
- package/dist/mdx/7.0-MIGRATION-GUIDE.mdx +33 -0
- package/dist/mdx/preview-react/form-field/FormField.mdx +27 -0
- package/dist/mdx/preview-react/form-field/examples/Custom.tsx +57 -0
- package/dist/mdx/preview-react/text-area/TextArea.mdx +122 -0
- package/dist/mdx/preview-react/text-area/examples/Alert.tsx +31 -0
- package/dist/mdx/preview-react/text-area/examples/Basic.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/Disabled.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/Error.tsx +40 -0
- package/dist/mdx/preview-react/text-area/examples/Grow.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +20 -0
- package/dist/mdx/preview-react/text-area/examples/LabelPositionHorizontal.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/LabelPositionVertical.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/Placeholder.tsx +21 -0
- package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +28 -0
- package/dist/mdx/preview-react/text-area/examples/Required.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/ResizeConstraints.tsx +22 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/TextInput.mdx +40 -18
- package/dist/mdx/preview-react/text-input/examples/Alert.tsx +40 -0
- package/dist/mdx/{labs-react/text-input/examples/HiddenLabel.tsx → preview-react/text-input/examples/Basic.tsx} +3 -3
- package/dist/mdx/preview-react/text-input/examples/Disabled.tsx +17 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/Error.tsx +6 -9
- package/dist/mdx/preview-react/text-input/examples/Grow.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +20 -0
- package/dist/mdx/preview-react/text-input/examples/LabelPositionHorizontal.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/LabelPositionVertical.tsx +17 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/LoginForm.tsx +10 -5
- package/dist/mdx/preview-react/text-input/examples/Password.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/Placeholder.tsx +17 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/RefForwarding.tsx +7 -6
- package/dist/mdx/preview-react/text-input/examples/Required.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +46 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/ThemedError.tsx +8 -11
- package/dist/mdx/react/_examples/GlobalHeader.mdx +9 -0
- package/dist/mdx/react/_examples/PageHeader.mdx +8 -0
- package/dist/mdx/react/_examples/examples/GlobalHeader.tsx +66 -0
- package/dist/mdx/react/_examples/examples/PageHeader.tsx +63 -0
- package/dist/mdx/react/banner/Banner.mdx +203 -19
- package/dist/mdx/react/banner/PropTables.splitprops.tsx +39 -0
- package/dist/mdx/react/banner/examples/ActionText.tsx +8 -1
- package/dist/mdx/react/banner/examples/Basic.tsx +8 -1
- package/dist/mdx/react/banner/examples/Error.tsx +8 -1
- package/dist/mdx/react/banner/examples/RefForwarding.tsx +25 -0
- package/dist/mdx/react/banner/examples/Sticky.tsx +15 -7
- package/dist/mdx/react/banner/examples/StickyAnimation.tsx +62 -0
- package/dist/mdx/react/banner/examples/StickyRTL.tsx +38 -0
- package/dist/mdx/react/banner/examples/ThemedAlert.tsx +28 -0
- package/dist/mdx/react/banner/examples/ThemedError.tsx +29 -0
- package/dist/mdx/react/button/button/examples/Primary.tsx +4 -3
- 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/examples/DynamicTabs.tsx +50 -34
- package/dist/mdx/react/tooltip/Tooltip.mdx +8 -0
- package/dist/mdx/react/tooltip/examples/DelayedTooltip.tsx +16 -0
- package/package.json +5 -4
- 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/Grow.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +0 -20
- 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/Required.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +0 -51
|
@@ -4,17 +4,28 @@ import {space} from '@workday/canvas-kit-react/tokens';
|
|
|
4
4
|
import {Tabs, useTabsModel, TabsModel} from '@workday/canvas-kit-react/tabs';
|
|
5
5
|
import {SelectionModel} from '../../lib/selection';
|
|
6
6
|
|
|
7
|
+
type Tab = {
|
|
8
|
+
tab: string;
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
export default () => {
|
|
8
|
-
const [tabs, setTabs] = React.useState([
|
|
13
|
+
const [tabs, setTabs] = React.useState<Tab[]>([
|
|
9
14
|
{tab: 'Tab 1', id: 'tab-1'},
|
|
10
15
|
{tab: 'Tab 2', id: 'tab-2'},
|
|
11
16
|
{tab: 'Tab 3', id: 'tab-3'},
|
|
17
|
+
{tab: 'Add Tab', id: 'add'},
|
|
12
18
|
]);
|
|
13
|
-
const addedRef = React.useRef(tabs.length);
|
|
19
|
+
const addedRef = React.useRef(tabs.length - 1);
|
|
14
20
|
const model = useTabsModel({
|
|
15
|
-
|
|
21
|
+
items: tabs,
|
|
22
|
+
shouldSelect: ({data}) => data.id !== 'add',
|
|
16
23
|
});
|
|
17
24
|
|
|
25
|
+
// A ref of the model for the render functions to work around the caching done to lists
|
|
26
|
+
const modelRef = React.useRef(model);
|
|
27
|
+
modelRef.current = model;
|
|
28
|
+
|
|
18
29
|
/**
|
|
19
30
|
* Helper function that should be called when an item is programmatically removed. The following
|
|
20
31
|
* side effects depend on state of the model:
|
|
@@ -22,8 +33,9 @@ export default () => {
|
|
|
22
33
|
* * **Item is selected**: Selection will be moved to the next item in the list
|
|
23
34
|
* @param id The id of the item that will be removed
|
|
24
35
|
*/
|
|
25
|
-
const removeItem = (id: string, model: SelectionModel) => {
|
|
36
|
+
const removeItem = <T extends unknown>(id: string, model: SelectionModel<T>) => {
|
|
26
37
|
const index = model.state.items.findIndex(item => model.getId(item) === model.state.cursorId);
|
|
38
|
+
console.log('index', index, id, model.state.cursorId, model.state.items);
|
|
27
39
|
const nextIndex = index === model.state.items.length - 1 ? index - 1 : index + 1;
|
|
28
40
|
const nextId = model.getId(model.state.items[nextIndex]);
|
|
29
41
|
if (model.state.selectedIds[0] === id) {
|
|
@@ -41,48 +53,52 @@ export default () => {
|
|
|
41
53
|
}
|
|
42
54
|
};
|
|
43
55
|
|
|
44
|
-
const onKeyDown = (e: React.KeyboardEvent<HTMLElement
|
|
45
|
-
if (e.key === 'Delete') {
|
|
56
|
+
const onKeyDown = (id: string) => (e: React.KeyboardEvent<HTMLElement>) => {
|
|
57
|
+
if (e.key === 'Delete' && id !== 'add') {
|
|
46
58
|
setTabs(tabs.filter(item => item.id !== id));
|
|
59
|
+
const model = modelRef.current;
|
|
47
60
|
removeItem(id, model);
|
|
48
61
|
}
|
|
49
62
|
};
|
|
50
63
|
|
|
64
|
+
const onClick = (id: string) => (e: React.MouseEvent) => {
|
|
65
|
+
if (id === 'add') {
|
|
66
|
+
addedRef.current += 1;
|
|
67
|
+
setTabs(tabs => {
|
|
68
|
+
const newTabs = tabs.slice(0, tabs.length - 1);
|
|
69
|
+
const addTab = tabs.slice(-1);
|
|
70
|
+
return newTabs.concat(
|
|
71
|
+
{tab: `Tab ${addedRef.current}`, id: `tab-${addedRef.current}`},
|
|
72
|
+
addTab
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
model.events.goTo({id: 'add'});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
51
79
|
return (
|
|
52
80
|
<Tabs model={model}>
|
|
53
|
-
<Tabs.List>
|
|
54
|
-
{
|
|
55
|
-
<Tabs.Item
|
|
56
|
-
key={item.id}
|
|
57
|
-
name={item.id}
|
|
58
|
-
index={index}
|
|
59
|
-
onKeyDown={e => onKeyDown(e, item.id)}
|
|
60
|
-
>
|
|
81
|
+
<Tabs.List overflowButton={<Tabs.OverflowButton>More</Tabs.OverflowButton>}>
|
|
82
|
+
{(item: Tab) => (
|
|
83
|
+
<Tabs.Item name={item.id} onKeyDown={onKeyDown(item.id)} onClick={onClick(item.id)}>
|
|
61
84
|
{item.tab}
|
|
62
85
|
</Tabs.Item>
|
|
63
|
-
)
|
|
64
|
-
<Tabs.Item
|
|
65
|
-
key={'last'}
|
|
66
|
-
index={tabs.length}
|
|
67
|
-
name={'last'}
|
|
68
|
-
onClick={() => {
|
|
69
|
-
addedRef.current += 1;
|
|
70
|
-
setTabs(tabs =>
|
|
71
|
-
tabs.concat({tab: `Tab ${addedRef.current}`, id: `tab-${addedRef.current}`})
|
|
72
|
-
);
|
|
73
|
-
model.events.goTo({id: 'last'});
|
|
74
|
-
}}
|
|
75
|
-
>
|
|
76
|
-
Add Tab
|
|
77
|
-
</Tabs.Item>
|
|
86
|
+
)}
|
|
78
87
|
</Tabs.List>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
<Tabs.
|
|
88
|
+
<Tabs.Menu.Popper>
|
|
89
|
+
<Tabs.Menu.Card maxWidth={300} maxHeight={200}>
|
|
90
|
+
<Tabs.Menu.List>
|
|
91
|
+
{(item: Tab) => <Tabs.Menu.Item name={item.id}>{item.tab}</Tabs.Menu.Item>}
|
|
92
|
+
</Tabs.Menu.List>
|
|
93
|
+
</Tabs.Menu.Card>
|
|
94
|
+
</Tabs.Menu.Popper>
|
|
95
|
+
<Tabs.Panels>
|
|
96
|
+
{(item: Tab) => (
|
|
97
|
+
<Tabs.Panel marginTop="m" name={item.id}>
|
|
82
98
|
Contents of {item.tab}
|
|
83
99
|
</Tabs.Panel>
|
|
84
|
-
)
|
|
85
|
-
</
|
|
100
|
+
)}
|
|
101
|
+
</Tabs.Panels>
|
|
86
102
|
</Tabs>
|
|
87
103
|
);
|
|
88
104
|
};
|
|
@@ -3,6 +3,7 @@ import {Specifications} from '@workday/canvas-kit-docs';
|
|
|
3
3
|
|
|
4
4
|
import Default from './examples/Default';
|
|
5
5
|
import CustomContent from './examples/CustomContent';
|
|
6
|
+
import DelayedTooltip from './examples/DelayedTooltip';
|
|
6
7
|
import DescribeType from './examples/DescribeType';
|
|
7
8
|
import Muted from './examples/Muted';
|
|
8
9
|
import Placements from './examples/Placements';
|
|
@@ -87,6 +88,13 @@ a dialog instead.
|
|
|
87
88
|
|
|
88
89
|
<ExampleCodeBlock code={CustomContent} />
|
|
89
90
|
|
|
91
|
+
### Delayed Tooltip
|
|
92
|
+
|
|
93
|
+
The default delay for showing and hiding a tooltip are 300ms and 100ms, respectively. You can
|
|
94
|
+
control the length of the delay by providing custom `showDelay` and `hideDelay` in ms.
|
|
95
|
+
|
|
96
|
+
<ExampleCodeBlock code={DelayedTooltip} />
|
|
97
|
+
|
|
90
98
|
### Placements
|
|
91
99
|
|
|
92
100
|
The tooltip allows for a `placement` configuration. The tooltip uses
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {Tooltip} from '@workday/canvas-kit-react/tooltip';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
return (
|
|
8
|
+
<React.Fragment>
|
|
9
|
+
<Tooltip type="describe" title="Tooltip Text" showDelay={2000} hideDelay={1000}>
|
|
10
|
+
<SecondaryButton>
|
|
11
|
+
Tooltip appears after 2 seconds and disappears after 1 second
|
|
12
|
+
</SecondaryButton>
|
|
13
|
+
</Tooltip>
|
|
14
|
+
</React.Fragment>
|
|
15
|
+
);
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "6.0.0-alpha.0-next.
|
|
3
|
+
"version": "6.0.0-alpha.0-next.39+ac7c09b9",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"build:specs": "node ./utils/build-specifications.js",
|
|
36
36
|
"build:downlevel-dts": "yarn run downlevel-dts dist ts3.5/dist",
|
|
37
37
|
"build": "npm-run-all --parallel build:cjs build:es6 build:mdx --sequential build:specs build:downlevel-dts",
|
|
38
|
-
"depcheck": "node ../../utils/check-dependencies-exist.js"
|
|
38
|
+
"depcheck": "node ../../utils/check-dependencies-exist.js",
|
|
39
|
+
"typecheck:src": "tsc -p . --noEmit --incremental false"
|
|
39
40
|
},
|
|
40
41
|
"publishConfig": {
|
|
41
42
|
"access": "public"
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
],
|
|
50
51
|
"dependencies": {
|
|
51
52
|
"@storybook/csf": "0.0.1",
|
|
52
|
-
"@workday/canvas-kit-react": "^6.0.0-alpha.0-next.
|
|
53
|
+
"@workday/canvas-kit-react": "^6.0.0-alpha.0-next.39+ac7c09b9"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"fs-extra": "^10.0.0",
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"mkdirp": "^1.0.3",
|
|
58
59
|
"typescript": "^3.8.3"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "ac7c09b97add635f256ffc4103478fab55da55c2"
|
|
61
62
|
}
|
|
@@ -1,46 +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 {styled} from '@workday/canvas-kit-react/common';
|
|
5
|
-
import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
|
|
6
|
-
import {CSSProperties, space} from '@workday/canvas-kit-react/tokens';
|
|
7
|
-
|
|
8
|
-
const StyledField = styled(TextInput.Field)<{alertStyles?: CSSProperties}>(
|
|
9
|
-
({alertStyles}) => alertStyles
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
export default () => {
|
|
13
|
-
const [value, setValue] = React.useState('foo');
|
|
14
|
-
|
|
15
|
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
16
|
-
setValue(event.target.value);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const alertStyles = useThemedRing(
|
|
20
|
-
value.length < 3 ? 'error' : value.length < 5 ? 'alert' : 'success'
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<VStack spacing="xxxs" alignItems="flex-start">
|
|
25
|
-
<TextInput>
|
|
26
|
-
<TextInput.Label>Password</TextInput.Label>
|
|
27
|
-
<StyledField
|
|
28
|
-
alertStyles={alertStyles}
|
|
29
|
-
onChange={handleChange}
|
|
30
|
-
value={value}
|
|
31
|
-
type="password"
|
|
32
|
-
/>
|
|
33
|
-
<TextInput.Hint paddingTop={space.xxs}>
|
|
34
|
-
<strong>Password Strength: </strong>
|
|
35
|
-
{value.length < 3 ? (
|
|
36
|
-
<span>Weak</span>
|
|
37
|
-
) : value.length < 5 ? (
|
|
38
|
-
<span>Average</span>
|
|
39
|
-
) : (
|
|
40
|
-
<span>Strong</span>
|
|
41
|
-
)}
|
|
42
|
-
</TextInput.Hint>
|
|
43
|
-
</TextInput>
|
|
44
|
-
</VStack>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
@@ -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} />
|
|
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} disabled />
|
|
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">
|
|
14
|
-
<TextInput>
|
|
15
|
-
<TextInput.Label>Street Address</TextInput.Label>
|
|
16
|
-
<TextInput.Field onChange={handleChange} value={value} />
|
|
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 {HStack} 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
|
-
<HStack spacing="l" alignItems="center">
|
|
14
|
-
<TextInput>
|
|
15
|
-
<TextInput.Label>Email</TextInput.Label>
|
|
16
|
-
<TextInput.Field onChange={handleChange} value={value} />
|
|
17
|
-
</TextInput>
|
|
18
|
-
</HStack>
|
|
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('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,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
|
-
};
|