@spectrum-web-components/picker-button 1.3.0-testing.0 → 1.3.1-beta.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.
Files changed (2) hide show
  1. package/README.md +86 -34
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## Description
1
+ ## Overview
2
2
 
3
3
  An `<sp-picker-button>` is used as a sub-component of patterns like the `<sp-combobox>` (release pending) to pair a button interface with a text input. With its many custom states and alterations, it isn't likely to be leveraged directly outside of more complex UIs.
4
4
 
@@ -23,7 +23,35 @@ When looking to leverage the `PickerButton` base class as a type and/or for exte
23
23
  import { PickerButton } from '@spectrum-web-components/picker-button';
24
24
  ```
25
25
 
26
- ## Sizes
26
+ ### Anatomy
27
+
28
+ #### Text and icon
29
+
30
+ With the use of the `label` slot, you can deliver an `<sp-picker-button>` with both an icon and a text label:
31
+
32
+ ```html
33
+ <sp-picker-button><span slot="label">All</span></sp-picker-button>
34
+ ```
35
+
36
+ #### Icon only
37
+
38
+ Without content addressed to the `label` slot, the `<sp-picker-button>` with both an icon and a text label:
39
+
40
+ ```html
41
+ <sp-picker-button></sp-picker-button>
42
+ ```
43
+
44
+ #### Custom icon
45
+
46
+ You can customize the icon in an `<sp-picker-button>` by addressing a new icon to the `icon` slot:
47
+
48
+ ```html
49
+ <sp-picker-button><sp-icon-add slot="icon"></sp-icon-add></sp-picker-button>
50
+ ```
51
+
52
+ ### Options
53
+
54
+ #### Sizes
27
55
 
28
56
  <sp-tabs selected="m" auto label="Size Attribute Options">
29
57
  <sp-tab value="s">Small</sp-tab>
@@ -68,33 +96,7 @@ import { PickerButton } from '@spectrum-web-components/picker-button';
68
96
  </sp-tab-panel>
69
97
  </sp-tabs>
70
98
 
71
- ## Text and icon
72
-
73
- With the use of the `label` slot, you can deliver an `<sp-picker-button>` with both an icon and a text label:
74
-
75
- ```html
76
- <sp-picker-button><span slot="label">All</span></sp-picker-button>
77
- ```
78
-
79
- ## Icon only
80
-
81
- Without content addressed to the `label` slot, the `<sp-picker-button>` with both an icon and a text label:
82
-
83
- ```html
84
- <sp-picker-button></sp-picker-button>
85
- ```
86
-
87
- ### Custom icon
88
-
89
- You can customize the icon in an `<sp-picker-button>` by addressing a new icon to the `icon` slot:
90
-
91
- ```html
92
- <sp-picker-button><sp-icon-add slot="icon"></sp-icon-add></sp-picker-button>
93
- ```
94
-
95
- ## Modifying attributes
96
-
97
- ### Rounded
99
+ #### Rounded
98
100
 
99
101
  When delivered as part of the `express` system, an `<sp-picker-button>` with the `rounded` attribute will be given deeply rounded corners:
100
102
 
@@ -104,7 +106,7 @@ When delivered as part of the `express` system, an `<sp-picker-button>` with the
104
106
  <sp-picker-button rounded><span slot="label">All</span></sp-picker-button>
105
107
  ```
106
108
 
107
- ### Quiet
109
+ #### Quiet
108
110
 
109
111
  When delivered with the `quiet` attribute, the `<sp-picker-button>` will take a less pronounced visual delivery:
110
112
 
@@ -114,7 +116,7 @@ When delivered with the `quiet` attribute, the `<sp-picker-button>` will take a
114
116
  <sp-picker-button quiet><span slot="label">All</span></sp-picker-button>
115
117
  ```
116
118
 
117
- ### Position
119
+ #### Position
118
120
 
119
121
  By default the `<sp-picker-button>` will be given a `position` attribute with the value `right`, which is best leveraged at the right edge of an associated `<sp-textfield>` element. If your UI desires that the `<sp-picker-button>` be placed to the left of the related input, use the `position` attribute and set it to `left`:
120
122
 
@@ -126,7 +128,9 @@ By default the `<sp-picker-button>` will be given a `position` attribute with th
126
128
  </sp-picker-button>
127
129
  ```
128
130
 
129
- ### Open
131
+ ### States
132
+
133
+ #### Open
130
134
 
131
135
  When paired with an expanded UI, e.g. an `<sp-combobox>` with its autocomplete options visible, an `<sp-picker-button>` should be given the `open` attribute to visual match the delivered state in the larger UI:
132
136
 
