@spectrum-web-components/button 0.18.0 → 0.18.1

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 (161) hide show
  1. package/README.md +193 -34
  2. package/custom-elements.json +90 -90
  3. package/package.json +50 -16
  4. package/sp-button.dev.js +3 -0
  5. package/sp-button.dev.js.map +7 -0
  6. package/sp-button.js +3 -14
  7. package/sp-button.js.map +7 -1
  8. package/sp-clear-button.dev.js +3 -0
  9. package/sp-clear-button.dev.js.map +7 -0
  10. package/sp-clear-button.js +3 -14
  11. package/sp-clear-button.js.map +7 -1
  12. package/sp-close-button.dev.js +3 -0
  13. package/sp-close-button.dev.js.map +7 -0
  14. package/sp-close-button.js +3 -14
  15. package/sp-close-button.js.map +7 -1
  16. package/src/Button.dev.js +79 -0
  17. package/src/Button.dev.js.map +7 -0
  18. package/src/Button.js +72 -87
  19. package/src/Button.js.map +7 -1
  20. package/src/ButtonBase.dev.js +215 -0
  21. package/src/ButtonBase.dev.js.map +7 -0
  22. package/src/ButtonBase.js +198 -201
  23. package/src/ButtonBase.js.map +7 -1
  24. package/src/ClearButton.dev.js +70 -0
  25. package/src/ClearButton.dev.js.map +7 -0
  26. package/src/ClearButton.js +45 -52
  27. package/src/ClearButton.js.map +7 -1
  28. package/src/CloseButton.dev.js +65 -0
  29. package/src/CloseButton.dev.js.map +7 -0
  30. package/src/CloseButton.js +42 -49
  31. package/src/CloseButton.js.map +7 -1
  32. package/src/StyledButton.dev.js +8 -0
  33. package/src/StyledButton.dev.js.map +7 -0
  34. package/src/StyledButton.js +6 -17
  35. package/src/StyledButton.js.map +7 -1
  36. package/src/button-base.css.dev.js +10 -0
  37. package/src/button-base.css.dev.js.map +7 -0
  38. package/src/button-base.css.js +4 -15
  39. package/src/button-base.css.js.map +7 -1
  40. package/src/button.css.dev.js +619 -0
  41. package/src/button.css.dev.js.map +7 -0
  42. package/src/button.css.js +4 -15
  43. package/src/button.css.js.map +7 -1
  44. package/src/index.dev.js +6 -0
  45. package/src/index.dev.js.map +7 -0
  46. package/src/index.js +6 -17
  47. package/src/index.js.map +7 -1
  48. package/src/spectrum-button-base.css.dev.js +6 -0
  49. package/src/spectrum-button-base.css.dev.js.map +7 -0
  50. package/src/spectrum-button-base.css.js +3 -14
  51. package/src/spectrum-button-base.css.js.map +7 -1
  52. package/src/spectrum-button.css.dev.js +587 -0
  53. package/src/spectrum-button.css.dev.js.map +7 -0
  54. package/src/spectrum-button.css.js +4 -15
  55. package/src/spectrum-button.css.js.map +7 -1
  56. package/stories/button-accent-fill-sizes.stories.js +21 -18
  57. package/stories/button-accent-fill-sizes.stories.js.map +7 -1
  58. package/stories/button-accent-fill.stories.js +24 -20
  59. package/stories/button-accent-fill.stories.js.map +7 -1
  60. package/stories/button-accent-outline-sizes.stories.js +21 -18
  61. package/stories/button-accent-outline-sizes.stories.js.map +7 -1
  62. package/stories/button-accent-outline.stories.js +24 -20
  63. package/stories/button-accent-outline.stories.js.map +7 -1
  64. package/stories/button-black-fill-sizes.stories.js +22 -19
  65. package/stories/button-black-fill-sizes.stories.js.map +7 -1
  66. package/stories/button-black-fill.stories.js +26 -21
  67. package/stories/button-black-fill.stories.js.map +7 -1
  68. package/stories/button-black-outline-sizes.stories.js +22 -19
  69. package/stories/button-black-outline-sizes.stories.js.map +7 -1
  70. package/stories/button-black-outline.stories.js +26 -21
  71. package/stories/button-black-outline.stories.js.map +7 -1
  72. package/stories/button-negative-fill-sizes.stories.js +21 -18
  73. package/stories/button-negative-fill-sizes.stories.js.map +7 -1
  74. package/stories/button-negative-fill.stories.js +24 -20
  75. package/stories/button-negative-fill.stories.js.map +7 -1
  76. package/stories/button-negative-outline-sizes.stories.js +21 -18
  77. package/stories/button-negative-outline-sizes.stories.js.map +7 -1
  78. package/stories/button-negative-outline.stories.js +24 -20
  79. package/stories/button-negative-outline.stories.js.map +7 -1
  80. package/stories/button-primary-fill-sizes.stories.js +21 -18
  81. package/stories/button-primary-fill-sizes.stories.js.map +7 -1
  82. package/stories/button-primary-fill.stories.js +24 -20
  83. package/stories/button-primary-fill.stories.js.map +7 -1
  84. package/stories/button-primary-outline-sizes.stories.js +21 -18
  85. package/stories/button-primary-outline-sizes.stories.js.map +7 -1
  86. package/stories/button-primary-outline.stories.js +24 -20
  87. package/stories/button-primary-outline.stories.js.map +7 -1
  88. package/stories/button-secondary-fill-sizes.stories.js +21 -18
  89. package/stories/button-secondary-fill-sizes.stories.js.map +7 -1
  90. package/stories/button-secondary-fill.stories.js +24 -20
  91. package/stories/button-secondary-fill.stories.js.map +7 -1
  92. package/stories/button-secondary-outline-sizes.stories.js +21 -18
  93. package/stories/button-secondary-outline-sizes.stories.js.map +7 -1
  94. package/stories/button-secondary-outline.stories.js +24 -20
  95. package/stories/button-secondary-outline.stories.js.map +7 -1
  96. package/stories/button-white-fill-sizes.stories.js +22 -19
  97. package/stories/button-white-fill-sizes.stories.js.map +7 -1
  98. package/stories/button-white-fill.stories.js +26 -21
  99. package/stories/button-white-fill.stories.js.map +7 -1
  100. package/stories/button-white-outline-sizes.stories.js +22 -19
  101. package/stories/button-white-outline-sizes.stories.js.map +7 -1
  102. package/stories/button-white-outline.stories.js +26 -21
  103. package/stories/button-white-outline.stories.js.map +7 -1
  104. package/stories/index.js +92 -93
  105. package/stories/index.js.map +7 -1
  106. package/test/benchmark/test-basic.js +5 -16
  107. package/test/benchmark/test-basic.js.map +7 -1
  108. package/test/button-accent-fill-sizes.test-vrt.js +4 -15
  109. package/test/button-accent-fill-sizes.test-vrt.js.map +7 -1
  110. package/test/button-accent-fill.test-vrt.js +4 -15
  111. package/test/button-accent-fill.test-vrt.js.map +7 -1
  112. package/test/button-accent-outline-sizes.test-vrt.js +4 -15
  113. package/test/button-accent-outline-sizes.test-vrt.js.map +7 -1
  114. package/test/button-accent-outline.test-vrt.js +4 -15
  115. package/test/button-accent-outline.test-vrt.js.map +7 -1
  116. package/test/button-black-fill-sizes.test-vrt.js +4 -15
  117. package/test/button-black-fill-sizes.test-vrt.js.map +7 -1
  118. package/test/button-black-fill.test-vrt.js +4 -15
  119. package/test/button-black-fill.test-vrt.js.map +7 -1
  120. package/test/button-black-outline-sizes.test-vrt.js +4 -15
  121. package/test/button-black-outline-sizes.test-vrt.js.map +7 -1
  122. package/test/button-black-outline.test-vrt.js +4 -15
  123. package/test/button-black-outline.test-vrt.js.map +7 -1
  124. package/test/button-negative-fill-sizes.test-vrt.js +4 -15
  125. package/test/button-negative-fill-sizes.test-vrt.js.map +7 -1
  126. package/test/button-negative-fill.test-vrt.js +4 -15
  127. package/test/button-negative-fill.test-vrt.js.map +7 -1
  128. package/test/button-negative-outline-sizes.test-vrt.js +4 -15
  129. package/test/button-negative-outline-sizes.test-vrt.js.map +7 -1
  130. package/test/button-negative-outline.test-vrt.js +4 -15
  131. package/test/button-negative-outline.test-vrt.js.map +7 -1
  132. package/test/button-primary-fill-sizes.test-vrt.js +4 -15
  133. package/test/button-primary-fill-sizes.test-vrt.js.map +7 -1
  134. package/test/button-primary-fill.test-vrt.js +4 -15
  135. package/test/button-primary-fill.test-vrt.js.map +7 -1
  136. package/test/button-primary-outline-sizes.test-vrt.js +4 -15
  137. package/test/button-primary-outline-sizes.test-vrt.js.map +7 -1
  138. package/test/button-primary-outline.test-vrt.js +4 -15
  139. package/test/button-primary-outline.test-vrt.js.map +7 -1
  140. package/test/button-secondary-fill-sizes.test-vrt.js +4 -15
  141. package/test/button-secondary-fill-sizes.test-vrt.js.map +7 -1
  142. package/test/button-secondary-fill.test-vrt.js +4 -15
  143. package/test/button-secondary-fill.test-vrt.js.map +7 -1
  144. package/test/button-secondary-outline-sizes.test-vrt.js +4 -15
  145. package/test/button-secondary-outline-sizes.test-vrt.js.map +7 -1
  146. package/test/button-secondary-outline.test-vrt.js +4 -15
  147. package/test/button-secondary-outline.test-vrt.js.map +7 -1
  148. package/test/button-white-fill-sizes.test-vrt.js +4 -15
  149. package/test/button-white-fill-sizes.test-vrt.js.map +7 -1
  150. package/test/button-white-fill.test-vrt.js +4 -15
  151. package/test/button-white-fill.test-vrt.js.map +7 -1
  152. package/test/button-white-outline-sizes.test-vrt.js +4 -15
  153. package/test/button-white-outline-sizes.test-vrt.js.map +7 -1
  154. package/test/button-white-outline.test-vrt.js +4 -15
  155. package/test/button-white-outline.test-vrt.js.map +7 -1
  156. package/test/button.test.js +321 -320
  157. package/test/button.test.js.map +7 -1
  158. package/test/clear-button.test.js +13 -20
  159. package/test/clear-button.test.js.map +7 -1
  160. package/test/close-button.test.js +13 -20
  161. package/test/close-button.test.js.map +7 -1
