Skip to content

Commit c66d8de

Browse files
committed
fix(swatch+swatchgroup): remove unnecessary borderStyle references, set default size to m, additional cleanup
1 parent 3fd6acd commit c66d8de

File tree

8 files changed

+19
-65
lines changed

8 files changed

+19
-65
lines changed

.changeset/proud-schools-reply.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The `Add Swatch` and `Mixed Value` variants may not be combined with background
1313

1414
The `spectrum-Swatch-icon` is used to set the expected color to icons contained within the swatch.
1515

16-
The border should not be set when the swatch is selected as the border conflicts with the display of the selected state.
16+
The light and no border variants have been removed. Individual swatches have a border set to `--spectrum-gray-1000` at `42%` opacity, while the border opacity is set to `20%` in swatch groups.
1717

1818
##### Removed custom properties
1919

components/swatch/dist/metadata.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
".spectrum-Swatch--roundingNone:after",
2121
".spectrum-Swatch--roundingNone:before",
2222
".spectrum-Swatch--sizeL",
23-
".spectrum-Swatch--sizeM",
23+
".spectrum-Swatch--sizeS",
2424
".spectrum-Swatch--sizeXS",
2525
".spectrum-Swatch-disabledIcon",
2626
".spectrum-Swatch-disabledIcon path:first-child",
@@ -120,7 +120,7 @@
120120
"--spectrum-animation-duration-100",
121121
"--spectrum-border-width-100",
122122
"--spectrum-border-width-200",
123-
"--spectrum-corner-radius-75",
123+
"--spectrum-corner-radius-100",
124124
"--spectrum-corner-radius-full",
125125
"--spectrum-corner-radius-none",
126126
"--spectrum-focus-indicator-color",
@@ -135,7 +135,6 @@
135135
"--spectrum-neutral-content-color-default",
136136
"--spectrum-picked-color",
137137
"--spectrum-white",
138-
"--spectrum-workflow-icon-size-100",
139138
"--spectrum-workflow-icon-size-200",
140139
"--spectrum-workflow-icon-size-50",
141140
"--spectrum-workflow-icon-size-75"

components/swatch/index.css

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@
1111
* governing permissions and limitations under the License.
1212
*/
1313

14-
/* @note: default sizing for swatch is small */
1514
.spectrum-Swatch {
1615
/* Placeholder tokens */
1716
--spectrum-swatch-icon-border-color: var(--mod-swatch-icon-border-color, rgb(0 0 0 / var(--spectrum-swatch-disabled-icon-border-opacity)));
1817

1918
/* Size */
20-
--spectrum-swatch-size: var(--mod-swatch-size, var(--spectrum-swatch-size-small));
21-
--spectrum-swatch-border-radius: var(--mod-swatch-border-radius, var(--spectrum-corner-radius-75));
19+
--spectrum-swatch-size: var(--mod-swatch-size, var(--spectrum-swatch-size-medium));
20+
--spectrum-swatch-border-radius: var(--mod-swatch-border-radius, var(--spectrum-corner-radius-100));
2221
--spectrum-swatch-border-thickness: var(--mod-swatch-border-thickness, var(--spectrum-border-width-100));
2322
--spectrum-swatch-border-thickness-selected: var(--mod-swatch-border-thickness-selected, var(--spectrum-border-width-200));
2423
--spectrum-swatch-disabled-icon-size: var(--mod-swatch-disabled-icon-size, var(--spectrum-workflow-icon-size-75));
25-
--spectrum-swatch-slash-thickness: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness-small));
24+
--spectrum-swatch-slash-thickness: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness-medium));
2625

2726
/* Color */
2827
--spectrum-swatch-border-color-selected: var(--highcontrast-swatch-border-color-selected, var(--mod-swatch-border-color-selected, var(--spectrum-gray-1000)));
@@ -64,10 +63,10 @@
6463
--spectrum-swatch-slash-thickness: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness-extra-small));
6564
}
6665

67-
.spectrum-Swatch--sizeM {
68-
--spectrum-swatch-size: var(--mod-swatch-size, var(--spectrum-swatch-size-medium));
69-
--spectrum-swatch-disabled-icon-size: var(--mod-swatch-disabled-icon-size, var(--spectrum-workflow-icon-size-100));
70-
--spectrum-swatch-slash-thickness: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness-medium));
66+
.spectrum-Swatch--sizeS {
67+
--spectrum-swatch-size: var(--mod-swatch-size, var(--spectrum-swatch-size-small));
68+
--spectrum-swatch-disabled-icon-size: var(--mod-swatch-disabled-icon-size, var(--spectrum-workflow-icon-size-75));
69+
--spectrum-swatch-slash-thickness: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness-small));
7170
}
7271

