@workday/canvas-kit-docs 6.0.6 → 6.1.2

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.
Files changed (48) hide show
  1. package/dist/commonjs/lib/specs.js +136 -2
  2. package/dist/es6/lib/specs.js +136 -2
  3. package/dist/mdx/preview-react/form-field/FormField.mdx +27 -0
  4. package/dist/mdx/preview-react/form-field/examples/Custom.tsx +57 -0
  5. package/dist/mdx/preview-react/text-area/TextArea.mdx +122 -0
  6. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +31 -0
  7. package/dist/mdx/preview-react/text-area/examples/Basic.tsx +17 -0
  8. package/dist/mdx/preview-react/text-area/examples/Disabled.tsx +17 -0
  9. package/dist/mdx/preview-react/text-area/examples/Error.tsx +40 -0
  10. package/dist/mdx/preview-react/text-area/examples/Grow.tsx +17 -0
  11. package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +20 -0
  12. package/dist/mdx/preview-react/text-area/examples/LabelPositionHorizontal.tsx +17 -0
  13. package/dist/mdx/preview-react/text-area/examples/LabelPositionVertical.tsx +17 -0
  14. package/dist/mdx/preview-react/text-area/examples/Placeholder.tsx +21 -0
  15. package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +28 -0
  16. package/dist/mdx/preview-react/text-area/examples/Required.tsx +17 -0
  17. package/dist/mdx/preview-react/text-area/examples/ResizeConstraints.tsx +22 -0
  18. package/dist/mdx/{labs-react → preview-react}/text-input/TextInput.mdx +40 -18
  19. package/dist/mdx/preview-react/text-input/examples/Alert.tsx +40 -0
  20. package/dist/mdx/{labs-react/text-input/examples/HiddenLabel.tsx → preview-react/text-input/examples/Basic.tsx} +3 -3
  21. package/dist/mdx/preview-react/text-input/examples/Disabled.tsx +17 -0
  22. package/dist/mdx/{labs-react → preview-react}/text-input/examples/Error.tsx +6 -9
  23. package/dist/mdx/preview-react/text-input/examples/Grow.tsx +17 -0
  24. package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +20 -0
  25. package/dist/mdx/preview-react/text-input/examples/LabelPositionHorizontal.tsx +17 -0
  26. package/dist/mdx/preview-react/text-input/examples/LabelPositionVertical.tsx +17 -0
  27. package/dist/mdx/{labs-react → preview-react}/text-input/examples/LoginForm.tsx +10 -5
  28. package/dist/mdx/preview-react/text-input/examples/Password.tsx +17 -0
  29. package/dist/mdx/preview-react/text-input/examples/Placeholder.tsx +17 -0
  30. package/dist/mdx/{labs-react → preview-react}/text-input/examples/RefForwarding.tsx +7 -6
  31. package/dist/mdx/preview-react/text-input/examples/Required.tsx +17 -0
  32. package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +46 -0
  33. package/dist/mdx/{labs-react → preview-react}/text-input/examples/ThemedError.tsx +8 -11
  34. package/dist/mdx/react/button/button/examples/Primary.tsx +4 -3
  35. package/dist/mdx/react/loading-animation/LoadingAnimation.mdx +5 -0
  36. package/dist/mdx/react/loading-animation/examples/RTL.tsx +16 -0
  37. package/dist/mdx/react/tooltip/Tooltip.mdx +8 -0
  38. package/dist/mdx/react/tooltip/examples/DelayedTooltip.tsx +16 -0
  39. package/package.json +5 -4
  40. package/dist/mdx/labs-react/text-input/examples/Alert.tsx +0 -46
  41. package/dist/mdx/labs-react/text-input/examples/Basic.tsx +0 -20
  42. package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +0 -20
  43. package/dist/mdx/labs-react/text-input/examples/Grow.tsx +0 -20
  44. package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +0 -20
  45. package/dist/mdx/labs-react/text-input/examples/Password.tsx +0 -20
  46. package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +0 -20
  47. package/dist/mdx/labs-react/text-input/examples/Required.tsx +0 -20
  48. package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +0 -51