package/README.md CHANGED
@@ -66,41 +66,12 @@ import { Button, ClearButton, CloseButton } from '@spectrum-web-components/butto
66
66
  </sp-tab-panel>
67
67
  </sp-tabs>
68
68
 
69
- ## Variants
70
-
71
- There are many button variants to choose from in Spectrum. The `variant`
72
- attribute controls the main variant of the button, and a few other boolean
73
- attributes can be combined to apply sub-variants, e.g. `quiet`.
74
-
75
- ### Normal
76
-
77
- ```html
78
- <sp-button-group>
79
- <sp-button variant="cta">CTA</sp-button>
80
- <sp-button variant="primary">Primary</sp-button>
81
- <sp-button variant="secondary">Secondary</sp-button>
82
- <sp-button variant="negative">Negative</sp-button>
83
- </sp-button-group>
84
- ```
85
-
86
- ### Quiet
87
-
88
- ```html
89
- <sp-button-group>
90
- <sp-button quiet variant="primary">Quiet Primary</sp-button>
91
- <sp-button quiet variant="secondary">Quiet Secondary</sp-button>
92
- <sp-button quiet variant="negative">Quiet Negative</sp-button>
93
- </sp-button-group>
94
- ```
95
-
96
69
  ## Content
97
70
 
98
- `<sp-buttons>` can have a label, or a label with an icon. An icon is provided by
99
- placing an icon component to the `icon` slot. The icon may be an `sp-icon` or an
100
- SVG.
71
+ `<sp-button>` elements can be provided a visible label, a label with an icon, or just an icon (a non-visible label can be prived via the `label` attribute on an `<sp-button>` or on an `<sp-icon*>` element child to appropriately fulfill the accessibility contract of the button). An icon is provided by
72
+ placing an icon element to the `icon` slot.
101
73
 
