@workday/canvas-kit-docs 7.0.0-alpha.90-next.17 → 7.0.0-alpha.91-next.18

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.
@@ -39,7 +39,7 @@ action. Multiple primary buttons make it confusing for the user to understand wh
39
39
  should take. Not all screens require a Primary Button.
40
40
 
41
41
  Primary Buttons have four sizes: `extraSmall`, `small`, `medium`, and `large`. Icons are supported
42
- for every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
42
+ for every size and can be positioned at the `start` or `end` with the `iconPosition` prop.
43
43
 
44
44
  <ExampleCodeBlock code={Primary} />
45
45
 
@@ -62,7 +62,7 @@ Buttons can be used on most pages without restrictions and work well for multipl
62
62
  weight. They can be used in conjunction with a Primary Button or independently.
63
63
 
64
64
  Secondary Buttons have four sizes: `extraSmall`, `small`, `medium`, and `large`. Icons are supported
65
- for every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
65
+ for every size and can be positioned at the `start` or `end` with the `iconPosition` prop.
66
66
 
67
67
  <ExampleCodeBlock code={Secondary} />
68
68
 
@@ -85,7 +85,7 @@ not visible until it is interacted with. Use Tertiary Buttons for supplemental a
85
85
  More”, “Read More” or “Select a File”. Tertiary Buttons are frequently used on Cards.
86
86
 
87
87
  Tertiary Buttons have three sizes: `extraSmall`, `small`, and `medium`. Icons are supported for
88
- every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
88
+ every size and can be positioned at the `start` or `end` with the `iconPosition` prop.
89
89
 
90
90
  <ExampleCodeBlock code={Tertiary} />
91
91
 
@@ -105,12 +105,12 @@ standards.
105
105
 
106
106
  <ExampleCodeBlock code={Error} />
107
107
 
108
- ## Props
108
+ ## Color Input Props
109
109
 
110
110
  Undocumented props are spread to the underlying `<input type="text">` element.
111
111
 
112
112
  <ArgsTable of={ColorInput} />
113
113
 
114
- ## Specifications
114
+ ## Color Input Specifications
115
115
 
116
116
  <Specifications file="ColorPicker.spec.ts" name="ColorInput" />
@@ -42,12 +42,12 @@ relative to the Color Preview. `labelPosition` accepts the following values:
42
42
 
43
43
  <ExampleCodeBlock code={LabelPosition} />
44
44
 
45
- ## Props
45
+ ## Color Preview Props
46
46
 
47
47
  Undocumented props are spread to the underlying `<input type="text">` element.
48
48
 
49
49
  <ArgsTable of={ColorPreview} />
50
50
 
51
- ## Specifications
51
+ ## Color Preview Specifications
52
52
 
53
53
  <Specifications file="ColorPicker.spec.ts" name="ColorPreview" />
@@ -6,27 +6,38 @@ import Usage from './examples/Flex/Usage';
6
6
  import {FlexStyle} from './examples/PropTables.splitprops.tsx';
7
7
 
8
8
 
9
- # Flex
9
+ # Canvas Kit Flex
10
10
 
11
11
  `Flex` is a low-level layout component that provides a common, ergonomic API for building
12
12
  one-dimensional layouts with
13
13
  [CSS Flexbox](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox).
14
14
 
15
- ## Table of Contents
15
+ ## Installation
16
16
 