@@ -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' spacing='xxxs'>
13
+ <TextArea.Label>Leave a review</TextArea.Label>
14
+ <TextArea.Field onChange={handleChange} value={value} />
15
+ </TextArea>
16
+ );
17
+ };
@@ -0,0 +1,21 @@
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
15
+ placeholder="Let us know how we did!"
16
+ onChange={handleChange}
17
+ value={value}
18
+ />
19
+ </TextArea>
20
+ );
21
+ };
@@ -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
+ };
@@ -1,11 +1,12 @@
1
1
  import {Specifications} from '@workday/canvas-kit-docs';
2
2
 
3
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
3
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
4
4
 
5
5
  import Basic from './examples/Basic';
6
6
  import Disabled from './examples/Disabled';
7
7
  import Grow from './examples/Grow';
8
- import LabelPosition from './examples/LabelPosition';
8
+ import LabelPositionHorizontal from './examples/LabelPositionHorizontal';
9
+ import LabelPositionVertical from './examples/LabelPositionVertical';
9
10
  import Placeholder from './examples/Placeholder';
10
11
  import RefForwarding from './examples/RefForwarding';
11
12
  import Required from './examples/Required';
@@ -27,7 +28,7 @@ Text Inputs allow users to enter words or characters without styling.
27
28
  ## Installation
28
29
 
29
30
  ```sh
30
- yarn add @workday/canvas-kit-react
31
+ yarn add @workday/canvas-kit-preview-react
31
32
  ```
32
33
 
33
34
  ## Usage
@@ -38,21 +39,21 @@ yarn add @workday/canvas-kit-react
38
39
 
39
40
  ### Disabled
40
41
 
41
- Set the `disabled` prop of the TextInput.Field to prevent users from interacting with it.
42
+ Use `TextInput.Field`s `disabled` prop to prevent users from interacting with it.
42
43
 
43
44
  <ExampleCodeBlock code={Disabled} />
44
45
 
45
46
  ### Placeholder
46
47
 
47
- Set the `placeholder` prop of the TextInput.Field to display a sample of its expected format or
48
- value before a value has been provided.
48
+ Use `TextInput.Field`s `placeholder` prop to display a sample of its expected format or value before
49
+ a value has been provided.
49
50
 
50
51
  <ExampleCodeBlock code={Placeholder} />
51
52
 
52
53
  ### Required
53
54
 
54
- Set the `isRequired` property property from useTextInputModel to indicate that the field is
55
- required. This will also add an red asterisk next to your TextInput.Label.
55
+ Use `TextInput.Field`'s `isRequired` prop (or use with the `useTextInputModel` hook) to indicate
56
+ that the field is required. This will also add a red asterisk to `TextInput.Label`.
56
57
 
57
58
  <ExampleCodeBlock code={Required} />
58
59
 
@@ -67,34 +68,42 @@ All the TextInput subcomponents support
67
68
  ### Grow
68
69
 
69
70
  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 wrap the whole TextInput in it a Flex
71
- and set the growth that way, etc.
71
+ extend full width, e.g. setting width prop to 100%, or you can set the `alignItems` prop to
72
+ `stretch` on `TextInput`, etc.
72
73
 
73
74
  <ExampleCodeBlock code={Grow} />
74
75
 
75
76
  ### Label Position
76
77
 
77
- Setting the Label position can be done using HStack or VStack
78
+ Use the `orientation` property to set `TextInput.Label`'s position. You can override the default
79
+ spacing using the `spacing` prop. Below are examples of both positions:
78
80
 
79
- <ExampleCodeBlock code={LabelPosition} />
81
+ #### Horizontal
82
+
83
+ <ExampleCodeBlock code={LabelPositionHorizontal} />
84
+
85
+ #### Vertical
86
+
87
+ <ExampleCodeBlock code={LabelPositionVertical} />
80
88
 
81
89
  ### Visually Hiding The Label
82
90
 
83
- If your label is just for screen reader users you can add the isVisuallyHidden to TextInput.Label
91
+ If your label is just for screen reader users you can use the `accessibleHide` utility class from
92
+ `@workday/canvas-kit-react/common`. You will likely want to set the `spacing` prop on `TextInput` to
93
+ `zero`.
84
94
 
85
95
  <ExampleCodeBlock code={HiddenLabel} />
86
96
 
