Skip to content

Commit c7b5a86

Browse files
docs(swatch): fix no color/empty story and test
- adds documentation around making sure the default border is applied in cases where a swatch is empty/undefined - updates the no-color test case to apply the default border - removes non-existent swatch arguments isGradient and isImage - fix rectangle story name to shape
1 parent fe2235c commit c7b5a86

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

components/swatch/stories/swatch.stories.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { isDisabled, isSelected, size } from "@spectrum-css/preview/types";
33
import { Sizes } from "@spectrum-css/preview/decorators";
44
import pkgJson from "../package.json";
55
import { SwatchGroup } from "./swatch.test.js";
6-
import { Template, DisabledGroup, NothingGroup, RoundingGroup, BorderGroup, SizingGroup } from "./template";
6+
import { Template, DisabledGroup, EmptyGroup, RoundingGroup, BorderGroup, SizingGroup } from "./template";
77

88
/**
99
* A swatch shows a small sample of a fill--such as a color, gradient, texture, or material--that is intended to be applied to an object.
@@ -183,29 +183,30 @@ Border.parameters = {
183183
/**
184184
* Swatches can also have a rectangle shape with an aspect ratio of 2:1. The square shape is the default and is used in swatch groups (e.g., a palette of colors).
185185
*/
186-
export const Rectangle = Template.bind({});
187-
Rectangle.args = {
186+
export const Shape = Template.bind({});
187+
Shape.args = {
188188
shape: "rectangle",
189189
swatchColor: "rgba(174, 216, 230, 0.25)",
190190
};
191-
Rectangle.tags = ["!dev"];
192-
Rectangle.parameters = {
191+
Shape.tags = ["!dev"];
192+
Shape.parameters = {
193193
chromatic: { disableSnapshot: true },
194194
};
195+
Shape.storyName = "Shape - rectangle";
195196

196197
/**
197-
* A swatch will appear "empty" when its color, image, or gradient are undefined.
198+
* A swatch will appear "empty" when its preview is undefined, for instance when the image or gradient is undefined, or when a swatch color is transparent. The `.is-nothing` class is applied to the swatch in these cases. Implementations should ensure that the default border style is applied when a swatch is empty.
198199
*/
199-
export const Nothing = (args, context) => Sizes({
200-
Template: NothingGroup,
200+
export const Empty = (args, context) => Sizes({
201+
Template: EmptyGroup,
201202
withHeading: false,
202203
...args,
203204
}, context);
204-
Nothing.args = {
205+
Empty.args = {
205206
swatchColor: "transparent",
206207
};
207-
Nothing.tags = ["!dev"];
208-
Nothing.parameters = {
208+
Empty.tags = ["!dev"];
209+
Empty.parameters = {
209210
chromatic: { disableSnapshot: true },
210211
};
211212

components/swatch/stories/swatch.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ export const SwatchGroup = Variants({
3434
},
3535
{
3636
testHeading: "Gradient",
37-
isGradient: true,
3837
gradient: "linear-gradient(to right, rgba(0, 0, 0, 88%), rgb(174, 216, 230))",
3938
swatchColor: "rgba(174, 216, 230, 0.3)",
4039
},
4140
{
4241
testHeading: "Image",
43-
isImage: true,
4442
imageUrl: "example-ava@2x.png",
4543
},
4644
{
@@ -54,11 +52,12 @@ export const SwatchGroup = Variants({
5452
isDisabled: true,
5553
},
5654
{
57-
testHeading: "No color",
55+
testHeading: "No color/empty",
5856
swatchColor: undefined,
5957
imageUrl: "",
6058
gradient: "",
6159
isMixedValue: false,
60+
borderStyle: "default",
6261
},
6362
{
6463
testHeading: "Selected",

components/swatch/stories/template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const BorderGroup = (args, context) => Container({
151151
});
152152

153153
/* Shows a single group of swatches that are empty/nothing in various shapes and rounding. */
154-
export const NothingGroup = (args, context) => Container({
154+
export const EmptyGroup = (args, context) => Container({
155155
withBorder: false,
156156
content: html`
157157
${Container({

0 commit comments

Comments
 (0)