17
- - [Flex](#flex)
18
- - [Table of Contents](#table-of-contents)
19
- - [Usage](#usage)
20
- - [What's the difference between `Flex` and `Box`?](#whats-the-difference-between-flex-and-box)
21
- - [Flex Props](#flex-props)
22
- - [Examples](#examples)
23
- - [Exhaustive Prop List](#exhaustive-prop-list)
17
+ ```sh
18
+ yarn add @workday/canvas-kit-react
19
+ ```
24
20
 
25
21
  ## Usage
26
22
 
23
+ ### Basic Example
24
+
27
25
  <ExampleCodeBlock code={Usage} />
28
26
 
29
- ## What's the difference between `Flex` and `Box`?
27
+ ### Rows and Columns
28
+
29
+ You can nest `Flex` components to build layouts with rows and columns.
30
+
31
+ <ExampleCodeBlock code={FlexLayout} />
32
+
33
+ ### Small Containers
34
+
35
+ You can also use `Flex` to create layouts within smaller containers, such as this card example
36
+ below:
37
+
38
+ <ExampleCodeBlock code={FlexCard} />
39
+
40
+ ### Flex vs. Box
30
41
 
31
42
  `Flex` is built with `Box` and has access to all `BoxProps`. The main differences between `Box` and
32
43
  `Flex` are:
@@ -49,17 +60,6 @@ through style props as well. There are seven flex container props:
49
60
 
50
61
  <ArgsTable of={FlexStyle} />
51
62
 
52
- ## Examples
53
-
54
- You can nest `Flex` components to build layouts with rows and columns.
55
-
56
- <ExampleCodeBlock code={FlexLayout} />
57
-
58
- You can also use `Flex` to create layouts within smaller containers, such as this card example
59
- below:
60
-
61
- <ExampleCodeBlock code={FlexCard} />
62
-
63
- ## Exhaustive Prop List
63
+ ### Flex Props (Exhaustive List)
64
64
 
65
65
  <ArgsTable of={Flex} />
@@ -9,7 +9,7 @@ import HStackCards from './examples/Stack/HStackCards';
9
9
  import VStackCards from './examples/Stack/VStackCards';
10
10
 
11
11
 
12
- # Stack, HStack, and VStack
12
+ # Canvas Kit Stack
13
13
 
14
14
  `Stack`, `HStack`, and `VStack` are higher-level layout components that provide an ergonomic API for
15
15
  building one-dimensional layouts with consistent spacing between elements. They're built on top of
@@ -17,48 +17,13 @@ building one-dimensional layouts with consistent spacing between elements. They'
17
17
  horizontal or vertical orientation. `HStack` and `VStack` will only align items in a horizontal or
18
18
  vertical orientation, respectively.
19
19
 
20
- ## Table of Contents
21
-
22
- - [Stack, HStack, and VStack](#stack-hstack-and-vstack)
23
- - [Table of Contents](#table-of-contents)
24
- - [Stack](#stack)
25
- - [Usage](#usage)
26
- - [What Stack Is & Isn't](#what-stack-is--isnt)
27
- - [Setting Direction](#setting-direction)
28
- - [Setting Space](#setting-space)
29
- - [Managing Child Elements](#managing-child-elements)
30
- - [Basic Usage](#basic-usage)
31
- - [Using `shouldWrapChildren`](#using-shouldwrapchildren)
32
- - [Using `Stack.Item`](#using-stackitem)
33
- - [Valid Children](#valid-children)
34
- - [Examples](#examples)
35
- - [HStack](#hstack)
36
- - [Usage](#usage-1)
37
- - [Example](#example)
38
- - [VStack](#vstack)
39
- - [Usage](#usage-2)
40
- - [Example](#example-1)
41
- - [Exhaustive Prop List](#exhaustive-prop-list)
42
-
43
- ## Stack
20
+ ## Installation
44
21
 
45
- `Stack` is a composable component that's helpful for creating layouts with equal spacing between
46
- elements. It can create horizontal or vertical stacks of elements.
47
-
48
- ### Usage
49
-
50
- ```tsx
51
- import {Stack, StackStyleProps} from '@workday/canvas-kit-react/layout';
22
+ ```sh
23
+ yarn add @workday/canvas-kit-react
52
24
  ```
53
25
 
54
- ### What Stack Is & Isn't
55
-
56
- The most important distinction to make with `Stack` is that it is _not a grid._ Grid components are
57
- able to align items along two dimensions (rows and columns), and `Stack` is only built to support
58
- one dimension (rows _or_ columns). That said, you can nest horizontal and vertical `Stack`
59
- components to create grid-like layouts.
60
-
61
- ### Thinking in Stacks
26
+ ## Usage
62
27
 
63
28
  `Stack` is a higher-level layout component, meaning:
64
29
 
@@ -67,14 +32,39 @@ components to create grid-like layouts.
67
32
 
68
33
  `Stack` has three core opinions that guide its API:
69
34
 
70
- - space should be equal between child elements
71
- - space should only exist between child elements
72
- - children should be semantic elements
35
+ - Space should be equal between child elements
36
+ - Space should only exist between child elements
37
+ - Children should be semantic elements
73
38
 
74
39
  Much of layout design is founded on these opinions. Whether its creating lists of navigation links,
75
40
  groups of cards, or collections of buttons, once you think in stacks, you'll see them everywhere.
76
41
 
77
- ### Setting Direction
42
+ ### Basic Example
43
+
44
+ `Stack` is a composable component that's helpful for creating layouts with equal spacing between
45
+ elements. It can create horizontal or vertical stacks of elements.
46
+
47
+ > The most important distinction to make with `Stack` is that it is _not a grid._ Grid components
48
+ > are able to align items along two dimensions (rows and columns), and `Stack` is only built to
49
+ > support one dimension (rows _or_ columns). That said, you can nest horizontal and vertical `Stack`
50
+ > components to create grid-like layouts.
51
+
52
+ `Stack` uses CSS pseudo-classes to apply margin to child elements. This makes it really simple to
53
+ get consistent spacing between child elements without much manual effort. Below is a basic example.
54
+ Note that `Stack` does not add any space above or below the child elements. This helps your element
55
+ fit nicely within their containers.
56
+
57
+ <ExampleCodeBlock code={BasicStack} />
58
+
59
+ Use this approach when:
60
+
61
+ - You want consistent space between child elements
62
+ - You don't need to apply custom margin to child elements
63
+ - Specifically `marginLeft`/`marginInlineStart` for horizontal stacks and `marginTop` for vertical
64
+ stacks
65
+ - You don't want to add extra markup to wrap child elements
66
+
67
+ #### Setting Direction
78
68
 
79
69
  The direction of the child elements is set with the `flexDirection` prop. This prop supports four
80
70
  directions: `column`, `column-reverse`, `row`, and `row-reverse`. By default, it will set the
@@ -86,7 +76,7 @@ direction to `row` as is consistent with the CSS Flexbox spec.
86
76
  > Note: `spacing` also supports bidirectionality automatically. This means you don't need to think
87
77
  > about it for localization as long as you properly pass the `direction` to the `theme` object un
88
78
 
89
- ### Setting Space
79
+ #### Setting Space
90
80
 
91
81
  The space between child elements is set with the `spacing` prop, which supports all space token and
92
82
  string values. `Stack` intentionally only sets space between elements and never outside. For
@@ -94,13 +84,13 @@ example: a vertical stack of three elements would only have margin added to the
94
84
  and third child elements. Keeping space between elements makes building layouts more block-like and
95
85
  predictable.
96
86
 
97
- ### Managing Child Elements
87
+ #### Managing Child Elements
98
88
 
99
89
  There are three ways to manage space between child elements with `Stack`.
100
90
 
101
- - implicit spacing applied directly to child elements (default behavior)
102
- - implicit wrapping child elements with `shouldWrapChildren`
103
- - explicit wrapping child elements with `Stack.Item`s.
91
+ - Implicit spacing applied directly to child elements (default behavior)
92
+ - Implicit wrapping child elements with `shouldWrapChildren`
93
+ - Explicit wrapping child elements with `Stack.Item`s.
104
94
 
105
95
  Each approach has its own benefits and limitations, which are discussed in further detail below. We
106
96
  chose to implicitly apply spacing to child elements as the default behavior because it requires the
@@ -109,77 +99,7 @@ hatches for when the default behavior becomes forced. Should you find none of th
109
99
  for your use case, we recommend using `Flex` instead of `Stack`, which will provide you with more
110
100
  flexibility.
111
101
 
112
- #### Basic Usage
113
-
114
- `Stack` uses CSS pseudo-classes to apply margin to child elements. This makes it really simple to
115
- get consistent spacing between child elements without much manual effort. Below is a basic example.
116
- Note that `Stack` does not add any space above or below the child elements. This helps your element
117
- fit nicely within their containers.
118
-
119
- <ExampleCodeBlock code={BasicStack} />
120
-
121
- Use this approach when:
122
-
123
- - you want consistent space between child elements
124
- - you don't need to apply custom margin to child elements
125
- - specifically `marginLeft`/`marginInlineStart` for horizontal stacks and `marginTop` for vertical
126
- stacks
127
- - you don't want to add extra markup to wrap child elements
128
-
129
- A side-effect of `Stack`'s pseduo-classes is an increased style specificity. This specificity can
130
- override the child element's margin styles. If that creates a problem, there are two recommended
131
- options available:
132
-
133
- - Use the `shouldWrapChildren` prop (implicit option)
134
- - Use `Stack.Item` (explicit option)
135
-
136
- Both are discussed below.
137
-
138
- #### Using `shouldWrapChildren`
139
-
140
- The `shouldWrapChildren` prop will implicitly wrap each child in a `Stack.Item` component (which is
141
- a `Box`) and apply the margin to it instead of the child element provided. This allows you to
142
- control the margin of the child elements you provide and avoiding style collisions. The trade-off is
143
- that you do not have direct access to the `Stack.Item` being rendered. If having access to that
144
- element is necessary, using `Stack.Item` explicitly (as described below) could be the best solution.
145
-
146
- The example below is a bit contrived but has enough information to convey the point. In this
147
- scenario, we have a horizontal stack of `SecondaryButton`s that render an icon, but they are
148
- visually divided into separate groupings. The navigational buttons are on the left, and the
149
- additional actions are spaced slightly further to the right. You could use two separate horizontal
150
- stacks here to achieve the same result, but you could also use `shouldWrapChildren` and then put
151
- additional margin only where needed. Either approach would be fine; it's a matter of personal
152
- preference.
153
-
154
- <ExampleCodeBlock code={ShouldWrapChildren} />
155
-
156
- Use this approach when:
157
-
158
- - you want consistent space between child elements
159
- - you need to apply custom margin to particular children
160
- - wrapping each child element won't create issues with other semantic elements
161
- - you don't want to explicitly add extra markup to wrap child elements
162
-
163
- #### Using `Stack.Item`
164
-
165
- Sometimes inserting implicit wrapper elements can be problematic when you need access to those
166
- elements. In those situations, `shouldWrapChildren` is not the best choice, and you should opt for
167
- wrapping children in `Stack.Item`s. A `Stack.Item` is a `Box` with some preset styles which can be
168
- overridden if needed.
169
-
170
- In the example below, we wanted to keep our `li` elements as direct children of the `ul` stack. So
171
- we're wrapping each of the links with `Stack.Item`s, casting them as `li`s and applying custom
172
- styles to each. This would not be possible with `shouldWrapChildren`.
173
-
174
- <ExampleCodeBlock code={StackItems} />
175
-
176
- Use this approach when:
177
-
178
- - you want consistent space between child elements
179
- - you need to have direct access to `Stack.Item` wrappers
180
- - wrapping each child element won't create issues with other semantic elements
181
-
182
- ### Valid Children
102
+ #### Valid Children
183
103
 
184
104
  Because `Stack` applies styles to children, it requires its immediate children to be valid child
185
105
  elements. For example, text outside of an HTML tag would not render if it was an immediate `Stack`
@@ -197,18 +117,20 @@ const ValidChildrenExample = () => {
197
117
  };
198
118
  ```
199
119
 
200
- ### Examples
120
+ ### Grid-like Layouts
201
121
 
202
122
  You can nest vertical and horizontal `Stack`s to create grid-like layouts. Here are three horizontal
203
123
  `Stack`s nested within a vertical `Stack`. The fourth row is a single `Flex` component.
204
124
 
205
125
  <ExampleCodeBlock code={NestedStacks} />
206
126
 
127
+ ### Small Containers
128
+
207
129
  You can also use `Stack` to manage smaller layouts, such as within Cards.
208
130
 
209
131
  <ExampleCodeBlock code={StackCard} />
210
132
 
211
- ## HStack
133
+ ### HStack
212
134
 
213
135
  `HStack` works identically to `Stack` but is limited to only `row` and `row-reverse` directions. It
214
136
  defaults to `row` if no `flexDirection` is provided.
@@ -217,35 +139,72 @@ defaults to `row` if no `flexDirection` is provided.
217
139
  > the direction or spacing for localization. The direction switching is handled by the CSS Flexbox
218
140
  > spec, and the spacing will flip direction based on the `direction` provided in the `theme` object.
219
141
 
220
- ### Usage
221
-
222
- ```tsx
223
- import {HStack, HStackStyleProps} from '@workday/canvas-kit-react/layout';
224
- ```
225
-
226
- ### Example
227
-
228
142
  In this example, `HStack` is placing three cards in a row with small spacing between them.
229
143
 
230
144
  <ExampleCodeBlock code={HStackCards} />
231
145
 
232
- ## VStack
146
+ ### VStack
233
147
 
234
148
  `VStack` works identically to `Stack` but is limited to only `column` and `column-reverse`
235
149
  directions. It defaults to `column` if no `flexDirection` is provided.
236
150
 
237
- ### Usage
151
+ In this example, `VStack` is placing three cards in a column with small spacing between them.
238
152
 
239
- ```tsx
240
- import {VStack, VStackStyleProps} from '@workday/canvas-kit-react/layout';
241
- ```
153
+ <ExampleCodeBlock code={VStackCards} />
242
154
 
243
- ### Example
155
+ ### shouldWrapChildren and Stack.Item
244
156
 
245
- In this example, `VStack` is placing three cards in a column with small spacing between them.
157
+ A side-effect of `Stack`'s pseudo-classes is an increased style specificity. This specificity can
158
+ override the child element's margin styles. If that creates a problem, there are two recommended
159
+ options available:
246
160
 
247
- <ExampleCodeBlock code={VStackCards} />
161
+ - Use the `shouldWrapChildren` prop (implicit option)
162
+ - Use `Stack.Item` (explicit option)
163
+
164
+ #### shouldWrapChildren
165
+
166
+ The `shouldWrapChildren` prop will implicitly wrap each child in a `Stack.Item` component (which is
167
+ a `Box`) and apply the margin to it instead of the child element provided. This allows you to
168
+ control the margin of the child elements you provide and avoiding style collisions. The trade-off is
169
+ that you do not have direct access to the `Stack.Item` being rendered. If having access to that
170
+ element is necessary, using `Stack.Item` explicitly (as described below) could be the best solution.
171
+
172
+ The example below is a bit contrived but has enough information to convey the point. In this
173
+ scenario, we have a horizontal stack of `SecondaryButton`s that render an icon, but they are
174
+ visually divided into separate groupings. The navigational buttons are on the left, and the
175
+ additional actions are spaced slightly further to the right. You could use two separate horizontal
176
+ stacks here to achieve the same result, but you could also use `shouldWrapChildren` and then put
177
+ additional margin only where needed. Either approach would be fine; it's a matter of personal
178
+ preference.
179
+
180
+ <ExampleCodeBlock code={ShouldWrapChildren} />
181
+
182
+ Use this approach when:
183
+
184
+ - You want consistent space between child elements
185
+ - You need to apply custom margin to particular children
186
+ - Wrapping each child element won't create issues with other semantic elements
187
+ - You don't want to explicitly add extra markup to wrap child elements
188
+
189
+ #### Stack.Item
190
+
191
+ Sometimes inserting implicit wrapper elements can be problematic when you need access to those
192
+ elements. In those situations, `shouldWrapChildren` is not the best choice, and you should opt for
193
+ wrapping children in `Stack.Item`s. A `Stack.Item` is a `Box` with some preset styles which can be
194
+ overridden if needed.
195
+
196
+ In the example below, we wanted to keep our `li` elements as direct children of the `ul` stack. So
197
+ we're wrapping each of the links with `Stack.Item`s, casting them as `li`s and applying custom
198
+ styles to each. This would not be possible with `shouldWrapChildren`.
199
+
200
+ <ExampleCodeBlock code={StackItems} />
201
+
202
+ Use this approach when:
203
+
204
+ - You want consistent space between child elements
205
+ - You need to have direct access to `Stack.Item` wrappers
206
+ - Wrapping each child element won't create issues with other semantic elements
248
207
 
249
- ## Exhaustive Prop List
208
+ ## Stack Props
250
209
 
251
210
  <ArgsTable of={Stack} />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "7.0.0-alpha.90-next.17+1c0258d7",
3
+ "version": "7.0.0-alpha.91-next.18+f92b7ba5",
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.90-next.17+1c0258d7"
44
+ "@workday/canvas-kit-react": "^7.0.0-alpha.91-next.18+f92b7ba5"
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": "1c0258d72c737b6a42791bad140183c01d736c03"
52
+ "gitHead": "f92b7ba590e19e7f55f7a6417d0d4b7ae3b1bba4"
53
53
  }