@workday/canvas-kit-docs 12.0.0-alpha.855-next.0 → 12.0.0-alpha.862-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.
- package/dist/es6/lib/docs.js +826 -195
- package/dist/es6/lib/specs.js +1 -1
- package/dist/mdx/12.0-UPGRADE-GUIDE.mdx +13 -3
- package/dist/mdx/react/_examples/examples/GlobalHeader.tsx +1 -1
- package/dist/mdx/react/avatar/avatar/Avatar.mdx +93 -0
- package/dist/mdx/react/avatar/avatar/examples/Basic.tsx +18 -0
- package/dist/mdx/react/avatar/avatar/examples/Button.tsx +21 -0
- package/dist/mdx/react/avatar/avatar/examples/CustomStyles.tsx +35 -0
- package/dist/mdx/react/avatar/avatar/examples/Image.tsx +26 -0
- package/dist/mdx/react/avatar/avatar/examples/LazyLoad.tsx +15 -0
- package/dist/mdx/react/avatar/avatar/examples/ObjectFit.tsx +25 -0
- package/dist/mdx/react/avatar/avatar/examples/Size.tsx +28 -0
- package/dist/mdx/react/avatar/avatar/examples/Variant.tsx +11 -0
- package/package.json +6 -6
package/dist/es6/lib/specs.js
CHANGED
|
@@ -43,9 +43,8 @@ A note to the reader:
|
|
|
43
43
|
- [Select (Preview)](#select-preview)
|
|
44
44
|
- [Component Updates](#component-updates)
|
|
45
45
|
- [Styling API and CSS Tokens](#styling-api-and-css-tokens)
|
|
46
|
+
- [Avatar](#avatar)
|
|
46
47
|
- [Text Area](#text-area)
|
|
47
|
-
- [Style Utility Updates](#style-utility-updates)
|
|
48
|
-
- [createStencil](#createstencil)
|
|
49
48
|
- [Troubleshooting](#troubleshooting)
|
|
50
49
|
- [Glossary](#glossary)
|
|
51
50
|
- [Main](#main)
|
|
@@ -94,7 +93,8 @@ from Main instead.
|
|
|
94
93
|
### Styling API and CSS Tokens
|
|
95
94
|
|
|
96
95
|
**PRs:** [#2825](https://github.com/Workday/canvas-kit/pull/2825),
|
|
97
|
-
[#2795](https://github.com/Workday/canvas-kit/pull/2795)
|
|
96
|
+
[#2795](https://github.com/Workday/canvas-kit/pull/2795),
|
|
97
|
+
[#2793](https://github.com/Workday/canvas-kit/pull/2793)
|
|
98
98
|
|
|
99
99
|
Several components have been refactored to use our new
|
|
100
100
|
[Canvas Tokens](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs) and
|
|
@@ -103,6 +103,7 @@ The React interface **has not changed**, but CSS variables are now used for dyna
|
|
|
103
103
|
|
|
104
104
|
The following components are affected:
|
|
105
105
|
|
|
106
|
+
- `Avatar`
|
|
106
107
|
- `Dialog`
|
|
107
108
|
- `Modal`
|
|
108
109
|
- `Popup`
|
|
@@ -114,6 +115,15 @@ The following components are affected:
|
|
|
114
115
|
> with `cs` in our
|
|
115
116
|
> [documentation](https://workday.github.io/canvas-kit/?path=/docs/styling-basics--cs-prop).
|
|
116
117
|
|
|
118
|
+
### Avatar
|
|
119
|
+
|
|
120
|
+
- Avatar no longer uses `SystemIconCircle` for sizing.
|
|
121
|
+
- `Avatar.Size` is no longer supported. The `size` prop type has change to accept the following:
|
|
122
|
+
`"extraExtraLarge" | "extraLarge" | "large" | "medium" | "small" | "extraSmall" | (string{})`
|
|
123
|
+
- `Avatar.Variant` is no longer supported. Enum `AvatarVariant` has been removed. The `variant` type
|
|
124
|
+
prop now accepts `"dark" | "light"`
|
|
125
|
+
- The `as` prop now accepts any element, not just `div`.
|
|
126
|
+
|
|
117
127
|
### Text Area
|
|
118
128
|
|
|
119
129
|
**PR:** [#2825](https://github.com/Workday/canvas-kit/pull/2825)
|
|
@@ -31,7 +31,7 @@ export default () => (
|
|
|
31
31
|
<TertiaryButton aria-label="messages" icon={assistantIcon} />
|
|
32
32
|
<TertiaryButton aria-label="notifications" icon={notificationsIcon} />
|
|
33
33
|
<TertiaryButton aria-label="inbox" icon={inboxIcon} />
|
|
34
|
-
<Avatar size=
|
|
34
|
+
<Avatar size="medium" variant="light" />
|
|
35
35
|
</GlobalHeader.Item>
|
|
36
36
|
</GlobalHeader>
|
|
37
37
|
);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {Specifications, SymbolDoc, SymbolDescription} from '@workday/canvas-kit-docs';
|
|
2
|
+
|
|
3
|
+
import {Basic} from '../avatar/examples/Basic';
|
|
4
|
+
import {Button} from '../avatar/examples/Button';
|
|
5
|
+
import {Image} from '../avatar/examples/Image';
|
|
6
|
+
import {LazyLoad} from '../avatar/examples/LazyLoad';
|
|
7
|
+
import {ObjectFit} from '../avatar/examples/ObjectFit';
|
|
8
|
+
import {Size} from '../avatar/examples/Size';
|
|
9
|
+
import {Variant} from '../avatar/examples/Variant';
|
|
10
|
+
import {CustomStyles} from '../avatar/examples/CustomStyles';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Canvas Kit Avatar
|
|
14
|
+
|
|
15
|
+
Represents a person's profile.
|
|
16
|
+
|
|
17
|
+
[> Workday Design Reference](https://canvas.workdaydesign.com/components/indicators/avatar)
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
yarn add @workday/canvas-kit-react
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
<SymbolDescription name="Avatar" fileName="/react/" />
|
|
28
|
+
|
|
29
|
+
The example below shows multiple instances of a `Avatar` with various configurations.
|
|
30
|
+
|
|
31
|
+
### Basic
|
|
32
|
+
|
|
33
|
+
By default, the Avatar renders a `button` element. If yo'd like to change the default element, use
|
|
34
|
+
the `as` prop.
|
|
35
|
+
|
|
36
|
+
<ExampleCodeBlock code={Basic} />
|
|
37
|
+
|
|
38
|
+
### Button
|
|
39
|
+
|
|
40
|
+
Like many of our components, Avatar accepts an `as` prop, which lets you change the underlying
|
|
41
|
+
semantic element to a `div`. This should be done with caution to ensure the best accessibility.
|
|
42
|
+
Generally, `<button>` elements should be used for actions.
|
|
43
|
+
|
|
44
|
+
<ExampleCodeBlock code={Button} />
|
|
45
|
+
|
|
46
|
+
### Variant
|
|
47
|
+
|
|
48
|
+
Avatar defaults to using a `"light"` `variant` property. You can change the `variant` prop to "dark"
|
|
49
|
+
by including `variant="dark"`.
|
|
50
|
+
|
|
51
|
+
<ExampleCodeBlock code={Variant} />
|
|
52
|
+
|
|
53
|
+
### Size
|
|
54
|
+
|
|
55
|
+
Avatar defaults to using a `"medium"` `size` property. You can change the `size` prop to various
|
|
56
|
+
sizing options. See Component API for more details.
|
|
57
|
+
|
|
58
|
+
Additionally, you can explicitly specify the size you want for the Avatar in pixels or rems.
|
|
59
|
+
|
|
60
|
+
<ExampleCodeBlock code={Size} />
|
|
61
|
+
|
|
62
|
+
### Image
|
|
63
|
+
|
|
64
|
+
Avatar renders an image when the `url` prop is defined.
|
|
65
|
+
|
|
66
|
+
<ExampleCodeBlock code={Image} />
|
|
67
|
+
|
|
68
|
+
### Object Fit
|
|
69
|
+
|
|
70
|
+
Avatar defaults to using `contain` for object-fit. You can change this property to any other
|
|
71
|
+
acceptable `object-fit` properties. For best fit, try to use square images.
|
|
72
|
+
|
|
73
|
+
<ExampleCodeBlock code={ObjectFit} />
|
|
74
|
+
|
|
75
|
+
### Lazy Load
|
|
76
|
+
|
|
77
|
+
Example of implementing lazy load behavior with Avatar.
|
|
78
|
+
|
|
79
|
+
<ExampleCodeBlock code={LazyLoad} />
|
|
80
|
+
|
|
81
|
+
### Custom Styling
|
|
82
|
+
|
|
83
|
+
To change the background color of the Avatar, you can use our `createStencil` functionality.
|
|
84
|
+
|
|
85
|
+
<ExampleCodeBlock code={CustomStyles} />
|
|
86
|
+
|
|
87
|
+
## Component API
|
|
88
|
+
|
|
89
|
+
<SymbolDoc name="Avatar" fileName="/react/" />
|
|
90
|
+
|
|
91
|
+
## Specifications
|
|
92
|
+
|
|
93
|
+
<Specifications file="Avatar.spec.ts" name="Avatar" />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
3
|
+
import {createStyles} from '@workday/canvas-kit-styling';
|
|
4
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
5
|
+
|
|
6
|
+
const handleAvatarButtonClick = () => console.log('AvatarButton clicked');
|
|
7
|
+
|
|
8
|
+
const containerStyles = createStyles({
|
|
9
|
+
display: 'inline-flex',
|
|
10
|
+
gap: system.space.x2,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default () => (
|
|
14
|
+
<div className={containerStyles}>
|
|
15
|
+
<Avatar onClick={handleAvatarButtonClick} />
|
|
16
|
+
<Avatar as="div" />
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
3
|
+
import {createStyles} from '@workday/canvas-kit-styling';
|
|
4
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
5
|
+
// @ts-ignore: Cannot find module error
|
|
6
|
+
import testAvatar from '../../test-avatar.png';
|
|
7
|
+
|
|
8
|
+
const handleAvatarButtonClick = () => console.log('AvatarButton clicked');
|
|
9
|
+
|
|
10
|
+
const containerStyles = createStyles({
|
|
11
|
+
display: 'inline-flex',
|
|
12
|
+
gap: system.space.x2,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default () => (
|
|
16
|
+
<div className={containerStyles}>
|
|
17
|
+
<Avatar variant="dark" onClick={handleAvatarButtonClick} />
|
|
18
|
+
<Avatar onClick={handleAvatarButtonClick} />
|
|
19
|
+
<Avatar url={testAvatar} onClick={handleAvatarButtonClick} />
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
3
|
+
import {createStencil, createStyles} from '@workday/canvas-kit-styling';
|
|
4
|
+
import {base, system} from '@workday/canvas-tokens-web';
|
|
5
|
+
import {systemIconStencil} from '../../../../icon';
|
|
6
|
+
|
|
7
|
+
const customBlueAvatarStencil = createStencil({
|
|
8
|
+
base: {
|
|
9
|
+
backgroundColor: base.berrySmoothie400,
|
|
10
|
+
['[data-slot="avatar-icon"]']: {
|
|
11
|
+
[systemIconStencil.vars.color]: base.berrySmoothie100,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const customGreenAvatarStencil = createStencil({
|
|
17
|
+
base: {
|
|
18
|
+
backgroundColor: base.watermelon400,
|
|
19
|
+
['[data-slot="avatar-icon"]']: {
|
|
20
|
+
[systemIconStencil.vars.color]: base.watermelon100,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const containerStyles = createStyles({
|
|
26
|
+
display: 'inline-flex',
|
|
27
|
+
gap: system.space.x2,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export default () => (
|
|
31
|
+
<div className={containerStyles}>
|
|
32
|
+
<Avatar as="div" {...customBlueAvatarStencil()} />
|
|
33
|
+
<Avatar as="div" {...customGreenAvatarStencil()} />
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
3
|
+
// @ts-ignore: Cannot find module error
|
|
4
|
+
import testAvatar from '../../test-avatar.png';
|
|
5
|
+
import {createStyles} from '@workday/canvas-kit-styling';
|
|
6
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
7
|
+
|
|
8
|
+
const containerStyles = createStyles({
|
|
9
|
+
display: 'flex',
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
gap: system.space.x2,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export default () => (
|
|
15
|
+
<div className={containerStyles}>
|
|
16
|
+
<h3>Working Images</h3>
|
|
17
|
+
<Avatar size="extraExtraLarge" as="div" url={testAvatar} />
|
|
18
|
+
<Avatar size="extraLarge" as="div" url={testAvatar} />
|
|
19
|
+
<Avatar size="large" as="div" url={testAvatar} />
|
|
20
|
+
<Avatar size="medium" as="div" url={testAvatar} />
|
|
21
|
+
<Avatar size="small" as="div" url={testAvatar} />
|
|
22
|
+
<Avatar size="extraSmall" as="div" url={testAvatar} />
|
|
23
|
+
<h3>Broken Image</h3>
|
|
24
|
+
<Avatar url="/fake/path/to/image.png" as="div" />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
3
|
+
// @ts-ignore: Cannot find module error
|
|
4
|
+
import testAvatar from '../../test-avatar.png';
|
|
5
|
+
|
|
6
|
+
export default () => (
|
|
7
|
+
<div className="story">
|
|
8
|
+
{Array.from({length: 5}, (v, index) => (
|
|
9
|
+
<>
|
|
10
|
+
<Avatar key={index} as="div" size="medium" url={testAvatar + '?v=' + index} />
|
|
11
|
+
<br />
|
|
12
|
+
</>
|
|
13
|
+
))}
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
3
|
+
import {px2rem} from '@workday/canvas-kit-styling';
|
|
4
|
+
|
|
5
|
+
export default () => (
|
|
6
|
+
<div className="story">
|
|
7
|
+
<h3>Original Rectangle Image</h3>
|
|
8
|
+
<img alt="" src="https://picsum.photos/id/237/300/200" />
|
|
9
|
+
<h3>Object fit on a Rectangle Image</h3>
|
|
10
|
+
<Avatar as="div" url="https://picsum.photos/id/237/300/200" />
|
|
11
|
+
<h3>Object fit on a Rectangle Image using Dynamic Size</h3>
|
|
12
|
+
<Avatar
|
|
13
|
+
as="div"
|
|
14
|
+
size={px2rem(200)}
|
|
15
|
+
url="https://picsum.photos/id/237/300/200"
|
|
16
|
+
objectFit="contain"
|
|
17
|
+
/>
|
|
18
|
+
<h3>Original Square Image</h3>
|
|
19
|
+
<img alt="" src="https://picsum.photos/id/237/300/300" />
|
|
20
|
+
<h3>Object fit on a Square Image</h3>
|
|
21
|
+
<Avatar as="div" url="https://picsum.photos/id/237/300/300" />
|
|
22
|
+
<h3>Object fit on a Square Image using Dynamic Size</h3>
|
|
23
|
+
<Avatar as="div" size={px2rem(200)} url="https://picsum.photos/id/237/300/300" />
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
3
|
+
import {px2rem} from '@workday/canvas-kit-styling';
|
|
4
|
+
|
|
5
|
+
export default () => (
|
|
6
|
+
<div className="story">
|
|
7
|
+
<h3>Extra-Extra Large</h3>
|
|
8
|
+
<Avatar as="div" size="extraExtraLarge" />
|
|
9
|
+
<h3>Extra Large</h3>
|
|
10
|
+
<Avatar as="div" size="extraLarge" />
|
|
11
|
+
<h3>Large</h3>
|
|
12
|
+
<Avatar as="div" size="large" />
|
|
13
|
+
<h3>Medium</h3>
|
|
14
|
+
<Avatar as="div" size="medium" />
|
|
15
|
+
<h3>Small</h3>
|
|
16
|
+
<Avatar as="div" size="small" />
|
|
17
|
+
<h3>Extra Small</h3>
|
|
18
|
+
<Avatar as="div" size="extraSmall" />
|
|
19
|
+
<h3>30px</h3>
|
|
20
|
+
<Avatar as="div" size={px2rem(30)} />
|
|
21
|
+
<h3>40px</h3>
|
|
22
|
+
<Avatar as="div" size={px2rem(40)} />
|
|
23
|
+
<h3>3rem</h3>
|
|
24
|
+
<Avatar as="div" size="3rem" />
|
|
25
|
+
<h3>4rem</h3>
|
|
26
|
+
<Avatar as="div" size="4rem" />
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {Avatar} from '@workday/canvas-kit-react/avatar';
|
|
3
|
+
|
|
4
|
+
export default () => (
|
|
5
|
+
<div className="story">
|
|
6
|
+
<h3>Light</h3>
|
|
7
|
+
<Avatar as="div" size="medium" />
|
|
8
|
+
<h3>Dark</h3>
|
|
9
|
+
<Avatar as="div" size="medium" variant="dark" />
|
|
10
|
+
</div>
|
|
11
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.862-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",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@emotion/styled": "^11.6.0",
|
|
46
46
|
"@storybook/csf": "0.0.1",
|
|
47
|
-
"@workday/canvas-kit-labs-react": "^12.0.0-alpha.
|
|
48
|
-
"@workday/canvas-kit-preview-react": "^12.0.0-alpha.
|
|
49
|
-
"@workday/canvas-kit-react": "^12.0.0-alpha.
|
|
50
|
-
"@workday/canvas-kit-styling": "^12.0.0-alpha.
|
|
47
|
+
"@workday/canvas-kit-labs-react": "^12.0.0-alpha.862-next.0",
|
|
48
|
+
"@workday/canvas-kit-preview-react": "^12.0.0-alpha.862-next.0",
|
|
49
|
+
"@workday/canvas-kit-react": "^12.0.0-alpha.862-next.0",
|
|
50
|
+
"@workday/canvas-kit-styling": "^12.0.0-alpha.862-next.0",
|
|
51
51
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
52
52
|
"@workday/canvas-tokens-web": "^2.0.0",
|
|
53
53
|
"markdown-to-jsx": "^7.2.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"mkdirp": "^1.0.3",
|
|
60
60
|
"typescript": "4.2"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "3b7726adda5b24aff4229e4ee8ca9f4f83522be3"
|
|
63
63
|
}
|