Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(popover, progresscircle, radio, rating, sidenav): site docs to storybook #2883

Merged
merged 10 commits into from
Sep 5, 2024
Prev Previous commit
Next Next commit
docs(rating): migrate docs to storybook and stories cleanup
Adjust some stories and controls to improve documentation and make sure
that any docs site documentation is represented.

docs(rating): fix disabled stars not showing in storybook

The Storybook template was excluding the is-selected and is-currentValue
classes for disabled and read-only, when it shouldn't have been; this
now matches the markup on the docs site and fixes the disabled rating
not showing filled stars.
  • Loading branch information
jawinn committed Sep 5, 2024
commit bb3c9a9056cfd72f442192d6658a6b15e9929500
16 changes: 16 additions & 0 deletions components/rating/stories/rating.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Template } from "./template.js";

/**
* A rating element is used to display or collect a user's rating of an item as represented by a number of stars.
*
* All active stars have the class `is-selected` applied. Additionally, the current value (the last active star) has the class `is-currentValue` applied.
*/
export default {
title: "Rating",
Expand All @@ -17,15 +19,18 @@ export default {
isReadOnly,
max: {
name: "Maximum value",
description: "The total number of stars. Star ratings should always have 5 available stars. This shouldn't be increased or decreased to fit various containers.",
type: { name: "number" },
table: {
type: { summary: "number" },
category: "Content",
disable: true,
},
control: { type: "number" },
},
value: {
name: "Value",
description: "The current rating, represented by the number of selected stars.",
type: { name: "number" },
table: {
type: { summary: "number" },
Expand All @@ -38,6 +43,8 @@ export default {
args: {
rootClass: "spectrum-Rating",
isDisabled: false,
isEmphasized: false,
isReadOnly: false,
max: 5,
value: 3,
},
Expand All @@ -46,6 +53,9 @@ export default {
},
};

/**
* A initial value of three is used for the following examples, to demonstrate both active and inactive stars.
*/
export const Default = RatingGroup.bind({});
Default.args = {};

Expand All @@ -60,7 +70,12 @@ WithForcedColors.parameters = {
};

// ********* DOCS ONLY ********* //

/**
* A non-interactive rating.
*/
export const ReadOnly = Template.bind({});
ReadOnly.storyName = "Read-only";
jawinn marked this conversation as resolved.
Show resolved Hide resolved
ReadOnly.tags = ["!dev"];
ReadOnly.args = {
isReadOnly: true,
Expand All @@ -79,6 +94,7 @@ Emphasized.parameters = {
};

export const ReadOnlyEmphasized = Template.bind({});
ReadOnlyEmphasized.storyName = "Read-only, emphasized";
ReadOnlyEmphasized.tags = ["!dev"];
ReadOnlyEmphasized.args = {
isEmphasized: true,
Expand Down
2 changes: 1 addition & 1 deletion components/rating/stories/rating.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const RatingGroup = Variants({
isFocused: true,
},
{
testHeading: "Read only",
testHeading: "Read-only",
isReadOnly: true,
},
]
Expand Down
5 changes: 2 additions & 3 deletions components/rating/stories/template.js
jawinn marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ export const Template = ({
<span
class=${classMap({
[`${rootClass}-icon`]: true,
"is-selected": !isDisabled && idx <= value - 1,
"is-currentValue":
!isDisabled && !isReadOnly && idx === value - 1,
"is-selected": idx <= value - 1,
"is-currentValue": idx === value - 1,
jawinn marked this conversation as resolved.
Show resolved Hide resolved
})}
@click=${function() {
updateArgs({ value: idx + 1, isFocused: true });
Expand Down