@workday/canvas-kit-docs 7.0.0-alpha.95-next.21 → 7.0.0-alpha.96-next.22
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/mdx/preview-react/pill/Pill.mdx +241 -0
- package/dist/mdx/preview-react/pill/examples/Basic.tsx +18 -0
- package/dist/mdx/preview-react/pill/examples/WithAvatar.tsx +21 -0
- package/dist/mdx/preview-react/pill/examples/WithCount.tsx +9 -0
- package/dist/mdx/preview-react/pill/examples/WithList.tsx +31 -0
- package/dist/mdx/preview-react/pill/examples/WithReadOnly.tsx +15 -0
- package/dist/mdx/preview-react/pill/examples/WithRemovable.tsx +25 -0
- package/dist/mdx/preview-react/pill/examples/test-avatar.png +0 -0
- package/package.json +3 -3
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import {Specifications} from '@workday/canvas-kit-docs';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
|
|
5
|
+
import WithReadOnly from './examples/WithReadOnly';
|
|
6
|
+
import WithAvatar from './examples/WithAvatar';
|
|
7
|
+
import Basic from './examples/Basic';
|
|
8
|
+
import WithCount from './examples/WithCount';
|
|
9
|
+
import WithRemovable from './examples/WithRemovable';
|
|
10
|
+
import WithList from './examples/WithList';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Canvas Kit Pill
|
|
14
|
+
|
|
15
|
+
`Pill`s are static or interactive indicators that allow users to input, filter, or label
|
|
16
|
+
information.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
yarn add @workday/canvas-kit-preview-react
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
`Pill`s are used to visually label objects on a page for quick recognition. They’re offered as both
|
|
27
|
+
static (read-only) and interactive elements. They allow users to filter a list or table, or label
|
|
28
|
+
information to help with scanning and organization.
|
|
29
|
+
|
|
30
|
+
### Basic Pills
|
|
31
|
+
|
|
32
|
+
By default a Pill is considered interactive, therefore it's default variant is `default`.All leading
|
|
33
|
+
elements (icons or avatars) are intended to be descriptive, helping support the label. Do not rely
|
|
34
|
+
on the leading element to indicate the interaction behavior.
|
|
35
|
+
|
|
36
|
+
#### Icon
|
|
37
|
+
|
|
38
|
+
You can render an icon inside the `Pill` with `Pill.Icon`. It will render a `plusIcon` by default,
|
|
39
|
+
but it can be customized by providing an icon to the `icon` prop. Because it uses `SystemIcon` under
|
|
40
|
+
the hood, you also have to all `SystemIconProps`.
|
|
41
|
+
|
|
42
|
+
<ExampleCodeBlock code={Basic} />
|
|
43
|
+
|
|
44
|
+
#### Avatar
|
|
45
|
+
|
|
46
|
+
You can render an avatar image inside the `Pill` with `Pill.Avatar`. It should appear before the
|
|
47
|
+
`Pill` text. Because it uses `Avatar` under the hood, you also have access to all `AvatarProps`.
|
|
48
|
+
|
|
49
|
+
<ExampleCodeBlock code={WithAvatar} />
|
|
50
|
+
|
|
51
|
+
#### Count
|
|
52
|
+
|
|
53
|
+
The count appears after the label. It is usually associated with the label. If you have a category,
|
|
54
|
+
the count will dirrectly correlate to that category.
|
|
55
|
+
|
|
56
|
+
<ExampleCodeBlock code={WithCount} />
|
|
57
|
+
|
|
58
|
+
### Read Only
|
|
59
|
+
|
|
60
|
+
If the `Pill` has `variant='readOnly'`, it will look like a read-only `Pill`. This is a
|
|
61
|
+
non-interactive element that is used to display information.
|
|
62
|
+
|
|
63
|
+
> **_NOTE:_** `maxWidth` measures the width of the `Pill.Label` (or text) and not the width of the
|
|
64
|
+
> entire `Pill`. By default, this `maxWidth` is set to `200px` and the text will be truncated with
|
|
65
|
+
> an ellipsis and render an OverflowTooltip on hover and focus. This max width can be changed by
|
|
66
|
+
> providing a `maxWidth` prop on the Pill.
|
|
67
|
+
|
|
68
|
+
<ExampleCodeBlock code={WithReadOnly} />
|
|
69
|
+
|
|
70
|
+
### Removable Pills
|
|
71
|
+
|
|
72
|
+
Removable `Pill`s display an `X` icon after the label. They have a smaller, more specific focus
|
|
73
|
+
state and click target to be more intentional about their actions and to avoid unintended removal.
|
|
74
|
+
|
|
75
|
+
You can define a removable `Pill` by providing a `variant='removable'` prop.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<Pill variant="removable">
|
|
79
|
+
Pink Shirts
|
|
80
|
+
<Pill.IconButton onClick={() => console.warn('clicked')} />
|
|
81
|
+
</Pill>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
In this case, we use a `Pill.IconButton` because the `X` becomes the focusable and clickable
|
|
85
|
+
element.
|
|
86
|
+
|
|
87
|
+
The default icon for `Pill.IconButton` is `xSmallIcon` but this can also be overwritten by passing
|
|
88
|
+
an `icon` prop to `Pill.IconButton`
|
|
89
|
+
|
|
90
|
+
<ExampleCodeBlock code={WithRemovable} />
|
|
91
|
+
|
|
92
|
+
### List of Pills
|
|
93
|
+
|
|
94
|
+
`Pill`s can often represent multiple pieces of information such as a filtered list of categories or
|
|
95
|
+
skills.
|
|
96
|
+
|
|
97
|
+
In order to achieve this, use our `HStack` component to wrap each `Pill` and space them out
|
|
98
|
+
accordingly.
|
|
99
|
+
|
|
100
|
+
<ExampleCodeBlock code={WithList} />
|
|
101
|
+
|
|
102
|
+
## Components
|
|
103
|
+
|
|
104
|
+
### Pill
|
|
105
|
+
|
|
106
|
+
By default, a `Pill` renders an interactive element that accepts subcomponents. By "interactive" we
|
|
107
|
+
mean that the Pill container is a focusable element (a `<button>`). All leading elements (icons or
|
|
108
|
+
avatars) are intended to be descriptive, helping support the label. They should not receive focus.
|
|
109
|
+
|
|
110
|
+
`Pill` is the container component. It also provides a React context model for its subcomponents.
|
|
111
|
+
Based on the `variant` prop this component will render different styled `Pill`s.
|
|
112
|
+
|
|
113
|
+
#### Usage
|
|
114
|
+
|
|
115
|
+
Example of read only:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
<Pill variant="readOnly">This is a read only</Pill>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Example of interactive:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
<Pill onClick={() => console.log('clicked')}>
|
|
125
|
+
<Pill.Avatar /> Regina Skeltor
|
|
126
|
+
</Pill>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Example of removable:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
<Pill variant="removable">
|
|
133
|
+
<Pill.Avatar /> Regina Skeltor
|
|
134
|
+
<Pill.IconButton onClick={() => console.log('clicked')} />
|
|
135
|
+
</Pill>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
If you set the `Pill` `variant` to `removable`, it will render a `<span>` element. You can then
|
|
139
|
+
provide a `Pill.IconButton` that acts as the focus target. This creates a smaller, more intentional
|
|
140
|
+
click target that prevents users from accidentally deleting an item.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<Pill variant="removable">
|
|
144
|
+
Shoes
|
|
145
|
+
<Pill.IconButton onClick={() => console.log('handle remove')} />
|
|
146
|
+
</Pill>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Props
|
|
150
|
+
|
|
151
|
+
<ArgsTable of={Pill} />
|
|
152
|
+
|
|
153
|
+
### Pill.Avatar
|
|
154
|
+
|
|
155
|
+
This component renders an avatar. It supports all props of the `Avatar` component.
|
|
156
|
+
|
|
157
|
+
#### Usage
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
<Pill variant="removable">
|
|
161
|
+
<Pill.Avatar url={avatarUrl} />
|
|
162
|
+
Regina Skeltor
|
|
163
|
+
<Pill.IconButton onClick={() => console.log('handle remove')} />
|
|
164
|
+
</Pill>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Props
|
|
168
|
+
|
|
169
|
+
<ArgsTable of={Pill.Avatar} />
|
|
170
|
+
|
|
171
|
+
### Pill.Count
|
|
172
|
+
|
|
173
|
+
This component renders its `children` as the count.
|
|
174
|
+
|
|
175
|
+
#### Usage
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
<Pill onClick={() => console.warn('clicked')}>
|
|
179
|
+
Shoes
|
|
180
|
+
<Pill.Count>30</Pill.Count>
|
|
181
|
+
</Pill>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Props
|
|
185
|
+
|
|
186
|
+
<ArgsTable of={Pill.Count} />
|
|
187
|
+
|
|
188
|
+
### Pill.Icon
|
|
189
|
+
|
|
190
|
+
This component renders an `icon`. It not be used with the `default` styling – not `readOnly` or
|
|
191
|
+
`removable` variants. By default it renders a `plusIcon` but it can be overridden by providing an
|
|
192
|
+
icon to the `icon` prop.
|
|
193
|
+
|
|
194
|
+
#### Usage
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
<Pill onClick={() => console.warn('clicked')}>
|
|
198
|
+
<Pill.Icon />
|
|
199
|
+
<Pill.Label>Regina Skeltor</Pill.Label>
|
|
200
|
+
</Pill>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Props
|
|
204
|
+
|
|
205
|
+
<ArgsTable of={Pill.Icon} />
|
|
206
|
+
|
|
207
|
+
### Pill.IconButton
|
|
208
|
+
|
|
209
|
+
This component renders a custom icon button. It is only intended to be used with the `removable`
|
|
210
|
+
variant. By default, it renders a `xSmallIcon` but can be overridden by providing an icon to the
|
|
211
|
+
`icon` prop.
|
|
212
|
+
|
|
213
|
+
#### Usage
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
<Pill variant="removable">
|
|
217
|
+
Pink Shirts
|
|
218
|
+
<Pill.IconButton onClick={() => console.warn('clicked')} />
|
|
219
|
+
</Pill>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### Props
|
|
223
|
+
|
|
224
|
+
<ArgsTable of={Pill.IconButton} />
|
|
225
|
+
|
|
226
|
+
### Pill.Label
|
|
227
|
+
|
|
228
|
+
This component renders a `<span>` that automatically handles overflow by rendering a tooltip.
|
|
229
|
+
There's no need to use this component directly since the overflow is handled for you automatically.
|
|
230
|
+
|
|
231
|
+
#### Usage
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
<Pill variant="readOnly">
|
|
235
|
+
<Pill.Label>Read-only</Pill.Label>
|
|
236
|
+
</Pill>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### Props
|
|
240
|
+
|
|
241
|
+
<ArgsTable of={Pill.Label} />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
|
|
5
|
+
import {HStack} from '@workday/canvas-kit-react';
|
|
6
|
+
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="xxs">
|
|
9
|
+
<Pill onClick={() => console.warn('clicked')}>
|
|
10
|
+
<Pill.Icon />
|
|
11
|
+
<Pill.Label>Regina Skeltor</Pill.Label>
|
|
12
|
+
</Pill>
|
|
13
|
+
<Pill onClick={() => console.warn('clicked')} disabled>
|
|
14
|
+
<Pill.Icon />
|
|
15
|
+
<Pill.Label>Regina Skeltor</Pill.Label>
|
|
16
|
+
</Pill>
|
|
17
|
+
</HStack>
|
|
18
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
// @ts-ignore: Cannot find module error
|
|
5
|
+
import testAvatar from './test-avatar.png';
|
|
6
|
+
import {HStack} from '@workday/canvas-kit-react';
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
return (
|
|
10
|
+
<HStack spacing="xxs">
|
|
11
|
+
<Pill onClick={() => console.warn('clicked')}>
|
|
12
|
+
<Pill.Avatar url={testAvatar} />
|
|
13
|
+
Regina Skeltor
|
|
14
|
+
</Pill>
|
|
15
|
+
<Pill onClick={() => console.warn('clicked')} disabled maxWidth={50}>
|
|
16
|
+
<Pill.Avatar url={testAvatar} />
|
|
17
|
+
Regina Skeltor
|
|
18
|
+
</Pill>
|
|
19
|
+
</HStack>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
import {Flex} from '@workday/canvas-kit-react';
|
|
5
|
+
|
|
6
|
+
const data = [
|
|
7
|
+
'Shoes',
|
|
8
|
+
'Pants',
|
|
9
|
+
'Dress Shoes',
|
|
10
|
+
'Color',
|
|
11
|
+
'Accessories',
|
|
12
|
+
'Luxury',
|
|
13
|
+
'Casual',
|
|
14
|
+
'Hats',
|
|
15
|
+
'Beanies',
|
|
16
|
+
'Glasses',
|
|
17
|
+
'Jewelry',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export default () => (
|
|
21
|
+
<Flex flexWrap="wrap">
|
|
22
|
+
{data.map((cat, index) => {
|
|
23
|
+
return (
|
|
24
|
+
<Pill key={index} variant="removable" marginBottom="xxs" marginInlineEnd="xxs">
|
|
25
|
+
<Pill.Label>{cat}</Pill.Label>
|
|
26
|
+
<Pill.IconButton onClick={() => console.log(`delete ${cat}`)} />
|
|
27
|
+
</Pill>
|
|
28
|
+
);
|
|
29
|
+
})}
|
|
30
|
+
</Flex>
|
|
31
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
|
|
5
|
+
import {HStack} from '@workday/canvas-kit-react';
|
|
6
|
+
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="xxs">
|
|
9
|
+
<Pill variant="readOnly">Read-only</Pill>
|
|
10
|
+
<Pill variant="readOnly" maxWidth={250}>
|
|
11
|
+
Read-only but with super long text in case you want to read a paragraph in a Pill which we
|
|
12
|
+
don't recommend
|
|
13
|
+
</Pill>
|
|
14
|
+
</HStack>
|
|
15
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
// @ts-ignore: Cannot find module error
|
|
5
|
+
import testAvatar from './test-avatar.png';
|
|
6
|
+
import {HStack} from '@workday/canvas-kit-react';
|
|
7
|
+
|
|
8
|
+
export default () => (
|
|
9
|
+
<HStack spacing="xxs">
|
|
10
|
+
<Pill variant="removable">
|
|
11
|
+
Pink Shirts
|
|
12
|
+
<Pill.IconButton onClick={() => console.warn('clicked')} />
|
|
13
|
+
</Pill>
|
|
14
|
+
<Pill variant="removable">
|
|
15
|
+
<Pill.Avatar url={testAvatar} />
|
|
16
|
+
Carolyn Grimaldi
|
|
17
|
+
<Pill.IconButton onClick={() => console.warn('clicked')} />
|
|
18
|
+
</Pill>
|
|
19
|
+
|
|
20
|
+
<Pill variant="removable" disabled>
|
|
21
|
+
<Pill.Label>This is a category that should not exist because it is too long</Pill.Label>
|
|
22
|
+
<Pill.IconButton />
|
|
23
|
+
</Pill>
|
|
24
|
+
</HStack>
|
|
25
|
+
);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.96-next.22+29ac2599",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@storybook/csf": "0.0.1",
|
|
44
|
-
"@workday/canvas-kit-react": "^7.0.0-alpha.
|
|
44
|
+
"@workday/canvas-kit-react": "^7.0.0-alpha.96-next.22+29ac2599"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"fs-extra": "^10.0.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"mkdirp": "^1.0.3",
|
|
50
50
|
"typescript": "4.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "29ac25992f1ca92c4cc885813c271120511038b5"
|
|
53
53
|
}
|