@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
|
@@ -216,6 +216,9 @@ const CustomGlobalHeader = props => {
|
|
|
216
216
|
};
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
+
You may continue to use this component exactly as you did in v5, but note that we plan to hard-deprecate it in Canvas Kit v7.
|
|
220
|
+
If you would like to migrate away from this deprecated component now, you can reference [this example](https://workday.github.io/canvas-kit/?path=/story/examples-global-header-react--basic) instead.
|
|
221
|
+
|
|
219
222
|
### Page Header
|
|
220
223
|
|
|
221
224
|
We are [soft-deprecating](#soft-deprecation) `PageHeader`. It has been renamed to
|
|
@@ -267,6 +270,9 @@ export const CustomPageHeader = (props: CustomPageHeaderProps) => {
|
|
|
267
270
|
};
|
|
268
271
|
```
|
|
269
272
|
|
|
273
|
+
You may continue to use this component exactly as you did in v5, but note that we plan to hard-deprecate it in Canvas Kit v7.
|
|
274
|
+
If you would like to migrate away from this deprecated component now, you can reference [this example](https://workday.github.io/canvas-kit/?path=/story/examples-page-header-react--basic) instead.
|
|
275
|
+
|
|
270
276
|
## Component Migrations
|
|
271
277
|
|
|
272
278
|
### Search Bar
|
|
@@ -337,7 +343,7 @@ type CustomDepthValues = CanvasDepthValue;
|
|
|
337
343
|
interface OtherCustomDepthValues extends CanvasDepthValue {}
|
|
338
344
|
|
|
339
345
|
// v6
|
|
340
|
-
import {
|
|
346
|
+
import {CanvasDepthValues} from '@workday/canvas-kit-react/tokens';
|
|
341
347
|
|
|
342
348
|
type CustomDepthValues = CanvasDepthValues;
|
|
343
349
|
interface OtherCustomDepthValues extends CanvasDepthValues {}
|
|
@@ -363,10 +369,10 @@ Below is a reference table for the V5 and V6 breakpoint values.
|
|
|
363
369
|
|
|
364
370
|
Also for reference, these are our viewport ranges:
|
|
365
371
|
|
|
366
|
-
- `small` (320px - 767px) Used for mobile-sized screens
|
|
367
|
-
- `medium` (768px - 1023px) Used for tablet-sized screens
|
|
368
|
-
- `large` - (1024px - 1439px) Used for laptop and small desktop screens
|
|
369
|
-
- `extra-large` (
|
|
372
|
+
- `small` (`320px` - `767px`) Used for mobile-sized screens
|
|
373
|
+
- `medium` (`768px` - `1023px`) Used for tablet-sized screens
|
|
374
|
+
- `large` - (`1024px` - `1439px`) Used for laptop and small desktop screens
|
|
375
|
+
- `extra-large` (`≥1440px`) Used for very large screens
|
|
370
376
|
|
|
371
377
|
### Action Bar
|
|
372
378
|
|
|
@@ -374,10 +380,10 @@ Also for reference, these are our viewport ranges:
|
|
|
374
380
|
`max-width: 575px`. They now use `max-width: 767.5px` – the upper limit of the `small` range. This
|
|
375
381
|
will have two effects for this component:
|
|
376
382
|
|
|
377
|
-
- Container padding will decrease from `s` (16px) to `xxs` (8px) on all viewports
|
|
378
|
-
- This was previously happening only on viewports
|
|
379
|
-
- Button order will be reversed on all viewports
|
|
380
|
-
- This was previously happening only on viewports
|
|
383
|
+
- Container padding will decrease from `s` (`16px`) to `xxs` (`8px`) on all viewports less than `768px` wide
|
|
384
|
+
- This was previously happening only on viewports less than `576px` wide
|
|
385
|
+
- Button order will be reversed on all viewports less than `768px` wide
|
|
386
|
+
- This was previously happening only on viewports less than `576px` wide
|
|
381
387
|
|
|
382
388
|
These changes in behavior are intentional and expected.
|
|
383
389
|
|
|
@@ -471,7 +477,7 @@ All these changes are described in detail by button type in the sections below.
|
|
|
471
477
|
#### Primary Disabled State
|
|
472
478
|
|
|
473
479
|
Previously the button's disabled state had a `blueberry200` background, but it now uses the default
|
|
474
|
-
`blueberry400` and sets the entire button to 40% opacity. This creates more
|
|
480
|
+
`blueberry400` and sets the entire button to 40% opacity. This creates more consistency for the
|
|
475
481
|
disabled states across all our buttons.
|
|
476
482
|
|
|
477
483
|
#### Primary Large
|
|
@@ -489,7 +495,7 @@ height of the button will remain the same.
|
|
|
489
495
|
|
|
490
496
|
#### Primary Small
|
|
491
497
|
|
|
492
|
-
We now support icons for small `PrimaryButton`s. The icons are `20px` x `
|
|
498
|
+
We now support icons for small `PrimaryButton`s. The icons are `20px` x `20px`.
|
|
493
499
|
|
|
494
500
|
#### Primary Extra Small
|
|
495
501
|
|
|
@@ -513,7 +519,7 @@ overall height of the button will remain the same.
|
|
|
513
519
|
|
|
514
520
|
#### Secondary Small
|
|
515
521
|
|
|
516
|
-
We now support icons for small `SecondaryButton`s. The icons are `20px` x `
|
|
522
|
+
We now support icons for small `SecondaryButton`s. The icons are `20px` x `20px`.
|
|
517
523
|
|
|
518
524
|
#### Secondary Extra Small
|
|
519
525
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Canvas Kit 7.0 Migration Guide
|
|
2
|
+
|
|
3
|
+
Below are the breaking changes made in Canvas Kit v7. Please
|
|
4
|
+
[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have
|
|
5
|
+
any questions about the update.
|
|
6
|
+
|
|
7
|
+
- [Codemod](#codemod)
|
|
8
|
+
|
|
9
|
+
## Codemod
|
|
10
|
+
|
|
11
|
+
Please use our [codemod package](https://github.com/Workday/canvas-kit/tree/master/modules/codemod)
|
|
12
|
+
to automatically update your code to work with a majority of the breaking changes in the migration
|
|
13
|
+
from Canvas Kit v6 to v7:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
> npx @workday/canvas-kit-codemod v7 [path]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
> Note: This codemod only works on `.js`, `.jsx`, `.ts`, and `.tsx` extensions. You may need to make
|
|
20
|
+
> some manual changes in other file types (`.json`, `.mdx`, `.md`, etc.).
|
|
21
|
+
|
|
22
|
+
> Note: You may need to run your linter after executing the codemod, as it's resulting formatting
|
|
23
|
+
> (spacing, quotes, etc.) may not match your project's styling.
|
|
24
|
+
|
|
25
|
+
**Breaking changes accounted for by this codemod will be marked with a 🤖.**
|
|
26
|
+
|
|
27
|
+
**Please verify all changes made by the codemod. As a safety precaution, we recommend committing the
|
|
28
|
+
changes from the codemod as a single isolated commit (separate from other changes) so you can
|
|
29
|
+
rollback more easily if necessary.**
|
|
30
|
+
|
|
31
|
+
[Let us know](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you
|
|
32
|
+
encounter any issues or use cases that we've missed. The `@workday/canvas-kit-codemod` package will
|
|
33
|
+
help us maintain additional codemod transforms to make future migrations easier.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {Specifications} from '@workday/canvas-kit-docs';
|
|
2
|
+
|
|
3
|
+
import {FormField} from '@workday/canvas-kit-preview-react/form-field';
|
|
4
|
+
|
|
5
|
+
import Custom from './examples/Custom';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Canvas Kit Form Field
|
|
9
|
+
|
|
10
|
+
FormField allows users to wrap input components to make them accessible. You usually won't want to
|
|
11
|
+
use FormField directly but instead should use the specific component you need, e.g. `TextInput`.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
yarn add @workday/canvas-kit-preview-react
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Customizing With Behavior Hooks Example
|
|
22
|
+
|
|
23
|
+
If you need full customization you can use the form field behavior hooks to build your own solution.
|
|
24
|
+
It is also easy it work with custom components or third party libraries and get the CKR
|
|
25
|
+
accessibility guarantees by using the `as` prop.
|
|
26
|
+
|
|
27
|
+
<ExampleCodeBlock code={Custom} />
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
useFormFieldHint,
|
|
4
|
+
useFormFieldInput,
|
|
5
|
+
useFormFieldLabel,
|
|
6
|
+
useFormFieldModel,
|
|
7
|
+
useFormFieldOrientation,
|
|
8
|
+
FormFieldModelContext,
|
|
9
|
+
} from '@workday/canvas-kit-preview-react/form-field';
|
|
10
|
+
import {useModelContext} from '@workday/canvas-kit-react/common';
|
|
11
|
+
import {Stack} from '@workday/canvas-kit-labs-react/layout';
|
|
12
|
+
|
|
13
|
+
const Label = ({model, children}) => {
|
|
14
|
+
const localModel = useModelContext(FormFieldModelContext, model);
|
|
15
|
+
const props = useFormFieldLabel(localModel);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<label {...props}>
|
|
19
|
+
{children}
|
|
20
|
+
{model.state.isRequired ? '*' : ''}
|
|
21
|
+
</label>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const Hint = ({model, children}) => {
|
|
26
|
+
const localModel = useModelContext(FormFieldModelContext, model);
|
|
27
|
+
const props = useFormFieldHint(localModel);
|
|
28
|
+
|
|
29
|
+
return <span {...props}>{children}</span>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const Input = ({model, ...elementProps}) => {
|
|
33
|
+
const localModel = useModelContext(FormFieldModelContext, model);
|
|
34
|
+
const props = useFormFieldInput(localModel, elementProps);
|
|
35
|
+
|
|
36
|
+
return <input type="text" required={model.state.isRequired ? true : false} {...props} />;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default () => {
|
|
40
|
+
const [value, setValue] = React.useState('');
|
|
41
|
+
|
|
42
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
43
|
+
setValue(event.target.value);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const model = useFormFieldModel({isRequired: true});
|
|
47
|
+
|
|
48
|
+
const layoutProps = useFormFieldOrientation('vertical')
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Stack {...layoutProps}>
|
|
52
|
+
<Label model={model}>My Custom Field</Label>
|
|
53
|
+
<Input model={model} value={value} onChange={handleChange} />
|
|
54
|
+
<Hint model={model}>You can be anything</Hint>
|
|
55
|
+
</Stack>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {Specifications} from '@workday/canvas-kit-docs';
|
|
2
|
+
|
|
3
|
+
import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
|
|
4
|
+
|
|
5
|
+
import Alert from './examples/Alert';
|
|
6
|
+
import Basic from './examples/Basic';
|
|
7
|
+
import Disabled from './examples/Disabled';
|
|
8
|
+
import Error from './examples/Error';
|
|
9
|
+
import Grow from './examples/Grow';
|
|
10
|
+
import LabelPositionVertical from './examples/LabelPositionVertical';
|
|
11
|
+
import LabelPositionHorizontal from './examples/LabelPositionHorizontal';
|
|
12
|
+
import HiddenLabel from './examples/HiddenLabel';
|
|
13
|
+
import Placeholder from './examples/Placeholder';
|
|
14
|
+
import RefForwarding from './examples/RefForwarding';
|
|
15
|
+
import Required from './examples/Required';
|
|
16
|
+
import ResizeConstraints from './examples/ResizeConstraints';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Canvas Kit Text Area
|
|
20
|
+
|
|
21
|
+
TextArea's allow users to enter and edit multiple lines of text.
|
|
22
|
+
|
|
23
|
+
[> Workday Design Reference](https://design.workday.com/components/inputs/text-area)
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
yarn add @workday/canvas-kit-preview-react
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Basic Example
|
|
34
|
+
|
|
35
|
+
<ExampleCodeBlock code={Basic} />
|
|
36
|
+
|
|
37
|
+
### Disabled
|
|
38
|
+
|
|
39
|
+
Use `TextArea.Field`'s `disabled` prop to prevent users from interacting with the field.
|
|
40
|
+
|
|
41
|
+
<ExampleCodeBlock code={Disabled} />
|
|
42
|
+
|
|
43
|
+
### Placeholder
|
|
44
|
+
|
|
45
|
+
Use `TextArea.Field`'s `placeholder` prop to display a sample of its expected format or value before
|
|
46
|
+
a value has been provided.
|
|
47
|
+
|
|
48
|
+
<ExampleCodeBlock code={Placeholder} />
|
|
49
|
+
|
|
50
|
+
### Required
|
|
51
|
+
|
|
52
|
+
Use `TextArea.Field`'s `isRequired` prop (or use with the `useTextAreaModel` hook) to indicate that
|
|
53
|
+
the field is required. This will also add a red asterisk to `TextArea.Label`.
|
|
54
|
+
|
|
55
|
+
<ExampleCodeBlock code={Required} />
|
|
56
|
+
|
|
57
|
+
### Ref Forwarding
|
|
58
|
+
|
|
59
|
+
`TextArea` supports [ref forwarding](https://reactjs.org/docs/forwarding-refs.html). It will forward
|
|
60
|
+
`ref` to its underlying `<textarea>` element.
|
|
61
|
+
|
|
62
|
+
<ExampleCodeBlock code={RefForwarding} />
|
|
63
|
+
|
|
64
|
+
### Resize Constraints
|
|
65
|
+
|
|
66
|
+
Use the `resize` css attribute to restrict resizing of it to certain dimensions.
|
|
67
|
+
|
|
68
|
+
<ExampleCodeBlock code={ResizeConstraints} />
|
|
69
|
+
|
|
70
|
+
### Grow
|
|
71
|
+
|
|
72
|
+
There are lots of ways to accomplish this. The `TextArea.Field` extends from Box so it is easy to
|
|
73
|
+
extend full width, e.g. setting width prop to 100%, or you can set the `alignItems` prop to
|
|
74
|
+
`stretch` on `TextArea`, etc.
|
|
75
|
+
|
|
76
|
+
<ExampleCodeBlock code={Grow} />
|
|
77
|
+
|
|
78
|
+
### Label Position
|
|
79
|
+
|
|
80
|
+
Use the `orientation` property to set `TextArea.Label`'s position. You can override the default
|
|
81
|
+
spacing using the `spacing` prop. Below are examples of both positions:
|
|
82
|
+
|
|
83
|
+
#### Horizontal
|
|
84
|
+
|
|
85
|
+
<ExampleCodeBlock code={LabelPositionHorizontal} />
|
|
86
|
+
|
|
87
|
+
#### Vertical
|
|
88
|
+
|
|
89
|
+
<ExampleCodeBlock code={LabelPositionVertical} />
|
|
90
|
+
|
|
91
|
+
### Visually Hiding The Label
|
|
92
|
+
|
|
93
|
+
If your label is just for screen reader users you can use the `accessibleHide` utility class from
|
|
94
|
+
`@workday/canvas-kit-react/common`. You will likely want to set the `spacing` prop on `TextArea` to
|
|
95
|
+
`zero`.
|
|
96
|
+
|
|
97
|
+
<ExampleCodeBlock code={HiddenLabel} />
|
|
98
|
+
|
|
99
|
+
### Error States
|
|
100
|
+
|
|
101
|
+
Use the `hasError` property from `useTextAreaModel` to set the `TextArea` to the Error state. If you
|
|
102
|
+
have an accompanying hint you can use the `TextArea.Hint` subcomponent.
|
|
103
|
+
|
|
104
|
+
<ExampleCodeBlock code={Error} />
|
|
105
|
+
|
|
106
|
+
### Other Visual States
|
|
107
|
+
|
|
108
|
+
Use the `useThemedRing` hook to change the visual state of the `<textarea>` element.
|
|
109
|
+
|
|
110
|
+
#### Alert
|
|
111
|
+
|
|
112
|
+
<ExampleCodeBlock code={Alert} />
|
|
113
|
+
|
|
114
|
+
## Props
|
|
115
|
+
|
|
116
|
+
Undocumented props are spread to the underlying `<textarea>` element.
|
|
117
|
+
|
|
118
|
+
<ArgsTable of={TextArea} />
|
|
119
|
+
|
|
120
|
+
## Specifications
|
|
121
|
+
|
|
122
|
+
<Specifications file="TextAreaPreview.spec.ts" name="Text Area" />
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/core'
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
|
|
5
|
+
import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
|
|
6
|
+
import {space, colors} from '@workday/canvas-kit-react/tokens';
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
const [value, setValue] = React.useState('');
|
|
10
|
+
|
|
11
|
+
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
12
|
+
setValue(event.target.value.slice(0, 10));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const alertStyles = useThemedRing(
|
|
16
|
+
value.length < 3 ? 'success' : value.length < 7 ? 'alert' : 'error'
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const hintColor = value.length < 3 ? colors.greenApple600 : value.length < 7 ? colors.cantaloupe600 : colors.cinnamon500
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<TextArea orientation='vertical'>
|
|
23
|
+
<TextArea.Label>Add a comment</TextArea.Label>
|
|
24
|
+
<TextArea.Field css={alertStyles} onChange={handleChange} value={value} />
|
|
25
|
+
<TextArea.Hint paddingTop={space.xxs}>
|
|
26
|
+
<strong>Character Limit: </strong>
|
|
27
|
+
<span css={{color: hintColor}}>{10 - value.length} Left</span>
|
|
28
|
+
</TextArea.Hint>
|
|
29
|
+
</TextArea>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -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 onChange={handleChange} value={value} />
|
|
15
|
+
</TextArea>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -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 disabled onChange={handleChange} value={value} />
|
|
15
|
+
</TextArea>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
|
|
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<HTMLTextAreaElement>) => {
|
|
29
|
+
validateInput(event.target.value);
|
|
30
|
+
setValue(event.target.value);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<TextArea hasError={hasError} orientation='vertical'>
|
|
35
|
+
<TextArea.Label>A three letter word</TextArea.Label>
|
|
36
|
+
<TextArea.Field onChange={handleChange} value={value} />
|
|
37
|
+
<TextArea.Hint paddingTop={space.xxs}>{hint}</TextArea.Hint>
|
|
38
|
+
</TextArea>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -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' alignItems='stretch'>
|
|
13
|
+
<TextArea.Label>Leave a review</TextArea.Label>
|
|
14
|
+
<TextArea.Field onChange={handleChange} value={value} />
|
|
15
|
+
</TextArea>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/core'
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
|
|
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<HTMLTextAreaElement>) => {
|
|
11
|
+
setValue(event.target.value);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<TextArea orientation='vertical' spacing='zero'>
|
|
16
|
+
<TextArea.Label css={{...accessibleHide}}>Email</TextArea.Label>
|
|
17
|
+
<TextArea.Field onChange={handleChange} value={value} />
|
|
18
|
+
</TextArea>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
@@ -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='horizontal'>
|
|
13
|
+
<TextArea.Label>Leave a review</TextArea.Label>
|
|
14
|
+
<TextArea.Field onChange={handleChange} value={value} />
|
|
15
|
+
</TextArea>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -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
|
+
};
|