@workday/canvas-kit-docs 14.1.0-1284-next.0 → 15.0.0-alpha.1283-next.0

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.
@@ -0,0 +1,111 @@
1
+ import React from 'react';
2
+
3
+ import {useFormik} from 'formik';
4
+ import {object, SchemaOf, string} from 'yup';
5
+
6
+ import {TextInput} from '@workday/canvas-kit-react/text-input';
7
+ import {Flex} from '@workday/canvas-kit-react/layout';
8
+ import {TertiaryButton, PrimaryButton} from '@workday/canvas-kit-react/button';
9
+ import {visibleIcon, invisibleIcon} from '@workday/canvas-system-icons-web';
10
+ import {useUniqueId} from '@workday/canvas-kit-react/common';
11
+ import {FormField} from '@workday/canvas-kit-react/form-field';
12
+
13
+ interface LoginSchema {
14
+ email: string;
15
+ password: string;
16
+ }
17
+
18
+ const passwordMinimum = 8;
19
+ const passwordHint = `Password should be of minimum ${passwordMinimum} characters length`;
20
+ const emailRequired = 'Email is required';
21
+ const passwordRequired = 'Password is required';
22
+
23
+ const validationSchema: SchemaOf<LoginSchema> = object({
24
+ email: string().email('Enter a valid email').required(emailRequired),
25
+ password: string().min(passwordMinimum, passwordHint).required(passwordRequired),
26
+ });
27
+
28
+ export default () => {
29
+ const passwordRef = React.useRef<HTMLInputElement>(null);
30
+ const [showPassword, setShowPassword] = React.useState(false);
31
+ const passwordId = useUniqueId();
32
+
33
+ const formik = useFormik({
34
+ initialValues: {
35
+ email: 'example@baz.com',
36
+ password: 'foobarbaz',
37
+ },
38
+ validationSchema: validationSchema,
39
+ onSubmit: values => {
40
+ setShowPassword(false);
41
+ // Send data to server
42
+ setTimeout(() => {
43
+ alert(JSON.stringify(values, null, 2));
44
+ }, 0);
45
+ },
46
+ });
47
+
48
+ return (
49
+ <form onSubmit={formik.handleSubmit} action=".">
50
+ <Flex gap="xs" flexDirection="column" alignItems="flex-start">
51
+ <FormField
52
+ orientation="vertical"
53
+ isRequired={true}
54
+ error={formik.touched.email && !!formik.errors.email ? 'error' : undefined}
55
+ >
56
+ <FormField.Label>Email</FormField.Label>
57
+ <FormField.Field>
58
+ <FormField.Input
59
+ as={TextInput}
60
+ name="email"
61
+ autoComplete="username"
62
+ placeholder="yourName@example.com"
63
+ onChange={formik.handleChange}
64
+ onBlur={formik.handleBlur}
65
+ value={formik.values.email}
66
+ />
67
+ </FormField.Field>
68
+ <FormField.Hint>{formik.touched.email && formik.errors.email}</FormField.Hint>
69
+ </FormField>
70
+ <FormField
71
+ orientation="vertical"
72
+ id={passwordId}
73
+ error={formik.touched.password && !!formik.errors.password ? 'error' : undefined}
74
+ isRequired={true}
75
+ >
76
+ <FormField.Label>Password</FormField.Label>
77
+ <Flex gap="xxs">
78
+ <FormField.Field>
79
+ <FormField.Input
80
+ as={TextInput}
81
+ type={showPassword ? 'text' : 'password'}
82
+ name="password"
83
+ autoComplete="current-password"
84
+ spellCheck={false}
85
+ ref={passwordRef}
86
+ onChange={formik.handleChange}
87
+ onBlur={formik.handleBlur}
88
+ value={formik.values.password}
89
+ />
90
+ </FormField.Field>
91
+ <TertiaryButton
92
+ type="button"
93
+ icon={showPassword ? invisibleIcon : visibleIcon}
94
+ aria-label={showPassword ? 'Hide Password' : 'Show Password'}
95
+ aria-controls={`input-${passwordId}`}
96
+ onClick={() => {
97
+ setShowPassword(state => !state);
98
+ passwordRef.current?.focus();
99
+ }}
100
+ />
101
+ </Flex>
102
+ <FormField.Hint>
103
+ {(formik.touched.password && formik.errors.password) || passwordHint}
104
+ </FormField.Hint>
105
+ </FormField>
106
+
107
+ <PrimaryButton type="submit">Submit</PrimaryButton>
108
+ </Flex>
109
+ </form>
110
+ );
111
+ };
@@ -10,14 +10,6 @@ import {Select} from '@workday/canvas-kit-react/select';
10
10
  import {FormField} from '@workday/canvas-kit-react/form-field';
11
11
  import {visibleIcon, invisibleIcon} from '@workday/canvas-system-icons-web';
12
12
  import {useUniqueId} from '@workday/canvas-kit-react/common';