@@ -136,7 +140,7 @@ When paired with an expanded UI, e.g. an `<sp-combobox>` with its autocomplete o
136
140
  <sp-picker-button open><span slot="label">All</span></sp-picker-button>
137
141
  ```
138
142
 
139
- ### Disabled
143
+ #### Disabled
140
144
 
141
145
  Leveraging the `disabled` attribute will dim the `<sp-picker-button>` and alter its presentation in the accessibility tree:
142
146
 
@@ -146,7 +150,7 @@ Leveraging the `disabled` attribute will dim the `<sp-picker-button>` and alter
146
150
  <sp-picker-button disabled><span slot="label">All</span></sp-picker-button>
147
151
  ```
148
152
 
149
- ### Invalid
153
+ #### Invalid
150
154
 
151
155
  When delivered as part of the `spectrum` system, an `<sp-picker-button>` with the `invalid` attribute will be given a red border:
152
156
 
@@ -155,3 +159,51 @@ When delivered as part of the `spectrum` system, an `<sp-picker-button>` with th
155
159
  <br />
156
160
  <sp-picker-button invalid><span slot="label">All</span></sp-picker-button>
157
161
  ```
162
+
163
+ ### Accessibility
164
+
165
+ The example below is for demonstration purposes. For an example implementation of `<sp-picker-button>` view [`Combobox.ts`](https://github.com/adobe/spectrum-web-components/blob/main/packages/combobox/src/Combobox.ts). For comprehensive information on menu button accessibility, see WAI ARIA Authoring Practice Guide's [Menu Button Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/).
166
+
167
+ ```html
168
+ <sp-field-label for="color">Color</sp-field-label>
169
+ <sp-textfield id="color"></sp-textfield>
170
+ <overlay-trigger type="modal">
171
+ <sp-picker-button
172
+ aria-controls="colors-menu"
173
+ aria-expanded="false"
174
+ aria-haspopup="menu"
175
+ aria-describedby="color"
176
+ slot="trigger"
177
+ ></sp-picker-button>
178
+ <sp-tray slot="click-content">
179
+ <sp-menu id="colors-menu">
180
+ <sp-menu-item>Red</sp-menu-item>
181
+ <sp-menu-item>Blue</sp-menu-item>
182
+ </sp-menu>
183
+ </sp-tray>
184
+ </overlay-trigger>
185
+ ```
186
+
187
+ #### Include a label
188
+
189
+ To ensure menu items can be read by assistive technology, do _one_ of the following:
190
+
191
+ - Place visible text in the component's `label` slot.
192
+ - Use `aria-label` attribute.
193
+ - Set the `aria-labelledby` attribute to the ID reference of the menu element.
194
+
195
+ #### Set aria properties correctly
196
+
197
+ To indicate to assistive technology what the button does, do _all_ of the following:
198
+
199
+ - Set the `aria-controls` property to the ID reference of the menu element.
200
+ - Set the `aria-haspopup` property to `"menu"` or `"true"`.
201
+ - Set the `aria-expanded` property to `"menu"` or `"true"` or `"false"` depending on whether the menu is displayed.
202
+
203
+ ### Add keyboard interaction
204
+
205
+ Ensure that picker button can be operated by keyboard users:
206
+
207
+ - Required: Open the menu and focus on first menu item when <kbd>Enter</kbd> or <kbd>Space</kbd> is pressed.
208
+ - _Optional_: Open the menu and focus on first menu item when <kbd>Down Arrow</kbd> is pressed.
209
+ - _Optional_: Open the menu and focus on last menu item when <kbd>Up Arrow</kbd> is pressed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/picker-button",
3
- "version": "1.3.0-testing.0",
3
+ "version": "1.3.1-beta.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -58,11 +58,11 @@
58
58
  "lit-html"
59
59
  ],
60
60
  "dependencies": {
61
- "@spectrum-web-components/base": "^1.3.0-testing.0",
62
- "@spectrum-web-components/button": "^1.3.0-testing.0",
63
- "@spectrum-web-components/icon": "^1.3.0-testing.0",
64
- "@spectrum-web-components/icons-ui": "^1.3.0-testing.0",
65
- "@spectrum-web-components/shared": "^1.3.0-testing.0"
61
+ "@spectrum-web-components/base": "1.3.1-beta.0",
62
+ "@spectrum-web-components/button": "1.3.1-beta.0",
63
+ "@spectrum-web-components/icon": "1.3.1-beta.0",
64
+ "@spectrum-web-components/icons-ui": "1.3.1-beta.0",
65
+ "@spectrum-web-components/shared": "1.3.1-beta.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@spectrum-css/pickerbutton": "6.0.0-s2-foundations.16"