87
97
  ### Type
88
98
 
89
- Set the `type` prop TextInput.Field to any allowed string, e.g. password to change the input field
90
- type.
99
+ Use `TextInput.Field`'s `type` prop to customize the input type, e.g. `password`, `email`, etc.
91
100
 
92
101
  <ExampleCodeBlock code={Password} />
93
102
 
94
103
  ### Error States
95
104
 
96
- Use the `hasError` property from useTextInputModel to set the TextInput to the Error state. If you
97
- have an accompanying hint you can use the TextInput.Hint subcomponent.
105
+ Use the `hasError` property from `useTextInputModel` to set the `TextInput` to the Error state. If
106
+ you have an accompanying hint you can use the TextInput.Hint subcomponent.
98
107
 
99
108
  #### Errors
100
109
 
@@ -114,10 +123,23 @@ Use the `useThemedRing` hook to change the visual state of the input field.
114
123
 
115
124
  #### Themed Alerts
116
125
 
126
+ If the your theme's `main` color doesn't meet accessibility contrast, the `darkest` color will be
127
+ used in an outer ring.
128
+
117
129
  <ExampleCodeBlock code={ThemedAlert} />
118
130
 
119
131
  #### Full example
120
132
 
121
133
  Login Form using Formik
122
134
 
123
- <ExampleCodeBlock code={LoginForm} />
135
+ <ExampleCodeBlock code={LoginForm} />
136
+
137
+ ## Props
138
+
139
+ Undocumented props are spread to the underlying `<input>` element.
140
+
141
+ <ArgsTable of={TextInput} />
142
+
143
+ ## Specifications
144
+
145
+ <Specifications file="TextInputPreview.spec.ts" name="Text Input" />
@@ -0,0 +1,40 @@
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
23
+ css={alertStyles}
24
+ onChange={handleChange}
25
+ value={value}
26
+ type="password"
27
+ />
28
+ <TextInput.Hint paddingTop={space.xxs}>
29
+ <strong>Password Strength: </strong>
30
+ {value.length < 3 ? (
31
+ <span>Weak</span>
32
+ ) : value.length < 5 ? (
33
+ <span>Average</span>
34
+ ) : (
35
+ <span>Strong</span>
36
+ )}
37
+ </TextInput.Hint>
38
+ </TextInput>
39
+ );
40
+ };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
2
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
3
 
4
4
  export default () => {
5
5
  const [value, setValue] = React.useState('');
@@ -9,8 +9,8 @@ export default () => {
9
9
  };
10
10
 
11
11
  return (
12
- <TextInput>
13
- <TextInput.Label isVisuallyHidden={true}>Email</TextInput.Label>
12
+ <TextInput orientation='vertical'>
13
+ <TextInput.Label>Email</TextInput.Label>
14
14
  <TextInput.Field onChange={handleChange} value={value} />
15
15
  </TextInput>
16
16
  );
@@ -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
+ };
@@ -1,6 +1,5 @@
1
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';
2
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
4
3
  import {space} from '@workday/canvas-kit-react/tokens';
5
4
 
6
5
  export default () => {
@@ -32,12 +31,10 @@ export default () => {
32
31
  };
33
32
 
34
33
  return (
35
- <VStack spacing="xxxs" alignItems="flex-start">
36
- <TextInput hasError={hasError}>
37
- <TextInput.Label>A three letter word</TextInput.Label>
38
- <TextInput.Field onChange={handleChange} value={value} />
39
- <TextInput.Hint paddingTop={space.xxs}>{hint}</TextInput.Hint>
40
- </TextInput>
41
- </VStack>
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>
42
39
  );
43
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
+ };
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import {useFormik} from 'formik';
4
4
  import * as yup from 'yup';
5
5
 
6
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
6
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
7
7
  import {HStack, VStack} from '@workday/canvas-kit-labs-react/layout';
8
8
  import {IconButton, PrimaryButton} from '@workday/canvas-kit-react/button';
9
9
  import {visibleIcon, invisibleIcon} from '@workday/canvas-system-icons-web';