13
- import {createStyles, cssVar} from '@workday/canvas-kit-styling';
14
- import {system} from '@workday/canvas-tokens-web';
15
-
16
- const styles = createStyles({
17
- gap: system.space.x3,
18
- flexDirection: 'column',
19
- alignItems: 'flex-start',
20
- });
21
13
 
22
14
  type YupValidationResolver = <T extends {}>(
23
15
  validationSchema: SchemaOf<T>
@@ -107,7 +99,7 @@ export default () => {
107
99
  };
108
100
  return (
109
101
  <form onSubmit={onSubmit} action="." noValidate={true}>
110
- <Flex cs={styles}>
102
+ <Flex gap="xs" flexDirection="column" alignItems="flex-start">
111
103
  <FormField
112
104
  orientation="vertical"
113
105
  isRequired={true}
@@ -151,7 +143,7 @@ export default () => {
151
143
  error={!!errors.password ? 'error' : undefined}
152
144
  >
153
145
  <FormField.Label>Password</FormField.Label>
154
- <Flex cs={{gap: cssVar(system.space.x2)}}>
146
+ <Flex gap="xxs">
155
147
  <FormField.Field>
156
148
  <FormField.Input
157
149
  as={TextInput}
@@ -1,8 +1,4 @@
1
- import {
2
- ExampleCodeBlock,
3
- StylePropsTable,
4
- StorybookStatusIndicator,
5
- } from '@workday/canvas-kit-docs';
1
+ import {ExampleCodeBlock, StylePropsTable} from '@workday/canvas-kit-docs';
6
2
 
7
3
  import {
8
4
  backgroundStyleFnConfigs,
@@ -19,7 +15,8 @@ import {
19
15
  spaceStyleFnConfigs,
20
16
  textStyleFnConfigs,
21
17
  } from '@workday/canvas-kit-react/layout';
22
- import {InformationHighlight} from '@workday/canvas-kit-preview-react/information-highlight';
18
+ import {InformationHighlight} from '@workday/canvas-kit-preview-react/information-highlight'
19
+ import {Hyperlink} from '@workday/canvas-kit-react/button';
23
20
 
24
21
  import Background from './examples/Background';
25
22
  import Border from './examples/Border';
@@ -36,24 +33,19 @@ import Space from './examples/Space';
36
33
  import Text from './examples/Text';
37
34
 
38
35
 
39
- # Style Props <StorybookStatusIndicator type="deprecated" />
36
+ # Style Props
40
37
 
41
38
  Style props provide a common, ergonomic API for modifying a component's styles by passing styles
42
39
  with props.
43
40
 
44
41
  <InformationHighlight className="sb-unstyled" variant="caution">
45
- <InformationHighlight.Icon />
46
- <InformationHighlight.Heading> Style props are deprecated!</InformationHighlight.Heading>
47
- <InformationHighlight.Body>
48
- As we transition away from Emotion's runtime costs, we advise to move away from using style props. Please use our [styling utilities](https://workday.github.io/canvas-kit/?path=/docs/styling-getting-started-overview--docs) instead. For more information on this change, view our discussion on the [Future of Styling](https://github.com/Workday/canvas-kit/discussions/2265).
49
-
50
- You can use `14.1` codemod to automatic migration to `cs` prop. [More about codemods](http://localhost:9001/?path=/docs/guides-codemods--docs)
51
-
52
- </InformationHighlight.Body>
42
+ <InformationHighlight.Icon />
43
+ <InformationHighlight.Heading> Caution: Performance Hit</InformationHighlight.Heading>
44
+ <InformationHighlight.Body>
45
+ As we transition away from Emotion's runtime costs, we advise against using style props. Please use our <Hyperlink src="https://workday.github.io/canvas-kit/?path=/docs/styling-getting-started-overview--docs">styling utilities</Hyperlink> instead. For more information on this change, view our discussion on the <Hyperlink src="https://github.com/Workday/canvas-kit/discussions/2265">Future of Styling</Hyperlink>.
46
+ </InformationHighlight.Body>
53
47
  </InformationHighlight>
54
48
 
55
- <br />
56
-
57
49
  ## System Prop Values
58
50
 
59
51
  Many style props are design-system-aware and translate `SystemPropValues` for you automatically. In
@@ -1,4 +1,4 @@
1
- import {ExampleCodeBlock, SymbolDoc, StorybookStatusIndicator} from '@workday/canvas-kit-docs';
1
+ import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
2
2
  import {InformationHighlight} from '@workday/canvas-kit-preview-react/information-highlight';
3
3
  import {system} from '@workday/canvas-tokens-web';
4
4
  import StylingOverrides from './examples/StylingOverrides';
@@ -6,41 +6,7 @@ import StylingOverrides from './examples/StylingOverrides';
6
6
 
7
7
  # Merging Styles
8
8
 
9
- ## handleCsProp
10
-
11
- But what about when using components that use `@emotion/react` or `@emotion/styled`? Those libraries
12
- use a different approach. Instead of multiple class names, they use a single, merged class name.
13
-
14
- `handleCsProp` was created to handle integration with existing components that use the `css` prop
15
- from `@emotion/react` or the `styled` components from `@emotion/styled`. If a class name from one of
16
- those libraries is detected, style merging will follow the same rules as those libraries. Instead of
17
- multiple class names, a single class name with all matching properties is created. The
18
- `handleCsProp` also takes care of merging `style` props, `className` props, and can handle the `cs`
19
- prop:
20
-
21
- ```tsx
22
- const myStencil = createStencil({
23
- // ...
24
- });
25
-
26
- const MyComponent = elemProps => {
27
- return <div {...handleProps(elemProps, myStencil({}))} />;
28
- };
29
-
30
- // All props will be merged for you
31
- <MyComponent style={{color: 'red'}} className="my-classname" cs={{position: 'relative'}} />;
32
- ```
33
-
34
- `handleCsProp` will make sure the `style` prop is passed to the `div` and that the `my-classname`
35
- CSS class name appears on the `div`'s class list. Also the `cs` prop will add the appropriate styles
36
- to the element via a CSS class name. If your component needs to handle being passed a `className`,
37
- `style`, or `cs` prop, use `handleCsProp`.
38
-
39
- ### handleCsProp API
40
-
41
- <SymbolDoc hideHeading name="handleCsProp" />
42
-
43
- ## mergeStyles <StorybookStatusIndicator type="deprecated" />
9
+ ## mergeStyles
44
10
 
45
11
  In v9, we used `@emotion/styled` or `@emotion/react` for all styling which is a runtime styling
46
12
  solution. Starting in v10, we're migrating our styling to a more static solution using
@@ -161,4 +127,38 @@ the last defined. This should be the expected order.
161
127
 
162
128
  ### mergeStyles API
163
129
 
164
- <SymbolDoc hideHeading name="mergeStyles" />
130
+ <SymbolDoc hideHeading name="mergeStyles" />
131
+
132
+ ## handleCsProp
133
+
134
+ But what about when using components that use `@emotion/react` or `@emotion/styled`? Those libraries
135
+ use a different approach. Instead of multiple class names, they use a single, merged class name.
136
+
137
+ `handleCsProp` was created to handle integration with existing components that use the `css` prop
138
+ from `@emotion/react` or the `styled` components from `@emotion/styled`. If a class name from one of
139
+ those libraries is detected, style merging will follow the same rules as those libraries. Instead of
140
+ multiple class names, a single class name with all matching properties is created. The
141
+ `handleCsProp` also takes care of merging `style` props, `className` props, and can handle the `cs`
142
+ prop:
143
+
144
+ ```tsx
145
+ const myStencil = createStencil({
146
+ // ...
147
+ });
148
+
149
+ const MyComponent = elemProps => {
150
+ return <div {...handleProps(elemProps, myStencil({}))} />;
151
+ };
152
+
153
+ // All props will be merged for you
154
+ <MyComponent style={{color: 'red'}} className="my-classname" cs={{position: 'relative'}} />;
155
+ ```
156
+
157
+ `handleCsProp` will make sure the `style` prop is passed to the `div` and that the `my-classname`
158
+ CSS class name appears on the `div`'s class list. Also the `cs` prop will add the appropriate styles
159
+ to the element via a CSS class name. If your component needs to handle being passed a `className`,
160
+ `style`, or `cs` prop, use `handleCsProp`.
161
+
162
+ ### handleCsProp API
163
+
164
+ <SymbolDoc hideHeading name="handleCsProp" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "14.1.0-1284-next.0",
3
+ "version": "15.0.0-alpha.1283-next.0",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -45,10 +45,10 @@
45
45
  "@emotion/styled": "^11.6.0",
46
46
  "@stackblitz/sdk": "^1.11.0",
47
47
  "@storybook/csf": "0.0.1",
48
- "@workday/canvas-kit-labs-react": "^14.1.0-1284-next.0",
49
- "@workday/canvas-kit-preview-react": "^14.1.0-1284-next.0",
50
- "@workday/canvas-kit-react": "^14.1.0-1284-next.0",
51
- "@workday/canvas-kit-styling": "^14.1.0-1284-next.0",
48
+ "@workday/canvas-kit-labs-react": "^15.0.0-alpha.1283-next.0",
49
+ "@workday/canvas-kit-preview-react": "^15.0.0-alpha.1283-next.0",
50
+ "@workday/canvas-kit-react": "^15.0.0-alpha.1283-next.0",
51
+ "@workday/canvas-kit-styling": "^15.0.0-alpha.1283-next.0",
52
52
  "@workday/canvas-system-icons-web": "^3.0.36",
53
53
  "@workday/canvas-tokens-web": "^3.1.1",
54
54
  "markdown-to-jsx": "^7.2.0",
@@ -61,5 +61,5 @@
61
61
  "mkdirp": "^1.0.3",
62
62
  "typescript": "5.0"
63
63
  },
64
- "gitHead": "ef232455072b3e17bf0e3bc3da24b954f92d5911"
64
+ "gitHead": "69e1e3b1fb6262a3db424e4b538fb6dc1afb20f2"
65
65
  }