@workday/canvas-kit-docs 15.1.7 → 15.1.10
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 +860 -8
- package/dist/es6/lib/specs.js +120 -0
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/mdx/preview-react/status-indicator/StatusIndicator.mdx +119 -6
- package/dist/mdx/preview-react/status-indicator/examples/Icon.tsx +2 -2
- package/dist/mdx/react/menu/Menu.mdx +2 -0
- package/dist/mdx/react/menu/examples/NestedSiblings.tsx +60 -0
- package/dist/mdx/styling/mdx/Stencils.mdx +19 -1
- package/package.json +6 -6
package/dist/es6/lib/specs.js
CHANGED
|
@@ -1759,6 +1759,20 @@ module.exports = {specifications: [
|
|
|
1759
1759
|
}
|
|
1760
1760
|
]
|
|
1761
1761
|
},
|
|
1762
|
+
{
|
|
1763
|
+
"type": "describe",
|
|
1764
|
+
"name": "when a disabled item has focus and the menu is closed and reopened",
|
|
1765
|
+
"children": [
|
|
1766
|
+
{
|
|
1767
|
+
"type": "it",
|
|
1768
|
+
"name": "should move focus to the first item instead of the disabled item"
|
|
1769
|
+
},
|
|
1770
|
+
{
|
|
1771
|
+
"type": "it",
|
|
1772
|
+
"name": "should not leave focus on the disabled item"
|
|
1773
|
+
}
|
|
1774
|
+
]
|
|
1775
|
+
},
|
|
1762
1776
|
{
|
|
1763
1777
|
"type": "describe",
|
|
1764
1778
|
"name": "when the enter key is pressed",
|
|
@@ -1781,6 +1795,112 @@ module.exports = {specifications: [
|
|
|
1781
1795
|
}
|
|
1782
1796
|
]
|
|
1783
1797
|
},
|
|
1798
|
+
{
|
|
1799
|
+
"type": "describe",
|
|
1800
|
+
"name": "given the [Components/Popups/Menu, NestedSiblings] story is rendered",
|
|
1801
|
+
"children": [
|
|
1802
|
+
{
|
|
1803
|
+
"type": "describe",
|
|
1804
|
+
"name": "when the \"Second Item\" submenu is opened by hovering",
|
|
1805
|
+
"children": [
|
|
1806
|
+
{
|
|
1807
|
+
"type": "it",
|
|
1808
|
+
"name": "should set aria-expanded to true on \"Second Item\""
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
"type": "describe",
|
|
1812
|
+
"name": "when the sibling \"Third Item\" is then hovered",
|
|
1813
|
+
"children": [
|
|
1814
|
+
{
|
|
1815
|
+
"type": "it",
|
|
1816
|
+
"name": "should close the \"Second Item\" submenu"
|
|
1817
|
+
},
|
|
1818
|
+
{
|
|
1819
|
+
"type": "it",
|
|
1820
|
+
"name": "should set aria-expanded to false on \"Second Item\""
|
|
1821
|
+
},
|
|
1822
|
+
{
|
|
1823
|
+
"type": "it",
|
|
1824
|
+
"name": "should leave only the root menu and one submenu open"
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
"type": "describe",
|
|
1828
|
+
"name": "when the original \"Second Item\" is hovered again",
|
|
1829
|
+
"children": [
|
|
1830
|
+
{
|
|
1831
|
+
"type": "it",
|
|
1832
|
+
"name": "should close the \"Third Item\" submenu"
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
"type": "it",
|
|
1836
|
+
"name": "should leave only the root menu and one submenu open"
|
|
1837
|
+
}
|
|
1838
|
+
]
|
|
1839
|
+
}
|
|
1840
|
+
]
|
|
1841
|
+
}
|
|
1842
|
+
]
|
|
1843
|
+
},
|
|
1844
|
+
{
|
|
1845
|
+
"type": "describe",
|
|
1846
|
+
"name": "when a submenu is opened with the right arrow key",
|
|
1847
|
+
"children": [
|
|
1848
|
+
{
|
|
1849
|
+
"type": "it",
|
|
1850
|
+
"name": "should open the submenu"
|
|
1851
|
+
},
|
|
1852
|
+
{
|
|
1853
|
+
"type": "it",
|
|
1854
|
+
"name": "should keep the submenu open and move focus into it"
|
|
1855
|
+
},
|
|
1856
|
+
{
|
|
1857
|
+
"type": "describe",
|
|
1858
|
+
"name": "when the left arrow key is pressed",
|
|
1859
|
+
"children": [
|
|
1860
|
+
{
|
|
1861
|
+
"type": "it",
|
|
1862
|
+
"name": "should close the submenu"
|
|
1863
|
+
},
|
|
1864
|
+
{
|
|
1865
|
+
"type": "it",
|
|
1866
|
+
"name": "should return focus to the \"Second Item\" target"
|
|
1867
|
+
}
|
|
1868
|
+
]
|
|
1869
|
+
}
|
|
1870
|
+
]
|
|
1871
|
+
}
|
|
1872
|
+
]
|
|
1873
|
+
},
|
|
1874
|
+
{
|
|
1875
|
+
"type": "describe",
|
|
1876
|
+
"name": "given the [Components/Popups/Menu, NestedDynamic] story is rendered",
|
|
1877
|
+
"children": [
|
|
1878
|
+
{
|
|
1879
|
+
"type": "describe",
|
|
1880
|
+
"name": "when hovering deeper into a chain of nested submenus",
|
|
1881
|
+
"children": [
|
|
1882
|
+
{
|
|
1883
|
+
"type": "it",
|
|
1884
|
+
"name": "should keep the ancestor submenu open"
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
"type": "it",
|
|
1888
|
+
"name": "should keep every menu in the open chain visible"
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
"type": "describe",
|
|
1892
|
+
"name": "when hovering back onto the ancestor item in the open trail",
|
|
1893
|
+
"children": [
|
|
1894
|
+
{
|
|
1895
|
+
"type": "it",
|
|
1896
|
+
"name": "should keep the open trail intact"
|
|
1897
|
+
}
|
|
1898
|
+
]
|
|
1899
|
+
}
|
|
1900
|
+
]
|
|
1901
|
+
}
|
|
1902
|
+
]
|
|
1903
|
+
},
|
|
1784
1904
|
{
|
|
1785
1905
|
"type": "describe",
|
|
1786
1906
|
"name": "given the [Testing/Popups/Menu, MenuWithFallbackPlacements] example is rendered",
|
|
@@ -18,11 +18,11 @@ export const packageJSONFile = `{
|
|
|
18
18
|
"@emotion/react": "11.11.4",
|
|
19
19
|
"@types/react": "18.2.60",
|
|
20
20
|
"@types/react-dom": "18.2.19",
|
|
21
|
-
"@workday/canvas-kit-labs-react": "15.1.
|
|
22
|
-
"@workday/canvas-kit-preview-react": "15.1.
|
|
23
|
-
"@workday/canvas-kit-react": "15.1.
|
|
24
|
-
"@workday/canvas-kit-react-fonts": "^15.1.
|
|
25
|
-
"@workday/canvas-kit-styling": "15.1.
|
|
21
|
+
"@workday/canvas-kit-labs-react": "15.1.10",
|
|
22
|
+
"@workday/canvas-kit-preview-react": "15.1.10",
|
|
23
|
+
"@workday/canvas-kit-react": "15.1.10",
|
|
24
|
+
"@workday/canvas-kit-react-fonts": "^15.1.10",
|
|
25
|
+
"@workday/canvas-kit-styling": "15.1.10",
|
|
26
26
|
"@workday/canvas-system-icons-web": "4.0.2",
|
|
27
27
|
"@workday/canvas-expressive-icons-web": "1.0.1",
|
|
28
28
|
"@workday/canvas-tokens-web": "4.2.0"
|
|
@@ -19,11 +19,11 @@ export const packageJSONFile = `{
|
|
|
19
19
|
"@emotion/react": "11.11.4",
|
|
20
20
|
"@types/react": "18.2.60",
|
|
21
21
|
"@types/react-dom": "18.2.19",
|
|
22
|
-
"@workday/canvas-kit-labs-react": "15.1.
|
|
23
|
-
"@workday/canvas-kit-preview-react": "15.1.
|
|
24
|
-
"@workday/canvas-kit-react": "15.1.
|
|
25
|
-
"@workday/canvas-kit-react-fonts": "^15.1.
|
|
26
|
-
"@workday/canvas-kit-styling": "15.1.
|
|
22
|
+
"@workday/canvas-kit-labs-react": "15.1.10",
|
|
23
|
+
"@workday/canvas-kit-preview-react": "15.1.10",
|
|
24
|
+
"@workday/canvas-kit-react": "15.1.10",
|
|
25
|
+
"@workday/canvas-kit-react-fonts": "^15.1.10",
|
|
26
|
+
"@workday/canvas-kit-styling": "15.1.10",
|
|
27
27
|
"@workday/canvas-system-icons-web": "4.0.2",
|
|
28
28
|
"@workday/canvas-expressive-icons-web": "1.0.1",
|
|
29
29
|
"@workday/canvas-tokens-web": "4.2.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
|
|
2
2
|
|
|
3
3
|
import Basic from './examples/Basic';
|
|
4
4
|
import Custom from './examples/Custom';
|
|
@@ -46,6 +46,10 @@ position of the icon may be adjusted depending on where you place it in the mark
|
|
|
46
46
|
|
|
47
47
|
<ExampleCodeBlock code={Icon} />
|
|
48
48
|
|
|
49
|
+
> **Accessibility Note**: In this example, the icon is used as a decoration and is intentionally
|
|
50
|
+
> hidden from screen readers. If you're using icons to convey additional information, add
|
|
51
|
+
> `role="img"` and a translated `aria-label` string to `StatusIndicator.Icon`.
|
|
52
|
+
|
|
49
53
|
### Overflow
|
|
50
54
|
|
|
51
55
|
We **strongly** discourage using text in a `StatusIndicator` which will cause it to exceed its
|
|
@@ -61,14 +65,16 @@ of `StatusIndicator` via [style props](/get-started/for-developers/documentation
|
|
|
61
65
|
Set the `variant` prop of `StatusIndicator` to adjust its background color. `variant` accepts the
|
|
62
66
|
following values:
|
|
63
67
|
|
|
64
|
-
- `gray`
|
|
65
|
-
- `orange`
|
|
66
|
-
- `blue`
|
|
67
|
-
- `green`
|
|
68
|
-
- `red`
|
|
68
|
+
- `neutral` (default; `gray` is a deprecated alias)
|
|
69
|
+
- `caution` (`orange` is a deprecated alias)
|
|
70
|
+
- `info` (`blue` is a deprecated alias)
|
|
71
|
+
- `positive` (`green` is a deprecated alias)
|
|
72
|
+
- `critical` (`red` is a deprecated alias)
|
|
69
73
|
- `transparent`
|
|
70
74
|
|
|
71
75
|
The background color dictated by the `variant` will be dark or light based on the `emphasis`.
|
|
76
|
+
`variant` and `emphasis` change color only—they do not change the accessible name. Put the status
|
|
77
|
+
meaning in **`StatusIndicator.Label`**.
|
|
72
78
|
|
|
73
79
|
<ExampleCodeBlock code={Variants} />
|
|
74
80
|
|
|
@@ -84,6 +90,113 @@ Status Indicator and its subcomponents support custom styling via the `cs` prop.
|
|
|
84
90
|
information, check our
|
|
85
91
|
["How To Customize Styles"](https://workday.github.io/canvas-kit/?path=/docs/styling-guides-customizing-styles--docs).
|
|
86
92
|
|
|
93
|
+
## Accessibility
|
|
94
|
+
|
|
95
|
+
`StatusIndicator` is a compact, **non-interactive** status label. The accessibility goal is that
|
|
96
|
+
assistive technology users get the same status meaning as sighted users from
|
|
97
|
+
**`StatusIndicator.Label`** text—not from color, emphasis, or a decorative icon.
|
|
98
|
+
|
|
99
|
+
### Minimum Accessible Structure
|
|
100
|
+
|
|
101
|
+
The following matches the [Basic Example](#basic-example): a container and a visible label. Icon is
|
|
102
|
+
optional.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
|
|
106
|
+
|
|
107
|
+
<StatusIndicator>
|
|
108
|
+
<StatusIndicator.Label>Unpublished</StatusIndicator.Label>
|
|
109
|
+
</StatusIndicator>;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Always include **`StatusIndicator.Label`** with concise text that names the status. Do not rely on
|
|
113
|
+
**`variant`**, **`emphasis`**, or **`StatusIndicator.Icon`** as the only indicator of meaning.
|
|
114
|
+
|
|
115
|
+
### Built-in Behaviors
|
|
116
|
+
|
|
117
|
+
Canvas Kit applies visual layout and color through `statusIndicatorStencil` when you compose
|
|
118
|
+
**`StatusIndicator`**, **`StatusIndicator.Label`**, and optionally **`StatusIndicator.Icon`**. It
|
|
119
|
+
does **not** apply `role="img"` or an accessible name on the icon. **Do not duplicate them** in
|
|
120
|
+
consuming code. Only add icon ARIA when the informative-icon requirement below applies.
|
|
121
|
+
|
|
122
|
+
**ARIA and DOM** (_applied by subcomponents_):
|
|
123
|
+
|
|
124
|
+
- **`StatusIndicator`**: renders a `div` (override with `as` if needed). Default `maxWidth` is
|
|
125
|
+
`200px`. Default `variant` is `neutral`; default `emphasis` is `low`. No ARIA role is set.
|
|
126
|
+
- **`StatusIndicator.Label`**: renders a `span` with bold subtext, `white-space: nowrap`,
|
|
127
|
+
`overflow: hidden`, and `text-overflow: ellipsis`. Truncation is visual; the full text remains in
|
|
128
|
+
the accessibility tree.
|
|
129
|
+
- **`StatusIndicator.Icon`**: renders `SystemIcon` at size `20`. It does **not** set `role="img"` or
|
|
130
|
+
`aria-label`. If `icon.type` is missing, the icon renders nothing.
|
|
131
|
+
|
|
132
|
+
**Keyboard** (_not a control by default_):
|
|
133
|
+
|
|
134
|
+
- **`StatusIndicator`** is not in the tab order. There is no built-in keyboard behavior.
|
|
135
|
+
|
|
136
|
+
**Screen reader expectations** (_when built-in behaviors are used as intended_):
|
|
137
|
+
|
|
138
|
+
- Assistive technology should announce the **`StatusIndicator.Label`** text as the content of the
|
|
139
|
+
indicator
|
|
140
|
+
- `variant` and `emphasis` are **not** announced
|
|
141
|
+
- A decorative **`StatusIndicator.Icon`** (no `role="img"`) should not add a separate accessible
|
|
142
|
+
name
|
|
143
|
+
- [**OverflowTooltip**](https://workday.github.io/canvas-kit/?path=/docs/components-popups-tooltip--docs#tooltips-on-overflowing-content)
|
|
144
|
+
uses `type="muted"` and does not set `aria-label` on the target—the accessible name stays the
|
|
145
|
+
element's text content
|
|
146
|
+
|
|
147
|
+
### Accessibility Requirements
|
|
148
|
+
|
|
149
|
+
Required in application code for an accessible Status Indicator. Rows marked _(conditional)_ apply
|
|
150
|
+
only when the situation matches—otherwise omit.
|
|
151
|
+
|
|
152
|
+
**If no design spec is provided:** include a visible **`StatusIndicator.Label`**; keep the icon
|
|
153
|
+
decorative (omit `role="img"` and `aria-label`); omit `tabIndex` and **`OverflowTooltip`**. Prefer
|
|
154
|
+
short label text so truncation is unnecessary.
|
|
155
|
+
|
|
156
|
+
| Requirement | How to satisfy |
|
|
157
|
+
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
158
|
+
| Visible status text | **`StatusIndicator.Label`** with translated text that names the status (for example, "Unpublished", not color alone) |
|
|
159
|
+
| Color is not the only indicator | Use **`variant`** / **`emphasis`** only as visual reinforcement of the label. See [Failure of Success Criterion 1.4.1 due to identifying required or error fields using color differences only](https://www.w3.org/WAI/WCAG22/Techniques/failures/F81) |
|
|
160
|
+
| Decorative icon _(conditional)_ | **`StatusIndicator.Icon`** with `icon={...}` and **no** `role="img"` when the icon only supports the label visually |
|
|
161
|
+
| Informative icon _(conditional)_ | On **`StatusIndicator.Icon`**, set `role="img"` and a translated `aria-label` that adds meaning **beyond** the label text |
|
|
162
|
+
| Overflowed label _(conditional)_ | Avoid exceeding the `200px` max width. If truncation cannot be avoided, wrap **`StatusIndicator`** in **`OverflowTooltip`** and set `tabIndex={0}` so keyboard and mouse users can reveal the full text. See the [Overflow example](#overflow) |
|
|
163
|
+
|
|
164
|
+
**Informative icon** _(conditional)_:
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
|
|
168
|
+
import {cloudArrowUpIcon} from '@workday/canvas-system-icons-web';
|
|
169
|
+
|
|
170
|
+
<StatusIndicator>
|
|
171
|
+
<StatusIndicator.Icon role="img" aria-label="Waiting to sync" icon={cloudArrowUpIcon} />
|
|
172
|
+
<StatusIndicator.Label>Unpublished</StatusIndicator.Label>
|
|
173
|
+
</StatusIndicator>;
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Summary for code generation:**
|
|
177
|
+
|
|
178
|
+
- **REQUIRED:** visible **`StatusIndicator.Label`** whose text conveys the status
|
|
179
|
+
- **CONDITIONAL:** `role="img"` + translated `aria-label` on **`StatusIndicator.Icon`**,
|
|
180
|
+
**`OverflowTooltip`** + `tabIndex={0}`
|
|
181
|
+
|
|
182
|
+
### Anti-Patterns
|
|
183
|
+
|
|
184
|
+
Do **not** generate code that does the following (see **Accessibility Requirements** above for what
|
|
185
|
+
to supply instead):
|
|
186
|
+
|
|
187
|
+
- Omit **`StatusIndicator.Label`** or use an empty label, relying on `variant`, `emphasis`, or an
|
|
188
|
+
icon for meaning
|
|
189
|
+
- Set `role="img"` on a decorative **`StatusIndicator.Icon`**, or set `role="img"` without a
|
|
190
|
+
translated `aria-label`—that can expose an unnamed image to assistive technology. See **Decorative
|
|
191
|
+
icon** and **Informative icon** in **Accessibility Requirements**
|
|
192
|
+
- Duplicate the label text as `aria-label` on the icon when the icon adds no extra meaning
|
|
193
|
+
- Add `role="status"`, `aria-live`, or `aria-label` on **`StatusIndicator`** by default—Canvas Kit
|
|
194
|
+
does not wire these, and they change how assistive technology treats a static label. If a design
|
|
195
|
+
requires announcing asynchronous updates, see
|
|
196
|
+
[ARIA Live Regions](https://workday.github.io/canvas-kit/?path=/docs/guides-accessibility-aria-live-regions--docs)
|
|
197
|
+
- Truncate label text without **`OverflowTooltip`** and `tabIndex={0}` when keyboard users must read
|
|
198
|
+
the overflow
|
|
199
|
+
|
|
87
200
|
## Component API
|
|
88
201
|
|
|
89
202
|
<SymbolDoc name="StatusIndicator" fileName="/preview-react/" />
|
|
@@ -12,12 +12,12 @@ export default () => {
|
|
|
12
12
|
return (
|
|
13
13
|
<Flex cs={parentContainerStyles}>
|
|
14
14
|
<StatusIndicator>
|
|
15
|
-
<StatusIndicator.Icon
|
|
15
|
+
<StatusIndicator.Icon icon={cloudArrowUpIcon} />
|
|
16
16
|
<StatusIndicator.Label>Unpublished</StatusIndicator.Label>
|
|
17
17
|
</StatusIndicator>
|
|
18
18
|
<StatusIndicator variant="positive">
|
|
19
19
|
<StatusIndicator.Label>published</StatusIndicator.Label>
|
|
20
|
-
<StatusIndicator.Icon
|
|
20
|
+
<StatusIndicator.Icon icon={cloudArrowUpIcon} />
|
|
21
21
|
</StatusIndicator>
|
|
22
22
|
</Flex>
|
|
23
23
|
);
|
|
@@ -33,6 +33,8 @@ yarn add @workday/canvas-kit-react
|
|
|
33
33
|
`Menu` will automatically focus on the cursor item (first item by default). The `Menu` uses a menu
|
|
34
34
|
model which composes a list model and a popup model and sets up accessibility features for you.
|
|
35
35
|
|
|
36
|
+
> **Note:** When content exceeds `60vh`, the menu content is clipped and the menu becomes scrollable.
|
|
37
|
+
|
|
36
38
|
### Context Menu
|
|
37
39
|
|
|
38
40
|
<ExampleCodeBlock code={ContextMenu} />
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Menu} from '@workday/canvas-kit-react/menu';
|
|
4
|
+
import {BodyText} from '@workday/canvas-kit-react/text';
|
|
5
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
const [selected, setSelected] = React.useState('');
|
|
9
|
+
return (
|
|
10
|
+
<Menu
|
|
11
|
+
id="first-menu"
|
|
12
|
+
onSelect={data => {
|
|
13
|
+
setSelected(data.id);
|
|
14
|
+
}}
|
|
15
|
+
>
|
|
16
|
+
<Menu.Target>Open Menu</Menu.Target>
|
|
17
|
+
<Menu.Popper>
|
|
18
|
+
<Menu.Card>
|
|
19
|
+
<Menu.List>
|
|
20
|
+
<Menu.Item data-id="first-item">First Item</Menu.Item>
|
|
21
|
+
<Menu.Submenu id="second-menu">
|
|
22
|
+
<Menu.Submenu.TargetItem data-id="second-item">Second Item</Menu.Submenu.TargetItem>
|
|
23
|
+
<Menu.Submenu.Popper>
|
|
24
|
+
<Menu.Submenu.Card>
|
|
25
|
+
<Menu.Submenu.List>
|
|
26
|
+
<Menu.Submenu.Item data-id="second-first-sub-item">
|
|
27
|
+
Second: First Sub Item
|
|
28
|
+
</Menu.Submenu.Item>
|
|
29
|
+
<Menu.Submenu.Item data-id="second-second-sub-item">
|
|
30
|
+
Second: Second Sub Item
|
|
31
|
+
</Menu.Submenu.Item>
|
|
32
|
+
</Menu.Submenu.List>
|
|
33
|
+
</Menu.Submenu.Card>
|
|
34
|
+
</Menu.Submenu.Popper>
|
|
35
|
+
</Menu.Submenu>
|
|
36
|
+
<Menu.Submenu id="third-menu">
|
|
37
|
+
<Menu.Submenu.TargetItem data-id="third-item">Third Item</Menu.Submenu.TargetItem>
|
|
38
|
+
<Menu.Submenu.Popper>
|
|
39
|
+
<Menu.Submenu.Card>
|
|
40
|
+
<Menu.Submenu.List>
|
|
41
|
+
<Menu.Submenu.Item data-id="third-first-sub-item">
|
|
42
|
+
Third: First Sub Item
|
|
43
|
+
</Menu.Submenu.Item>
|
|
44
|
+
<Menu.Submenu.Item data-id="third-second-sub-item">
|
|
45
|
+
Third: Second Sub Item
|
|
46
|
+
</Menu.Submenu.Item>
|
|
47
|
+
</Menu.Submenu.List>
|
|
48
|
+
</Menu.Submenu.Card>
|
|
49
|
+
</Menu.Submenu.Popper>
|
|
50
|
+
</Menu.Submenu>
|
|
51
|
+
<Menu.Item data-id="fourth-item">Fourth Item</Menu.Item>
|
|
52
|
+
</Menu.List>
|
|
53
|
+
</Menu.Card>
|
|
54
|
+
</Menu.Popper>
|
|
55
|
+
<BodyText size="small" cs={{marginBlockStart: system.gap.md}}>
|
|
56
|
+
Selected: <span data-testid="output">{selected}</span>
|
|
57
|
+
</BodyText>
|
|
58
|
+
</Menu>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -405,7 +405,9 @@ To style elements in the render function, we'll need to choose what elements to
|
|
|
405
405
|
the example below, we're able to spread the parts directly to elements. The Stencil will generate
|
|
406
406
|
the type and value most appropriate for the context the part is used. In the Stencil, the part is
|
|
407
407
|
represented by a string that looks like `[data-part="{partValue}"]` and in the render function, it
|
|
408
|
-
is an object that looks like `{'data-part': partValue}`.
|
|
408
|
+
is an object that looks like `{'data-part': partValue}`. That object also has a non-enumerable
|
|
409
|
+
`selector` property (`[data-part="{partValue}"]`) for targeting the part from another stencil's
|
|
410
|
+
style object without writing the attribute selector by hand.
|
|
409
411
|
|
|
410
412
|
```jsx
|
|
411
413
|
import {createStencil, handleCsProp} from '@workday/canvas-kit-styling';
|
|
@@ -444,6 +446,22 @@ const MyButton = ({children, ...elemProps}) => {
|
|
|
444
446
|
};
|
|
445
447
|
```
|
|
446
448
|
|
|
449
|
+
To target a part from another stencil, use `.selector`. Spreading the part onto an element still
|
|
450
|
+
only applies `data-part`.
|
|
451
|
+
|
|
452
|
+
```jsx
|
|
453
|
+
const cardStencil = createStencil({
|
|
454
|
+
base: {
|
|
455
|
+
[`&:where(:has(${myButtonStencil.parts.icon.selector}))`]: {
|
|
456
|
+
paddingInlineStart: 0,
|
|
457
|
+
},
|
|
458
|
+
[`& ${myButtonStencil.parts.label.selector}`]: {
|
|
459
|
+
fontWeight: 700,
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
});
|
|
463
|
+
```
|
|
464
|
+
|
|
447
465
|
As a reusable component, you can use component parts to style elements that are not exposed in the
|
|
448
466
|
API. Consumers can also use the type safe Stencil to target that element to style it as well. As a
|
|
449
467
|
general rule, a Stencil maps to a component. Multiple Stencils per component usually means nested
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "15.1.
|
|
3
|
+
"version": "15.1.10",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"@stackblitz/sdk": "^1.11.0",
|
|
48
48
|
"@storybook/csf": "0.0.1",
|
|
49
49
|
"@workday/canvas-expressive-icons-web": "1.0.2",
|
|
50
|
-
"@workday/canvas-kit-labs-react": "^15.1.
|
|
51
|
-
"@workday/canvas-kit-preview-react": "^15.1.
|
|
52
|
-
"@workday/canvas-kit-react": "^15.1.
|
|
53
|
-
"@workday/canvas-kit-styling": "^15.1.
|
|
50
|
+
"@workday/canvas-kit-labs-react": "^15.1.10",
|
|
51
|
+
"@workday/canvas-kit-preview-react": "^15.1.10",
|
|
52
|
+
"@workday/canvas-kit-react": "^15.1.10",
|
|
53
|
+
"@workday/canvas-kit-styling": "^15.1.10",
|
|
54
54
|
"@workday/canvas-system-icons-web": "4.2.0",
|
|
55
55
|
"@workday/canvas-tokens-web": "4.4.0",
|
|
56
56
|
"markdown-to-jsx": "^7.2.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"mkdirp": "^1.0.3",
|
|
64
64
|
"typescript": "5.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "f901efa76097c95b05ec7872ea7b90e0555db9fd"
|
|
67
67
|
}
|