Skip to content

Commit f7ce386

Browse files
docs(swatchgroup): add lightBorder template support and story
1 parent 04d3f4e commit f7ce386

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

components/swatchgroup/stories/swatchgroup.stories.js

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import {
2323
*
2424
* ### Border only for low-contrast swatches
2525
*
26-
* Swatches within a swatch group with low contrast (below 3:1 contrast with the background) have a less prominent border compared to the swatch component when used by itself, and should have the `.spectrum-Swatch--lightBorder` class. Low contrast color swatches have a border of gray-900 at 20%. This reduces the likelihood of the UI interfering with color perception and comparisons.
26+
* Swatches within a swatch group with low contrast (below 3:1 contrast with the background) have a less prominent border compared to the swatch component when used by itself, and should have the `.spectrum-Swatch--lightBorder` class. Low contrast color swatches have a border of `gray-900` at 20%. This reduces the likelihood of the UI interfering with color perception and comparisons.
2727
*
28-
* Swatches should have the `.spectrum-Swatch--noBorder` class, otherwise.
28+
* Swatches within a swatch group should have the `.spectrum-Swatch--noBorder` class, otherwise.
2929
*
3030
* ### Density
3131
*
@@ -49,7 +49,6 @@ export default {
4949
isSelected,
5050
swatchColor: { table: { disable: true } },
5151
isRectangle: { table: { disable: true } },
52-
withBorder: { table: { disable: true } },
5352
isGradient: { table: { disable: true } },
5453
isImage: { table: { disable: true } },
5554
isMixedValue: { table: { disable: true } },
@@ -62,6 +61,17 @@ export default {
6261
name: "Container width",
6362
table: { disable: true },
6463
},
64+
withBorder: {
65+
name: "Border",
66+
description: "Use the `lightBorder` class when grouped swatches have a color contrast ratio of less than 3:1.",
67+
type: { name: "string" },
68+
table: {
69+
type: { summary: "string", required: true },
70+
category: "Component",
71+
},
72+
options: ["noBorder", "lightBorder"],
73+
control: "select",
74+
},
6575
},
6676
args: {
6777
rootClass: "spectrum-SwatchGroup",
@@ -73,7 +83,6 @@ export default {
7383
items: [
7484
{swatchColor: "rgb(22, 135, 140)",},
7585
{swatchColor: "rgb(33, 132, 113)",},
76-
{swatchColor: "rgb(33, 132, 113)",},
7786
{swatchColor: "rgb(254, 132, 152)",},
7887
{swatchColor: "rgb(255, 127, 96)",},
7988
{swatchColor: "rgb(255, 209, 24)",},
@@ -142,6 +151,37 @@ export const Sizing = SizingTemplate.bind({});
142151
Sizing.args = {};
143152
Sizing.tags = ["autodocs", "!dev"];
144153

154+
/**
155+
* Swatches within a swatch group with low contrast (below 3:1 contrast with the background) have a less prominent border compared to the swatch component when used by itself.
156+
* Low contrast color swatches have a border of `gray-900` at 20%. This reduces the likelihood of the UI interfering with color perception and comparisons.
157+
* In this example, the lower contrast swatches utilize the `.spectrum-Swatch--lightBorder` class.
158+
*/
159+
export const WithLightBorder = Template.bind({});
160+
WithLightBorder.args = {
161+
items: [
162+
{swatchColor: "rgb(22, 135, 140)",},
163+
{swatchColor: "rgb(33, 132, 113)",},
164+
{swatchColor: "rgb(254, 132, 152)", withBorder: "lightBorder",},
165+
{swatchColor: "rgb(255, 127, 96)", withBorder: "lightBorder",},
166+
{swatchColor: "rgb(255, 209, 24)", withBorder: "lightBorder",},
167+
{swatchColor: "rgb(120, 91, 199)",},
168+
{swatchColor: "rgb(225, 234, 119)", withBorder: "lightBorder",},
169+
{swatchColor: "rgb(0, 225, 171)", withBorder: "lightBorder",},
170+
{swatchColor: "rgb(248, 239, 187)", withBorder: "lightBorder",},
171+
{swatchColor: "rgb(254, 205, 215)", withBorder: "lightBorder",},
172+
{swatchColor: "rgb(212, 182, 237)", withBorder: "lightBorder",},
173+
{swatchColor: "rgb(153, 219, 244)", withBorder: "lightBorder",},
174+
{swatchColor: "rgb(171, 238, 221)", withBorder: "lightBorder",},
175+
{swatchColor: "rgb(187, 182, 175)", withBorder: "lightBorder",},
176+
{swatchColor: "rgb(238, 211, 190)", withBorder: "lightBorder",},
177+
{swatchColor: "rgb(0, 143, 242)",},
178+
{swatchColor: "rgb(60, 49, 199)",},
179+
{swatchColor: "rgb(254, 71, 144)",},
180+
],
181+
};
182+
WithLightBorder.tags = ["autodocs", "!dev"];
183+
WithLightBorder.storyName = "With light border";
184+
145185
// ********* VRT ONLY ********* //
146186
export const WithForcedColors = Template.bind({});
147187
WithForcedColors.tags = ["!autodocs", "!dev", "test"];

components/swatchgroup/stories/template.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const Template = ({
1313
size = "m",
1414
density = "regular",
1515
rounding = "regular",
16+
withBorder = "noBorder",
1617
items = [],
1718
customStyles = {},
1819
isDisabled =false,
@@ -37,6 +38,7 @@ export const Template = ({
3738
rounding,
3839
isDisabled: isDisabled,
3940
isSelected: isSelected,
41+
withBorder,
4042
...swatch,
4143
}, context))}
4244
</div>

0 commit comments

Comments
 (0)