102
74
  ```html
103
- <sp-icons-medium></sp-icons-medium>
104
75
  <sp-button-group>
105
76
  <sp-button variant="primary">Label only</sp-button>
106
77
  <sp-button variant="primary">
@@ -121,14 +92,202 @@ SVG.
121
92
  </svg>
122
93
  SVG Icon + Label
123
94
  </sp-button>
95
+ <sp-button variant="primary" label="Icon only">
96
+ <sp-icon-help slot="icon"></sp-icon-help>
97
+ </sp-button>
98
+ </sp-button-group>
99
+ ```
100
+
101
+ ## Variants
102
+
103
+ There are many button variants to choose from in Spectrum. The `variant`
104
+ attribute defaults to `accent` but also accepts the following value: `accent`, `primary`, `secondary`, `negative`, `white`, and `black`. They display as follows:
105
+
106
+ <sp-tabs selected="accent" auto label="Variant Attribute Options">
107
+ <sp-tab value="accent">Accent</sp-tab>
108
+ <sp-tab-panel value="accent">
109
+
110
+ ```html demo
111
+ <sp-button-group style="min-width: max-content">
112
+ <sp-button variant="accent">Label only</sp-button>
113
+ <sp-button variant="accent">
114
+ <sp-icon-help slot="icon"></sp-icon-help>
115
+ Icon + Label
116
+ </sp-button>
117
+ <sp-button variant="accent" label="Icon only">
118
+ <sp-icon-help slot="icon"></sp-icon-help>
119
+ </sp-button>
120
+ </sp-button-group>
121
+ ```
122
+
123
+ </sp-tab-panel>
124
+ <sp-tab value="primary">Primary</sp-tab>
125
+ <sp-tab-panel value="primary">
126
+
127
+ ```html demo
128
+ <sp-button-group style="min-width: max-content">
129
+ <sp-button variant="primary">Label only</sp-button>
130
+ <sp-button variant="primary">
131
+ <sp-icon-help slot="icon"></sp-icon-help>
132
+ Icon + Label
133
+ </sp-button>
134
+ <sp-button variant="primary" label="Icon only">
135
+ <sp-icon-help slot="icon"></sp-icon-help>
136
+ </sp-button>
137
+ </sp-button-group>
138
+ ```
139
+
140
+ </sp-tab-panel>
141
+ <sp-tab value="secondary">Seconday</sp-tab>
142
+ <sp-tab-panel value="secondary">
143
+
144
+ ```html demo
145
+ <sp-button-group style="min-width: max-content">
146
+ <sp-button variant="secondary">Label only</sp-button>
147
+ <sp-button variant="secondary">
148
+ <sp-icon-help slot="icon"></sp-icon-help>
149
+ Icon + Label
150
+ </sp-button>
151
+ <sp-button variant="secondary" label="Icon only">
152
+ <sp-icon-help slot="icon"></sp-icon-help>
153
+ </sp-button>
154
+ </sp-button-group>
155
+ ```
156
+
157
+ </sp-tab-panel>
158
+ <sp-tab value="negative">Negative</sp-tab>
159
+ <sp-tab-panel value="negative">
160
+
161
+ ```html demo
162
+ <sp-button-group style="min-width: max-content">
163
+ <sp-button variant="negative">Label only</sp-button>
164
+ <sp-button variant="negative">
165
+ <sp-icon-help slot="icon"></sp-icon-help>
166
+ Icon + Label
167
+ </sp-button>
168
+ <sp-button variant="negative" label="Icon only">
169
+ <sp-icon-help slot="icon"></sp-icon-help>
170
+ </sp-button>
124
171
  </sp-button-group>
125
172
  ```
