Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/statuslight/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,12 @@ Co-authored-by: Patrick Fulton <pfulton@adobe.com>

- implement t-shirt sizing for Status Light, closes [#686](https://github.com/adobe/spectrum-css/issues/686) ([0a20b52](https://github.com/adobe/spectrum-css/commit/0a20b52))

### Migration Guide

#### T-shirt sizing

Status Light now supports t-shirt sizing and requires that you specify the size by adding a `.spectrum-StatusLight--size*` class.

<a name="3.0.0-beta.4"></a>

## 3.0.0-beta.4
Expand Down
65 changes: 64 additions & 1 deletion components/statuslight/stories/statuslight.stories.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { size } from "@spectrum-css/preview/types";
import { isDisabled, size } from "@spectrum-css/preview/types";
import { Sizes } from "@spectrum-css/preview/decorators";
import pkgJson from "../package.json";
import { StatusLightGroup } from "./statuslight.test.js";
import { Template, SemanticGroup, NonsemanticGroup } from "./template.js";

/**
* Status lights describe the condition of an entity. They can be used to convey semantic meaning, such as statuses and categories.
*/
export default {
title: "Status light",
component: "Statuslight",
Expand All @@ -17,8 +22,10 @@ export default {
},
control: { type: "text" },
},
isDisabled,
variant: {
name: "Variant",
description: "Changes the color of the status dot. The variant list includes both semantic and non-semantic options.",
type: { name: "string", required: true },
table: {
type: { summary: "string" },
Expand Down Expand Up @@ -54,15 +61,71 @@ export default {
size: "m",
label: "Status",
variant: "info",
isDisabled: false,
},
parameters: {
packageJson: pkgJson,
},
};

/**
* Status lights should always include a label with text that clearly communicates the kind of status being shown. Color alone is not enough to communicate the status. Do not change the text color to match the dot.
*
* When the text is too long for the horizontal space available, it wraps to form another line.
*/
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask what your reasoning was for not showing the text wrapping to form another line? I think I made the opposite choice in some work I just did for switch, but I'm on the fence on whether I think that's the best way or whether we specifically need to demonstrate text wrapping.

I notice we're testing status light wrapping in the testing preview, which is definitely good, but I'm not sure that necessarily means we need to show it on the Docs page 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I had a similar conversation with Cassondra about this when I moved the documentation over for another component, but now I'm not sure where that conversation is. In-line alert is like this, where the truncation/wrapping option is only in the test view, and I know I migrated those docs. Maybe that's what I was thinking of? Badge is like this too I see, but then checkbox and radio show wrapping on their docs pages.

I figure at least a call out is good on the docs page. And then people can also test with a long label themselves? I know that's not a very convincing reason/answer!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds reasonable to me. We can always add it in later if we want to incorporate an example to the docs.

export const Default = StatusLightGroup.bind({});
Default.args = {};

/**
* Status lights come in four different sizes: small, medium, large, and extra-large. The medium size is the default and most frequently used option. Use the other sizes sparingly; they should be used to create a hierarchy of importance within the page.
*/
export const Sizing = (args, context) => Sizes({
Template,
withBorder: false,
withHeading: false,
...args,
}, context);
Sizing.tags = ["!dev"];
Sizing.parameters = {
chromatic: { disableSnapshot: true },
};

/**
* When status lights have a semantic meaning, they use semantic colors. Use these variants for the following statuses:
* - Informative (active, in use, live, published)
* - Neutral (archived, deleted, paused, draft, not started, ended)
* - Positive (approved, complete, success, new, purchased, licensed)
* - Notice (needs approval, pending, scheduled, syncing, indexing, processing)
* - Negative (error, alert, rejected, failed)
*
* Semantic status lights should never be used for color coding categories or labels, and vice versa.
*/
export const SemanticColors = SemanticGroup.bind({});
SemanticColors.tags = ["!dev"];
SemanticColors.parameters = {
chromatic: { disableSnapshot: true },
};
SemanticColors.storyName = "Semantic colors";

/**
* When status lights are used to color code categories and labels that are commonly found in data visualization, they use label colors. The ideal usage for these is when there are 8 or fewer categories or labels being color coded.
*/
export const NonSemanticColors = NonsemanticGroup.bind({});
NonSemanticColors.tags = ["!dev"];
NonSemanticColors.parameters = {
chromatic: { disableSnapshot: true },
};
NonSemanticColors.storyName = "Non-semantic colors";

export const Disabled = Template.bind({});
Disabled.args = {
isDisabled: true,
};
Disabled.tags = ["!dev"];
Disabled.parameters = {
chromatic: { disableSnapshot: true },
};

// ********* VRT ONLY ********* //
export const WithForcedColors = StatusLightGroup.bind({});
WithForcedColors.tags = ["!autodocs", "!dev"];
Expand Down
8 changes: 7 additions & 1 deletion components/statuslight/stories/statuslight.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ export const StatusLightGroup = Variants({
{
testHeading: "Truncation",
label: "Status light label that is long and wraps to the next line",
customStyles: {"max-width": "150px"}
customStyles: {"max-width": "150px"},
}
],
stateData: [
{
testHeading: "Disabled",
isDisabled: true,
}
]
});
38 changes: 38 additions & 0 deletions components/statuslight/stories/template.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Container } from "@spectrum-css/preview/decorators";
import { html } from "lit";
import { classMap } from "lit/directives/class-map.js";
import { styleMap } from "lit/directives/style-map.js";
Expand All @@ -9,6 +10,7 @@ export const Template = ({
size = "m",
variant = "info",
label,
isDisabled,
customStyles = {},
} = {}) => html`
<div
Expand All @@ -17,9 +19,45 @@ export const Template = ({
[`${rootClass}--size${size?.toUpperCase()}`]:
typeof size !== "undefined",
[`${rootClass}--${variant}`]: typeof variant !== "undefined",
"is-disabled": isDisabled,
})}
style=${styleMap(customStyles)}
>
${label}
</div>
`;

// TODO: the accent variant will be removed in S2.
export const SemanticGroup = (args, context) => Container({
withBorder: false,
direction: "column",
content: html`${[
"accent",
"neutral",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had never noticed before (or maybe I forgot) that the neutral variant is italicized. Clearly that's an intentional design decision, but it's nowhere in the guidelines. Have you ever picked up any historical knowledge about that? I'd love to see some sort of explanation on the Docs page, although I definitely don't think it's a requirement here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have much historical knowledge as to why it was italics, but I do know that, for S2, the italicization is no longer supported.

Note: The neutral variant of the status light label uses default-font-style rather than italics as in S1.

"info",
"negative",
"notice",
"positive"].map(variant => Template({...args, variant: variant, label: `${variant.charAt(0).toUpperCase() + variant.slice(1)} status` }, context))
}`
});

export const NonsemanticGroup = (args, context) => Container({
withBorder: false,
direction: "column",
content: html`${[
"gray",
"red",
"orange",
"yellow",
"chartreuse",
"celery",
"green",
"seafoam",
"cyan",
"blue",
"indigo",
"purple",
"fuchsia",
"magenta",].map(variant => Template({...args, variant: variant, label: `${variant.charAt(0).toUpperCase() + variant.slice(1)}`}, context))
}`
});