Skip to content

Commit

Permalink
feat(storybook): custom properties panel
Browse files Browse the repository at this point in the history
  • Loading branch information
castastrophe committed Sep 26, 2024
1 parent 97fe29f commit e1f7a95
Show file tree
Hide file tree
Showing 87 changed files with 1,068 additions and 84 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-plants-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spectrum-css/generator": patch
---

Update story templates to include the cssprops imports
5 changes: 5 additions & 0 deletions .changeset/new-bulldogs-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spectrum-css/preview": minor
---

New feature: Custom properties panel added to the development preview showing a list of modifiable custom properties as loaded from the metadata/metadata.json resource in each component.
2 changes: 2 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export default {
"@chromaui/addon-visual-tests",
// https://storybook.js.org/addons/@storybook/addon-designs/
"@storybook/addon-designs",
// https://github.com/ljcl/storybook-addon-cssprops
"@ljcl/storybook-addon-cssprops",
],
core: {
disableTelemetry: true,
Expand Down
1 change: 1 addition & 0 deletions .storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@babel/core": "^7.25.2",
"@chromaui/addon-visual-tests": "^1.0.0",
"@etchteam/storybook-addon-status": "^5.0.0",
"@ljcl/storybook-addon-cssprops": "^4.0.0",
"@storybook/addon-a11y": "^8.3.2",
"@storybook/addon-actions": "^8.3.2",
"@storybook/addon-console": "^3.0.0",
Expand Down
11 changes: 11 additions & 0 deletions components/accordion/stories/accordion.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Template as Link } from "@spectrum-css/link/stories/template.js";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { size } from "@spectrum-css/preview/types";
import { Template as Typography } from "@spectrum-css/typography/stories/template.js";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";
import { AccordionGroup } from "./accordion.test.js";
import { Template } from "./template.js";
Expand Down Expand Up @@ -57,6 +58,16 @@ export default {
},
chromatic: { disableSnapshot: true },
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
tags: ["!autodocs"],
};
Expand Down
12 changes: 12 additions & 0 deletions components/actionbar/stories/actionbar.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { default as CloseButton } from "@spectrum-css/closebutton/stories/closeb
import { default as Popover } from "@spectrum-css/popover/stories/popover.stories.js";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isEmphasized, isOpen } from "@spectrum-css/preview/types";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { ActionBarGroup } from "./actionbar.test.js";
import { Template } from "./template.js";

Expand Down Expand Up @@ -67,6 +69,16 @@ export default {
url: "https://www.figma.com/file/MPtRIVRzPp2VHiEplwXL2X/S-%2F-Manual?node-id=465%3A3127&t=xbooxCWItOFgG2xM-1",
},
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
tags: ["!autodocs"],
};
Expand Down
12 changes: 12 additions & 0 deletions components/actionbutton/stories/actionbutton.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isActive, isDisabled, isEmphasized, isFocused, isHovered, isQuiet, isSelected, size, staticColor } from "@spectrum-css/preview/types";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { ActionButtonGroup, ActionButtons } from "./actionbutton.test.js";

/**
Expand Down Expand Up @@ -73,6 +75,16 @@ export default {
handles: ["click .spectrum-ActionButton:not([disabled])"],
},
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
docs: {
story: {
height: "auto",
Expand Down
12 changes: 12 additions & 0 deletions components/actiongroup/stories/actiongroup.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { default as ActionButton } from "@spectrum-css/actionbutton/stories/actionbutton.stories.js";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { size } from "@spectrum-css/preview/types";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { ActionGroups } from "./actiongroup.test.js";

/**
Expand Down Expand Up @@ -61,6 +63,16 @@ export default {
],
},
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
};

Expand Down
6 changes: 6 additions & 0 deletions components/actionmenu/stories/actionmenu.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { default as Popover } from "@spectrum-css/popover/stories/popover.storie
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isOpen } from "@spectrum-css/preview/types";
import pkgJson from "../package.json";

import { ActionMenuGroup } from "./actionmenu.test.js";

/**
Expand Down Expand Up @@ -49,6 +50,11 @@ export default {
],
},
packageJson: pkgJson,
cssprops: {
...(Popover?.parameters?.cssprops ?? {}),
...(ActionButton?.parameters?.cssprops ?? {}),
...(Menu.parameters?.cssprops ?? {}),
},
docs: {
story: {
height: "200px",
Expand Down
16 changes: 14 additions & 2 deletions components/alertbanner/stories/alertbanner.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isOpen } from "@spectrum-css/preview/types";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { AlertBannerGroup } from "./alertbanner.test.js";
import { ActionableOptionsTemplate, Template, TextOverflowTemplate } from "./template.js";

Expand Down Expand Up @@ -68,6 +70,16 @@ export default {
handles: ["click .spectrum-AlertBanner button"],
},
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
};

Expand Down Expand Up @@ -133,7 +145,7 @@ Negative.parameters = {
* The alert banner component can contain both an icon-only close button and a button with a contextual action to
* take. Whenever possible, include the in-line action button if there's a way for a user to quickly address the issue
* associated with an alert. There should never be more than one button with a contextual action in an alert banner.
*
*
* The close button is optional, depending on context. Consider adding one to let a user easily dismiss the alert.
*/
export const ActionableOptions = ActionableOptionsTemplate.bind({});
Expand All @@ -160,4 +172,4 @@ TextOverflow.args = {
};
TextOverflow.parameters = {
chromatic: { disableSnapshot: true },
};
};
12 changes: 12 additions & 0 deletions components/alertdialog/stories/alertdialog.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { withUnderlayWrapper } from "@spectrum-css/preview/decorators";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isOpen } from "@spectrum-css/preview/types";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { AlertDialogGroup } from "./alertdialog.test.js";
import { Template } from "./template.js";