7372
.spectrum-Swatch--sizeL {

components/swatch/stories/swatch.stories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default {
4747
isDisabled: {
4848
...isDisabled,
4949
if: { arg: "isAddSwatch", truthy: false },
50+
category: "State",
5051
},
5152
isSelected,
5253
isHovered: {

components/swatch/stories/template.js

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import "../index.css";
1313
export const Template = ({
1414
rootClass = "spectrum-Swatch",
1515
size = "m",
16-
borderStyle = "default",
1716
shape = "square",
1817
imageUrl,
1918
isMixedValue = false,
@@ -31,18 +30,6 @@ export const Template = ({
3130
} = {}, context = {}) => {
3231
const { updateArgs } = context;
3332

34-
switch (borderStyle) {
35-
case "none":
36-
borderStyle = "noBorder";
37-
break;
38-
case "border":
39-
borderStyle = "border";
40-
break;
41-
case "light":
42-
borderStyle = "lightBorder";
43-
break;
44-
}
45-
4633
let pickedColor = swatchColor;
4734

4835
if (isMixedValue) pickedColor = "var(--spectrum-gray-25)";
@@ -57,7 +44,6 @@ export const Template = ({
5744
[`${rootClass}--rounding${capitalize(
5845
lowerCase(rounding)
5946
)}`]: typeof rounding !== "undefined" && rounding !== "partial",
60-
[`${rootClass}--${borderStyle}`]: typeof borderStyle !== "undefined" && borderStyle !== "default",
6147
"is-selected": !isDisabled && isSelected,
6248
"is-disabled": isDisabled,
6349
"is-hover": isHovered,
@@ -146,7 +132,6 @@ export const Template = ({
146132

147133
/* Shows a single group of swatches with all rounding options. */
148134
export const RoundingGroup = (args, context) => Container({
149-
withBorder: false,
150135
content: html`
151136
${Container({
152137
withBorder: false,
@@ -169,34 +154,8 @@ export const RoundingGroup = (args, context) => Container({
169154
`
170155
}, context);
171156

172-
/* Shows a single group of swatches with all border options. */
173-
export const BorderGroup = (args, context) => Container({
174-
withBorder: false,
175-
content: html`
176-
${Container({
177-
withBorder: false,
178-
heading: "Default",
179-
containerStyles: { "gap": "8px" },
180-
content: Template(args, context),
181-
}, context)}
182-
${Container({
183-
withBorder: false,
184-
heading: "No border",
185-
containerStyles: { "gap": "8px" },
186-
content: Template({...args, borderStyle: "noBorder"}, context),
187-
}, context)}
188-
${Container({
189-
withBorder: false,
190-
heading: "Light Border",
191-
containerStyles: { "gap": "8px" },
192-
content: Template({...args, borderStyle: "lightBorder"}, context),
193-
}, context)}
194-
`
195-
}, context);
196-
197157
/* Shows a single group of swatches that are empty/nothing in various shapes and rounding. */
198158
export const EmptyGroup = (args, context) => Container({
199-
withBorder: false,
200159
content: html`
201160
${Container({
202161
withBorder: false,
@@ -218,7 +177,6 @@ export const EmptyGroup = (args, context) => Container({
218177

219178
/* Shows a single group of disabled swatches. */
220179
export const DisabledGroup = (args, context) => Container({
221-
withBorder: false,
222180
content: html`
223181
${Container({
224182
withBorder: false,
@@ -234,7 +192,6 @@ export const DisabledGroup = (args, context) => Container({
234192
}, context);
235193

236194
export const SizingGroup = (args, context) =>Container({
237-
withBorder: false,
238195
content: html`
239196
${Container({
240197
withBorder: false,

components/swatchgroup/stories/swatchgroup.stories.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import { RoundingTemplate, Template } from "./template.js";
1111
*
1212
* ## Usage notes
1313
*
14-
* * ### Corner rounding in swatch groups
14+
* The border opacity of swatches in a swatch group is 20%.
15+
*
16+
* ### Corner rounding in swatch groups
1517
*
1618
* A corner rounding of "none" (`.spectrum-Swatch--roundingNone` class) should be used in a swatch group in order to help minimize the Hermann grid illusion that happens at the intersections of the white space within the group.
1719
*
1820
* The only exception is when a swatch group only takes up a single row. In that case, use any of the rounding options.
1921
*
20-
* The border opacity of swatches in a swatch group is 20%.
21-
*
2222
* ### Density
2323
*
2424
* Swatch groups come in several densities: regular (default), compact and spacious. Each density retains the same swatch size, but have less or more padding between each swatch, respectively.
@@ -64,12 +64,12 @@ export default {
6464
defaultValue: { summary: "none", },
6565
},
6666
},
67-
tags: ["migrated"],
6867
},
6968
args: {
7069
rootClass: "spectrum-SwatchGroup",
7170
containerWidth: "200px",
7271
density: "regular",
72+
size: "m",
7373
rounding: "none",
7474
items: [
7575
{swatchColor: "rgb(184, 109, 70)",},

components/swatchgroup/stories/swatchgroup.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ export const SwatchgroupGroup = Variants({
55
Template,
66
testData: [
77
{
8-
testHeading: "Default",
8+
testHeading: "Default (regular density)",
99
},
1010
{
11-
testHeading: "Small size (compact density)",
11+
testHeading: "Compact density",
1212
density: "compact",
1313
},
1414
{
15-
testHeading: "Full rounding",
15+
testHeading: "Full rounding (regular density)",
1616
rounding: "full",
1717
},
1818
{
19-
testHeading: "Regular rounding",
19+
testHeading: "Regular rounding (regular density)",
2020
rounding: "regular",
2121
},
2222
],

components/swatchgroup/stories/template.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const Template = ({
1313
size = "m",
1414
density = "regular",
1515
rounding = "none",
16-
borderStyle = "noBorder",
1716
containerWidth,
1817
items = [],
1918
customStyles = {},
@@ -36,7 +35,6 @@ export const Template = ({
3635
${items.map((swatch) => Swatch({
3736
size,
3837
rounding,
39-
borderStyle,
4038
...swatch,
4139
}, context))}
4240
</div>

0 commit comments

Comments
 (0)