@workday/canvas-kit-docs 5.3.17 → 5.4.0-next.1
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 +429 -19
- package/dist/es6/lib/specs.js +429 -19
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +567 -0
- package/dist/mdx/COMPOUND_COMPONENTS.mdx +31 -30
- package/dist/mdx/TESTING.mdx +30 -6
- package/dist/mdx/changelog.stories.mdx +0 -1
- package/dist/mdx/labs-react/layout/Stack.mdx +7 -2
- package/dist/mdx/labs-react/search-form/SearchForm.mdx +62 -0
- package/dist/mdx/labs-react/search-form/examples/Basic.tsx +61 -0
- package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +72 -0
- package/dist/mdx/labs-react/search-form/examples/Grow.tsx +62 -0
- package/dist/mdx/labs-react/search-form/examples/PropTables.splitProps.tsx +4 -0
- package/dist/mdx/labs-react/search-form/examples/RTL.tsx +70 -0
- package/dist/mdx/labs-react/search-form/examples/Theming.tsx +64 -0
- package/dist/mdx/preview-react/_examples/SelectWithFormik.mdx +8 -0
- package/dist/mdx/preview-react/_examples/TextInputWithFormik.mdx +8 -0
- package/dist/mdx/preview-react/_examples/examples/SelectWithFormik.tsx +47 -0
- package/dist/mdx/preview-react/_examples/examples/TextInputWithFormik.tsx +105 -0
- package/dist/mdx/preview-react/form-field/FormField.mdx +39 -0
- package/dist/mdx/preview-react/form-field/examples/Custom.tsx +57 -0
- package/dist/mdx/preview-react/form-field/examples/Select.tsx +50 -0
- package/dist/mdx/preview-react/side-panel/examples/AlwaysOpen.tsx +1 -1
- package/dist/mdx/preview-react/side-panel/examples/Basic.tsx +1 -1
- package/dist/mdx/preview-react/side-panel/examples/ExternalControl.tsx +1 -1
- package/dist/mdx/preview-react/side-panel/examples/RightOrigin.tsx +1 -1
- package/dist/mdx/preview-react/side-panel/examples/Variant.tsx +1 -1
- package/dist/mdx/preview-react/text-area/TextArea.mdx +122 -0
- package/dist/mdx/preview-react/text-area/examples/Alert.tsx +36 -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 +17 -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/preview-react/text-input/TextInput.mdx +138 -0
- package/dist/mdx/preview-react/text-input/examples/Alert.tsx +35 -0
- package/dist/mdx/preview-react/text-input/examples/Basic.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/Disabled.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/Error.tsx +40 -0
- 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/preview-react/text-input/examples/Password.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/Placeholder.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/RefForwarding.tsx +28 -0
- 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/preview-react/text-input/examples/ThemedError.tsx +35 -0
- package/dist/mdx/react/_examples/CookieBanner.mdx +8 -0
- package/dist/mdx/react/_examples/GlobalHeader.mdx +12 -0
- package/dist/mdx/react/_examples/PageHeader.mdx +8 -0
- package/dist/mdx/react/_examples/examples/CookieBanner.tsx +97 -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/button/button/Button.mdx +26 -2
- package/dist/mdx/react/button/button/examples/Primary.tsx +10 -1
- package/dist/mdx/react/button/button/examples/PrimaryInverse.tsx +14 -0
- package/dist/mdx/react/button/button/examples/Secondary.tsx +10 -1
- package/dist/mdx/react/button/button/examples/SecondaryInverse.tsx +14 -0
- package/dist/mdx/react/button/button/examples/Tertiary.tsx +13 -1
- package/dist/mdx/react/button/button/examples/TertiaryInverse.tsx +14 -0
- package/dist/mdx/react/popup/examples/FocusRedirect.tsx +2 -1
- package/dist/mdx/react/tabs/Tabs.mdx +31 -5
- package/dist/mdx/react/tabs/examples/DisabledTab.tsx +1 -1
- package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +82 -38
- package/dist/mdx/react/tabs/examples/HoistedModel.tsx +4 -4
- package/dist/mdx/react/tabs/examples/Icons.tsx +36 -0
- package/dist/mdx/react/tabs/examples/{NamedKeys.tsx → NamedTabs.tsx} +0 -0
- package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +58 -0
- package/dist/mdx/react/tabs/examples/SinglePanel.tsx +1 -1
- package/dist/mdx/react/text-area/TextArea.mdx +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextArea orientation="vertical">
|
|
13
|
+
<TextArea.Label>Leave a review</TextArea.Label>
|
|
14
|
+
<TextArea.Field placeholder="Let us know how we did!" onChange={handleChange} value={value} />
|
|
15
|
+
</TextArea>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {changeFocus} from '@workday/canvas-kit-react/common';
|
|
3
|
+
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
4
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
5
|
+
import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
const [value, setValue] = React.useState('');
|
|
9
|
+
const ref = React.useRef(null);
|
|
10
|
+
|
|
11
|
+
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
12
|
+
setValue(event.target.value);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const handleClick = () => {
|
|
16
|
+
changeFocus(ref.current);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<VStack spacing="xxxs" alignItems="flex-start">
|
|
21
|
+
<TextArea orientation="vertical">
|
|
22
|
+
<TextArea.Label>Leave a review</TextArea.Label>
|
|
23
|
+
<TextArea.Field onChange={handleChange} value={value} ref={ref} />
|
|
24
|
+
</TextArea>
|
|
25
|
+
<SecondaryButton onClick={handleClick}>Focus Text Area</SecondaryButton>
|
|
26
|
+
</VStack>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextArea isRequired={true} orientation="vertical">
|
|
13
|
+
<TextArea.Label>Leave a review</TextArea.Label>
|
|
14
|
+
<TextArea.Field onChange={handleChange} value={value} />
|
|
15
|
+
</TextArea>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
|
|
3
|
+
import {styled} from '@workday/canvas-kit-react/common';
|
|
4
|
+
|
|
5
|
+
const StyledField = styled(TextArea.Field)({
|
|
6
|
+
resize: 'vertical',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export default () => {
|
|
10
|
+
const [value, setValue] = React.useState('');
|
|
11
|
+
|
|
12
|
+
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
13
|
+
setValue(event.target.value);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<TextArea orientation="vertical">
|
|
18
|
+
<TextArea.Label>Leave a review</TextArea.Label>
|
|
19
|
+
<StyledField onChange={handleChange} value={value} />
|
|
20
|
+
</TextArea>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {Specifications} from '@workday/canvas-kit-docs';
|
|
2
|
+
|
|
3
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
4
|
+
|
|
5
|
+
import Basic from './examples/Basic';
|
|
6
|
+
import Disabled from './examples/Disabled';
|
|
7
|
+
import Grow from './examples/Grow';
|
|
8
|
+
import LabelPositionHorizontal from './examples/LabelPositionHorizontal';
|
|
9
|
+
import LabelPositionVertical from './examples/LabelPositionVertical';
|
|
10
|
+
import Placeholder from './examples/Placeholder';
|
|
11
|
+
import RefForwarding from './examples/RefForwarding';
|
|
12
|
+
import Required from './examples/Required';
|
|
13
|
+
import Password from './examples/Password';
|
|
14
|
+
import HiddenLabel from './examples/HiddenLabel';
|
|
15
|
+
import ThemedAlert from './examples/ThemedAlert';
|
|
16
|
+
import ThemedError from './examples/ThemedError';
|
|
17
|
+
import Error from './examples/Error';
|
|
18
|
+
import Alert from './examples/Alert';
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Canvas Kit Text Input
|
|
22
|
+
|
|
23
|
+
Text Inputs allow users to enter words or characters without styling.
|
|
24
|
+
|
|
25
|
+
[> Workday Design Reference](https://design.workday.com/components/inputs/text-input)
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
yarn add @workday/canvas-kit-preview-react
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Basic Example
|
|
36
|
+
|
|
37
|
+
<ExampleCodeBlock code={Basic} />
|
|
38
|
+
|
|
39
|
+
### Disabled
|
|
40
|
+
|
|
41
|
+
Use `TextInput.Field`s `disabled` prop to prevent users from interacting with it.
|
|
42
|
+
|
|
43
|
+
<ExampleCodeBlock code={Disabled} />
|
|
44
|
+
|
|
45
|
+
### Placeholder
|
|
46
|
+
|
|
47
|
+
Use `TextInput.Field`s `placeholder` prop to display a sample of its expected format or value before
|
|
48
|
+
a value has been provided.
|
|
49
|
+
|
|
50
|
+
<ExampleCodeBlock code={Placeholder} />
|
|
51
|
+
|
|
52
|
+
### Required
|
|
53
|
+
|
|
54
|
+
Use `TextInput.Field`'s `isRequired` prop (or use with the `useTextInputModel` hook) to indicate
|
|
55
|
+
that the field is required. This will also add a red asterisk to `TextInput.Label`.
|
|
56
|
+
|
|
57
|
+
<ExampleCodeBlock code={Required} />
|
|
58
|
+
|
|
59
|
+
### Ref Forwarding
|
|
60
|
+
|
|
61
|
+
All the TextInput subcomponents support
|
|
62
|
+
[ref forwarding](https://reactjs.org/docs/forwarding-refs.html). e.g. TextInput.Field will forward
|
|
63
|
+
`ref` to its underlying `<input type="text">` element.
|
|
64
|
+
|
|
65
|
+
<ExampleCodeBlock code={RefForwarding} />
|
|
66
|
+
|
|
67
|
+
### Grow
|
|
68
|
+
|
|
69
|
+
There are lots of ways to accomplish this. The TextInput.Field extends from Box so it is easy to
|
|
70
|
+
extend full width, e.g. setting width prop to 100%, or you can set the `alignItems` prop to
|
|
71
|
+
`stretch` on `TextInput`, etc.
|
|
72
|
+
|
|
73
|
+
<ExampleCodeBlock code={Grow} />
|
|
74
|
+
|
|
75
|
+
### Label Position
|
|
76
|
+
|
|
77
|
+
Use the `orientation` property to set `TextInput.Label`'s position. You can override the default
|
|
78
|
+
spacing using the `spacing` prop. Below are examples of both positions:
|
|
79
|
+
|
|
80
|
+
#### Horizontal
|
|
81
|
+
|
|
82
|
+
<ExampleCodeBlock code={LabelPositionHorizontal} />
|
|
83
|
+
|
|
84
|
+
#### Vertical
|
|
85
|
+
|
|
86
|
+
<ExampleCodeBlock code={LabelPositionVertical} />
|
|
87
|
+
|
|
88
|
+
### Visually Hiding The Label
|
|
89
|
+
|
|
90
|
+
If your label is just for screen reader users you can use the `accessibleHide` utility class from
|
|
91
|
+
`@workday/canvas-kit-react/common`. You will likely want to set the `spacing` prop on `TextInput` to
|
|
92
|
+
`zero`.
|
|
93
|
+
|
|
94
|
+
<ExampleCodeBlock code={HiddenLabel} />
|
|
95
|
+
|
|
96
|
+
### Type
|
|
97
|
+
|
|
98
|
+
Use `TextInput.Field`'s `type` prop to customize the input type, e.g. `password`, `email`, etc.
|
|
99
|
+
|
|
100
|
+
<ExampleCodeBlock code={Password} />
|
|
101
|
+
|
|
102
|
+
### Error States
|
|
103
|
+
|
|
104
|
+
Use the `hasError` property from `useTextInputModel` to set the `TextInput` to the Error state. If
|
|
105
|
+
you have an accompanying hint you can use the TextInput.Hint subcomponent.
|
|
106
|
+
|
|
107
|
+
#### Errors
|
|
108
|
+
|
|
109
|
+
<ExampleCodeBlock code={Error} />
|
|
110
|
+
|
|
111
|
+
#### Themed Errors
|
|
112
|
+
|
|
113
|
+
<ExampleCodeBlock code={ThemedError} />
|
|
114
|
+
|
|
115
|
+
### Other Visual States
|
|
116
|
+
|
|
117
|
+
Use the `useThemedRing` hook to change the visual state of the input field.
|
|
118
|
+
|
|
119
|
+
#### Alerts
|
|
120
|
+
|
|
121
|
+
<ExampleCodeBlock code={Alert} />
|
|
122
|
+
|
|
123
|
+
#### Themed Alerts
|
|
124
|
+
|
|
125
|
+
If the your theme's `main` color doesn't meet accessibility contrast, the `darkest` color will be
|
|
126
|
+
used in an outer ring.
|
|
127
|
+
|
|
128
|
+
<ExampleCodeBlock code={ThemedAlert} />
|
|
129
|
+
|
|
130
|
+
## Props
|
|
131
|
+
|
|
132
|
+
Undocumented props are spread to the underlying `<input>` element.
|
|
133
|
+
|
|
134
|
+
<ArgsTable of={TextInput} />
|
|
135
|
+
|
|
136
|
+
## Specifications
|
|
137
|
+
|
|
138
|
+
<Specifications file="TextInputPreview.spec.ts" name="Text Input" />
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import {jsx} from '@emotion/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
5
|
+
import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
|
|
6
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
const [value, setValue] = React.useState('foo');
|
|
10
|
+
|
|
11
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
12
|
+
setValue(event.target.value);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const alertStyles = useThemedRing(
|
|
16
|
+
value.length < 3 ? 'error' : value.length < 5 ? 'alert' : 'success'
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<TextInput orientation="vertical">
|
|
21
|
+
<TextInput.Label>Password</TextInput.Label>
|
|
22
|
+
<TextInput.Field css={alertStyles} onChange={handleChange} value={value} type="password" />
|
|
23
|
+
<TextInput.Hint paddingTop={space.xxs}>
|
|
24
|
+
<strong>Password Strength: </strong>
|
|
25
|
+
{value.length < 3 ? (
|
|
26
|
+
<span>Weak</span>
|
|
27
|
+
) : value.length < 5 ? (
|
|
28
|
+
<span>Average</span>
|
|
29
|
+
) : (
|
|
30
|
+
<span>Strong</span>
|
|
31
|
+
)}
|
|
32
|
+
</TextInput.Hint>
|
|
33
|
+
</TextInput>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextInput orientation="vertical">
|
|
13
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
14
|
+
<TextInput.Field onChange={handleChange} value={value} />
|
|
15
|
+
</TextInput>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextInput orientation="vertical">
|
|
13
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
14
|
+
<TextInput.Field onChange={handleChange} value={value} disabled />
|
|
15
|
+
</TextInput>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
4
|
+
|
|
5
|
+
export default () => {
|
|
6
|
+
const [value, setValue] = React.useState('four');
|
|
7
|
+
const [hint, setHint] = React.useState('');
|
|
8
|
+
const [hasError, setHasError] = React.useState(false);
|
|
9
|
+
|
|
10
|
+
const validateInput = (value: string) => {
|
|
11
|
+
const stringLength = value.length;
|
|
12
|
+
if (stringLength !== 3) {
|
|
13
|
+
setHasError(true);
|
|
14
|
+
const hintStart = 'Word length must be';
|
|
15
|
+
setHint(stringLength < 3 ? `${hintStart} greater than 2` : `${hintStart} less than 4`);
|
|
16
|
+
} else {
|
|
17
|
+
setHasError(false);
|
|
18
|
+
setHint('');
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
validateInput(value);
|
|
24
|
+
// Only run on load
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
29
|
+
validateInput(event.target.value);
|
|
30
|
+
setValue(event.target.value);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<TextInput hasError={hasError} orientation="vertical">
|
|
35
|
+
<TextInput.Label>A three letter word</TextInput.Label>
|
|
36
|
+
<TextInput.Field onChange={handleChange} value={value} />
|
|
37
|
+
<TextInput.Hint paddingTop={space.xxs}>{hint}</TextInput.Hint>
|
|
38
|
+
</TextInput>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextInput orientation="vertical" alignItems="stretch">
|
|
13
|
+
<TextInput.Label>Street Address</TextInput.Label>
|
|
14
|
+
<TextInput.Field onChange={handleChange} value={value} />
|
|
15
|
+
</TextInput>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import {jsx} from '@emotion/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
5
|
+
import {accessibleHide} from '@workday/canvas-kit-react/common';
|
|
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
|
+
return (
|
|
15
|
+
<TextInput orientation="vertical" spacing="zero">
|
|
16
|
+
<TextInput.Label css={{...accessibleHide}}>Email</TextInput.Label>
|
|
17
|
+
<TextInput.Field onChange={handleChange} value={value} />
|
|
18
|
+
</TextInput>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextInput orientation="horizontal">
|
|
13
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
14
|
+
<TextInput.Field onChange={handleChange} value={value} />
|
|
15
|
+
</TextInput>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextInput orientation="vertical" spacing="xxxs">
|
|
13
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
14
|
+
<TextInput.Field onChange={handleChange} value={value} />
|
|
15
|
+
</TextInput>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('SuperSecret1');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextInput orientation="vertical">
|
|
13
|
+
<TextInput.Label>Password</TextInput.Label>
|
|
14
|
+
<TextInput.Field onChange={handleChange} value={value} type="password" />
|
|
15
|
+
</TextInput>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextInput orientation="vertical">
|
|
13
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
14
|
+
<TextInput.Field onChange={handleChange} value={value} placeholder="user@email.com" />
|
|
15
|
+
</TextInput>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {changeFocus} from '@workday/canvas-kit-react/common';
|
|
3
|
+
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
4
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
5
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
const [value, setValue] = React.useState('');
|
|
9
|
+
const ref = React.useRef(null);
|
|
10
|
+
|
|
11
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
12
|
+
setValue(event.target.value);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const handleClick = () => {
|
|
16
|
+
changeFocus(ref.current);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<VStack spacing="xxxs" alignItems="flex-start">
|
|
21
|
+
<TextInput orientation="vertical">
|
|
22
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
23
|
+
<TextInput.Field onChange={handleChange} value={value} ref={ref} />
|
|
24
|
+
</TextInput>
|
|
25
|
+
<SecondaryButton onClick={handleClick}>Focus Text Input</SecondaryButton>
|
|
26
|
+
</VStack>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const [value, setValue] = React.useState('');
|
|
6
|
+
|
|
7
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
8
|
+
setValue(event.target.value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TextInput isRequired={true} orientation="vertical">
|
|
13
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
14
|
+
<TextInput.Field onChange={handleChange} value={value} />
|
|
15
|
+
</TextInput>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import {jsx} from '@emotion/core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
5
|
+
import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
|
|
6
|
+
import {CanvasProvider, PartialEmotionCanvasTheme} from '@workday/canvas-kit-react/common';
|
|
7
|
+
import {colors, space} from '@workday/canvas-kit-react/tokens';
|
|
8
|
+
|
|
9
|
+
export default () => {
|
|
10
|
+
const theme: PartialEmotionCanvasTheme = {
|
|
11
|
+
canvas: {
|
|
12
|
+
palette: {
|
|
13
|
+
common: {
|
|
14
|
+
focusOutline: colors.grapeSoda300,
|
|
15
|
+
},
|
|
16
|
+
alert: {
|
|
17
|
+
main: colors.kiwi200,
|
|
18
|
+
darkest: colors.kiwi600,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
return (
|
|
24
|
+
<CanvasProvider theme={theme}>
|
|
25
|
+
<AlertInput />
|
|
26
|
+
</CanvasProvider>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const AlertInput = () => {
|
|
31
|
+
const [value, setValue] = React.useState('invalid@email');
|
|
32
|
+
|
|
33
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
34
|
+
setValue(event.target.value);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const alertStyles = useThemedRing('alert');
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<TextInput orientation="vertical">
|
|
41
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
42
|
+
<TextInput.Field css={alertStyles} onChange={handleChange} value={value} />
|
|
43
|
+
<TextInput.Hint paddingTop={space.xxs}>Please enter a valid email.</TextInput.Hint>
|
|
44
|
+
</TextInput>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
3
|
+
import {CanvasProvider, PartialEmotionCanvasTheme} from '@workday/canvas-kit-react/common';
|
|
4
|
+
import {colors, space} from '@workday/canvas-kit-react/tokens';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
const [value, setValue] = React.useState('');
|
|
8
|
+
|
|
9
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
10
|
+
setValue(event.target.value);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const theme: PartialEmotionCanvasTheme = {
|
|
14
|
+
canvas: {
|
|
15
|
+
palette: {
|
|
16
|
+
common: {
|
|
17
|
+
focusOutline: colors.grapeSoda300,
|
|
18
|
+
},
|
|
19
|
+
error: {
|
|
20
|
+
main: colors.islandPunch400,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<CanvasProvider theme={theme}>
|
|
28
|
+
<TextInput hasError={!value} isRequired={true} orientation="vertical">
|
|
29
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
30
|
+
<TextInput.Field onChange={handleChange} value={value} />
|
|
31
|
+
<TextInput.Hint paddingTop={space.xxs}>{!value && 'Please enter an email.'}</TextInput.Hint>
|
|
32
|
+
</TextInput>
|
|
33
|
+
</CanvasProvider>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Basic from './examples/GlobalHeader';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# Canvas Kit Examples
|
|
5
|
+
|
|
6
|
+
## GlobalHeader
|
|
7
|
+
|
|
8
|
+
Developers building internal Workday applications will likely not need to create this component.
|
|
9
|
+
However, if you're building components to be used outside of Workday, this is a helpful reference
|
|
10
|
+
for building a global navigation header that looks like our internal `GlobalHeader`.
|
|
11
|
+
|
|
12
|
+
<ExampleCodeBlock code={Basic} />
|