@@ -48,8 +48,12 @@ export default () => {
48
48
 
49
49
  return (
50
50
  <form onSubmit={formik.handleSubmit} action=".">
51
- <VStack spacing="xs" alignItems="flex-start">
52
- <TextInput isRequired={true} hasError={formik.touched.email && !!formik.errors.email}>
51
+ <VStack spacing='xs' alignItems='flex-start'>
52
+ <TextInput
53
+ orientation='vertical'
54
+ isRequired={true}
55
+ hasError={formik.touched.email && !!formik.errors.email}
56
+ >
53
57
  <TextInput.Label>Email</TextInput.Label>
54
58
  <TextInput.Field
55
59
  name="email"
@@ -62,7 +66,8 @@ export default () => {
62
66
  <TextInput.Hint>{formik.touched.email && formik.errors.email}</TextInput.Hint>
63
67
  </TextInput>
64
68
  <TextInput
65
- inputId={passwordId}
69
+ orientation='vertical'
70
+ id={passwordId}
66
71
  hasError={formik.touched.password && !!formik.errors.password}
67
72
  isRequired={true}
68
73
  >
@@ -81,7 +86,7 @@ export default () => {
81
86
  type="button"
82
87
  icon={showPassword ? invisibleIcon : visibleIcon}
83
88
  aria-label={showPassword ? 'Hide Password' : 'Show Password'}
84
- aria-controls={passwordId}
89
+ aria-controls={`input-${passwordId}`}
85
90
  onClick={() => {
86
91
  setShowPassword(state => !state);
87
92
  passwordRef.current.focus();
@@ -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
+ };
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
2
+ import {changeFocus} from '@workday/canvas-kit-react/common';
3
3
  import {VStack} from '@workday/canvas-kit-labs-react/layout';
4
- import {PrimaryButton} from '@workday/canvas-kit-react/button';
4
+ import {SecondaryButton} from '@workday/canvas-kit-react/button';
5
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
5
6
 
6
7
  export default () => {
7
8
  const [value, setValue] = React.useState('');
@@ -12,16 +13,16 @@ export default () => {
12
13
  };
13
14
 
14
15
  const handleClick = () => {
15
- ref.current.focus();
16
+ changeFocus(ref.current)
16
17
  };
17
18
 
18
19
  return (
19
- <VStack spacing="xxxs" alignItems="flex-start">
20
- <TextInput>
20
+ <VStack spacing='xxxs' alignItems='flex-start'>
21
+ <TextInput orientation='vertical'>
21
22
  <TextInput.Label>Email</TextInput.Label>
22
23
  <TextInput.Field onChange={handleChange} value={value} ref={ref} />
23
24
  </TextInput>
24
- <PrimaryButton onClick={handleClick}>Focus Text Input</PrimaryButton>
25
+ <SecondaryButton onClick={handleClick}>Focus Text Input</SecondaryButton>
25
26
  </VStack>
26
27
  );
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
+ };
@@ -1,6 +1,5 @@
1
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';
2
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
4
3
  import {CanvasProvider, PartialEmotionCanvasTheme} from '@workday/canvas-kit-react/common';
5
4
  import {colors, space} from '@workday/canvas-kit-react/tokens';
6
5
 
@@ -26,15 +25,13 @@ export default () => {
26
25
 
27
26
  return (
28
27
  <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>
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}>
32
+ {!value && 'Please enter an email.'}
33
+ </TextInput.Hint>
34
+ </TextInput>
38
35
  </CanvasProvider>
39
36
  );
40
37
  };
@@ -4,10 +4,11 @@ import {PrimaryButton} from '@workday/canvas-kit-react/button';
4
4
  import {HStack} from '@workday/canvas-kit-labs-react/layout';
5
5
  import {plusIcon} from '@workday/canvas-system-icons-web';
6
6
 
7
- export default () => (
7
+ export default props => (
8
8
  <HStack spacing="s" padding="s">
9
- <PrimaryButton>Primary</PrimaryButton>
10
- <PrimaryButton icon={plusIcon} iconPosition="right">
9
+ <PrimaryButton {...props}>Primary</PrimaryButton>
10
+ <p>{JSON.stringify(props.theme)}</p>
11
+ <PrimaryButton icon={plusIcon} iconPosition="right" {...props}>
11
12
  Primary
12
13
  </PrimaryButton>
13
14
  </HStack>