Skip to content

Commit 04d3f4e

Browse files
docs(swatch): add lightBorder template support and story
1 parent 582181c commit 04d3f4e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

components/swatch/stories/swatch.stories.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default {
6969
type: { summary: "string", required: true },
7070
category: "Component",
7171
},
72-
options: ["default", "noBorder"],
72+
options: ["default", "noBorder", "lightBorder"],
7373
control: "select",
7474
},
7575
isRectangle: {
@@ -191,6 +191,11 @@ Selected.args = {
191191
};
192192
Selected.tags = ["autodocs", "!dev"];
193193

194+
/**
195+
* By default, swatches have a border. However, when swatches are used within a swatch group, there are additional border considerations.
196+
* - When color swatches are used in a [swatch group](?path=/docs/components-swatch-group--docs), they typically have the `.spectrum-Swatch--noBorder` class.
197+
* - When and only when color swatches used in a [swatch group](?path=/docs/components-swatch-group--docs) have low contrast (below 3:1 contrast with the background), those swatches will have a less prominent border compared to the swatch component when used by itself. They individually use the `.spectrum-Swatch--lightBorder` class.
198+
*/
194199
export const Border = BorderGroup.bind({});
195200
Border.tags = ["autodocs", "!dev"];
196201

components/swatch/stories/template.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export const RoundingGroup = (args, context) => html`
210210
`;
211211

212212
export const BorderGroup = (args, context) => html `
213-
<div style="display: flex; gap: 8px; padding: 8px 0;">
213+
<div style="display: flex; flex-direction: column; gap: 8px; padding: 8px 0;">
214214
<div>
215215
${Typography({
216216
semantics: "detail",
@@ -234,6 +234,18 @@ export const BorderGroup = (args, context) => html `
234234
withBorder: "noBorder",
235235
}, context)}
236236
</div>
237+
<div>
238+
${Typography({
239+
semantics: "detail",
240+
size: "s",
241+
content: ["Light border"],
242+
customClasses: ["chromatic-ignore"],
243+
})}
244+
${Template({
245+
...args,
246+
withBorder: "lightBorder",
247+
}, context)}
248+
</div>
237249
</div>
238250
`;
239251

0 commit comments

Comments
 (0)