126
173
 
174
+ </sp-tab-panel>
175
+ <sp-tab value="black">Black</sp-tab>
176
+ <sp-tab-panel value="black">
177
+
178
+ ```html demo
179
+ <sp-button-group style="min-width: max-content">
180
+ <sp-button variant="black">Label only</sp-button>
181
+ <sp-button variant="black">
182
+ <sp-icon-help slot="icon"></sp-icon-help>
183
+ Icon + Label
184
+ </sp-button>
185
+ <sp-button variant="black" label="Icon only">
186
+ <sp-icon-help slot="icon"></sp-icon-help>
187
+ </sp-button>
188
+ </sp-button-group>
189
+ ```
190
+
191
+ </sp-tab-panel>
192
+ <sp-tab value="white">White</sp-tab>
193
+ <sp-tab-panel value="white">
194
+
195
+ ```html demo
196
+ <sp-button-group style="min-width: max-content">
197
+ <sp-button variant="white">Label only</sp-button>
198
+ <sp-button variant="white">
199
+ <sp-icon-help slot="icon"></sp-icon-help>
200
+ Icon + Label
201
+ </sp-button>
202
+ <sp-button variant="white" label="Icon only">
203
+ <sp-icon-help slot="icon"></sp-icon-help>
204
+ </sp-button>
205
+ </sp-button-group>
206
+ ```
207
+
208
+ </sp-tab-panel>
209
+ </sp-tabs>
210
+
211
+ ### Treatment
212
+
213
+ The `treatment` attribute accepts `fill` and `outline` as values, and defaults to `fill`. These display as follows:
214
+
215
+ <sp-tabs selected="fill" auto label="Treatment Attribute Options">
216
+ <sp-tab value="fill">Fill</sp-tab>
217
+ <sp-tab-panel value="fill">
218
+
219
+ ```html demo
220
+ <sp-button-group style="min-width: max-content">
221
+ <sp-button treatment="fill" variant="primary">Primary, Fill</sp-button>
222
+ <sp-button treatment="fill" variant="secondary">Secondary, Fill</sp-button>
223
+ <sp-button treatment="fill" variant="negative">Negative, Fill</sp-button>
224
+ </sp-button-group>
225
+ ```
226
+
227
+ </sp-tab-panel>
228
+ <sp-tab value="outline">Outline</sp-tab>
229
+ <sp-tab-panel value="outline">
230
+
231
+ ```html demo
232
+ <sp-button-group style="min-width: max-content">
233
+ <sp-button treatment="outline" variant="primary">
234
+ Primary, Outline
235
+ </sp-button>
236
+ <sp-button treatment="outline" variant="secondary">
237
+ Secondary, Outline
238
+ </sp-button>
239
+ <sp-button treatment="outline" variant="negative">
240
+ Negative, Outline
241
+ </sp-button>
242
+ </sp-button-group>
243
+ ```
244
+
245
+ </sp-tab-panel>
246
+ <sp-tab value="outline-black">Outline, black</sp-tab>
247
+ <sp-tab-panel value="outline-black">
248
+
249
+ ```html demo
250
+ <sp-button-group
251
+ style="background: var(--spectrum-global-color-seafoam-600); padding: 0.5em; min-width: max-content"
252
+ >
253
+ <sp-button treatment="outline" variant="black">Label only</sp-button>
254
+ <sp-button treatment="outline" variant="black">
255
+ <sp-icon-help slot="icon"></sp-icon-help>
256
+ Icon + Label
257
+ </sp-button>
258
+ <sp-button treatment="outline" variant="black" label="Icon only">
259
+ <sp-icon-help slot="icon"></sp-icon-help>
260
+ </sp-button>
261
+ </sp-button-group>
262
+ ```
263
+
264
+ </sp-tab-panel>
265
+ <sp-tab value="outline-white">Outline, white</sp-tab>
266
+ <sp-tab-panel value="outline-white">
267
+
268
+ ```html demo
269
+ <sp-button-group
270
+ style="background: var(--spectrum-global-color-seafoam-600); padding: 0.5em; min-width: max-content"
271
+ >
272
+ <sp-button treatment="outline" variant="white">Label only</sp-button>
273
+ <sp-button treatment="outline" variant="white">
274
+ <sp-icon-help slot="icon"></sp-icon-help>
275
+ Icon + Label
276
+ </sp-button>
277
+ <sp-button treatment="outline" variant="white" label="Icon only">
278
+ <sp-icon-help slot="icon"></sp-icon-help>
279
+ </sp-button>
280
+ </sp-button-group>
281
+ ```
282
+
283
+ </sp-tab-panel>
284
+ </sp-tabs>
285
+
127
286
  ## States
128
287
 
129
- In addition to the variant, `<sp-buttons>` have a disabled state visual state
130
- which can be applied by adding the attribute `disabled`. All spectrum-button
131
- variants support the In addition to affectng the visual state, the `disabled`
288
+ In addition to the variant, `<sp-button>` elements have a disabled state visual state
289
+ which can be applied by adding the attribute `disabled`. All `<sp-button>`
290
+ variants support this. In addition to affectng the visual state, the `disabled`
132
291
  attribute prevents focus and disallows `click` events.
133
292
 
134
293
  ```html