Expand Down Expand Up @@ -49,6 +51,16 @@ export default {
}
},
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
decorators: [
withUnderlayWrapper,
Expand Down
12 changes: 12 additions & 0 deletions components/asset/stories/asset.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { AssetGroup } from "./asset.test.js";
import { Template } from "./template.js";

Expand Down Expand Up @@ -36,6 +38,16 @@ export default {
},
parameters: {
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
tags: ["!autodocs"],
};
Expand Down
12 changes: 12 additions & 0 deletions components/assetcard/stories/assetcard.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { default as Checkbox } from "@spectrum-css/checkbox/stories/checkbox.stories.js";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isFocused, isSelected } from "@spectrum-css/preview/types";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { AssetCardGroup } from "./assetcard.test.js";
import { Template } from "./template.js";

Expand Down Expand Up @@ -86,6 +88,16 @@ export default {
handles: [...(Checkbox.parameters?.actions?.handles ?? [])],
},
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
tags: ["!autodocs"],
};
Expand Down
12 changes: 12 additions & 0 deletions components/assetlist/stories/assetlist.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { default as Checkbox } from "@spectrum-css/checkbox/stories/checkbox.stories.js";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { AssetListGroup } from "./assetlist.test.js";

/**
Expand All @@ -20,6 +22,16 @@ export default {
handles: [...(Checkbox.parameters?.actions?.handles ?? [])],
},
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
};

Expand Down
12 changes: 12 additions & 0 deletions components/avatar/stories/avatar.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Sizes } from "@spectrum-css/preview/decorators";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isDisabled, size } from "@spectrum-css/preview/types";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { AvatarGroup } from "./avatar.test.js";
import { Template } from "./template.js";

Expand Down Expand Up @@ -58,6 +60,16 @@ export default {
},
parameters: {
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
tags: ["!autodocs"],
};
Expand Down
12 changes: 12 additions & 0 deletions components/badge/stories/badge.stories.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { size } from "@spectrum-css/preview/types";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { BadgeGroup } from "./badge.test.js";
import { PreviewSets } from "./template.js";

Expand Down Expand Up @@ -62,6 +64,16 @@ export default {
},
parameters: {
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
tags: ["!autodocs"],
};
Expand Down
18 changes: 15 additions & 3 deletions components/breadcrumb/stories/breadcrumb.stories.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isDragged } from "@spectrum-css/preview/types";
import data from "../metadata/metadata.json";
import pkgJson from "../package.json";

import { BreadcrumbGroup } from "./breadcrumb.test.js";
import { Template } from "./template";

/**
* Breadcrumbs show hierarchy and navigational context for a user's location within an app.
*
*
* ## Nesting
* Breadcrumbs truncate when there is not enough room to display all levels of the breadcrumb list, or as a way of managing relevance of the visible breadcrumb items in a deeply nested hierarchy. The truncation of breadcrumb items begins when either there is not enough room to display all items, or if there are 5 or more breadcrumbs to display. They are typically indicated by the truncated menu folder icon.
*
*
* The nested variants below are non-functional. Implementations can add their own overflow menus to display all options within a breadcrumb.
*
*
* ## Root Context
* Some applications find that displaying the root directory is useful for user orientation. This variation keeps the root visible when other folders are truncated into a menu. For example, when users can navigate file directories on their device as well as in the cloud, exposing a root directory called “On this device” is very helpful.
*/
Expand Down Expand Up @@ -41,6 +43,16 @@ export default {
},
parameters: {
packageJson: pkgJson,
cssprops: {
...data.modifiers.reduce((collection, item) => {
const key = item.replace(/^--/, "");
collection[key] = {
control: key.includes("color") ? "color" : "text",
category: "Modifiers",
};
return collection;
}, {})
},
},
};

Expand Down
Loading

0 comments on commit e1f7a95

Please sign in to comment.