Skip to content

feat: introduce badges addon for storybook #895

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

Merged
merged 3 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions packages/components/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
"@storybook/addon-a11y",
"storybook-css-modules-preset",
"@storybook/addon-interactions",
"@geometricpanda/storybook-addon-badges",
{
name: "@storybook/addon-postcss",
options: {
Expand Down
26 changes: 26 additions & 0 deletions packages/components/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import "../src/styles/fonts.css";
import "../src/styles/global.css";
import "../src/styles/tailwindUtilities.css";

import {
BADGE,
defaultBadgesConfig,
} from "@geometricpanda/storybook-addon-badges";
import React from "react";

export const decorators = [
Expand All @@ -26,4 +30,26 @@ export const parameters = {
},
],
},
badgesConfig: {
deprecated: {
...defaultBadgesConfig[BADGE.DEPRECATED],
tooltip: "This component is deprecated, please avoid using it.",
},
beta: {
...defaultBadgesConfig[BADGE.BETA],
tooltip: {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could we remove the tooltips for now, until we find a use for them? 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm down for removing the tooltips, mostly to show configuration possibility

title: "This is Beta",
desc: "Be ready to receive updates frequently and leave a feedback",
links: [
{ title: "Read more", href: "http://path/to/your/docs" },
{
title: "Leave feedback",
onClick: () => {
alert("thanks for the feedback");
},
},
],
},
},
},
};
15 changes: 15 additions & 0 deletions packages/components/docs/badges-addon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { BADGE } from "@geometricpanda/storybook-addon-badges";
import { StoryObj } from "@storybook/react";
import React from "react";

const Example = () => <p>Example to show badges addon</p>;

export default {
Copy link
Contributor

@anniehu4 anniehu4 Mar 16, 2022

Choose a reason for hiding this comment

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

Is this mostly for internal documentation? Would suggest naming it title: "Documentation/BadgesAddon" (or once we merge with next, adding to one of the comprehensive docs files there)

oh derp just saw your comment -- removing before merge also works

title: "BadgesAddon",
component: Example,
parameters: {
badges: [BADGE.STABLE, BADGE.DEPRECATED, BADGE.BETA],
},
};

export const Default: StoryObj = {};
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"devDependencies": {
"@chanzuckerberg/axe-storybook-testing": "^5.0.0",
"@chanzuckerberg/story-utils": "^3.0.4",
"@geometricpanda/storybook-addon-badges": "^0.2.1",
"@storybook/addon-a11y": "^6.4.19",
"@storybook/addon-essentials": "^6.4.19",
"@storybook/addon-interactions": "^6.4.19",
Expand Down
50 changes: 50 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,7 @@ __metadata:
"@chanzuckerberg/axe-storybook-testing": ^5.0.0
"@chanzuckerberg/eds-tokens": ^0.9.0
"@chanzuckerberg/story-utils": ^3.0.4
"@geometricpanda/storybook-addon-badges": ^0.2.1
"@headlessui/react": ^1.4.3
"@storybook/addon-a11y": ^6.4.19
"@storybook/addon-essentials": ^6.4.19
Expand Down Expand Up @@ -2059,6 +2060,22 @@ __metadata:
languageName: node
linkType: hard

"@geometricpanda/storybook-addon-badges@npm:^0.2.1":
version: 0.2.1
resolution: "@geometricpanda/storybook-addon-badges@npm:0.2.1"
dependencies:
react: ^17.0.2
react-dom: ^17.0.2
react-is: ^17.0.2
peerDependencies:
"@storybook/addons": ^6.2.9
"@storybook/api": ^6.2.9
"@storybook/components": ^6.2.9
"@storybook/theming": ^6.2.9
checksum: a063d91beb9d5a55b26c7db80f3b0806b4d37d8359a722487a6cb510493a20e8b8fd1d45a5314fd80b5f4aaf0bbf556ca284bfa19b709dd353da3ec7b4e82553
languageName: node
linkType: hard

"@headlessui/react@npm:^1.4.3":
version: 1.4.3
resolution: "@headlessui/react@npm:1.4.3"
Expand Down Expand Up @@ -17946,6 +17963,19 @@ __metadata:
languageName: node
linkType: hard

"react-dom@npm:^17.0.2":
version: 17.0.2
resolution: "react-dom@npm:17.0.2"
dependencies:
loose-envify: ^1.1.0
object-assign: ^4.1.1
scheduler: ^0.20.2
peerDependencies:
react: 17.0.2
checksum: 1c1eaa3bca7c7228d24b70932e3d7c99e70d1d04e13bb0843bbf321582bc25d7961d6b8a6978a58a598af2af496d1cedcfb1bf65f6b0960a0a8161cb8dab743c
languageName: node
linkType: hard

"react-draggable@npm:^4.4.3":
version: 4.4.4
resolution: "react-draggable@npm:4.4.4"
Expand Down Expand Up @@ -18147,6 +18177,16 @@ __metadata:
languageName: node
linkType: hard

"react@npm:^17.0.2":
version: 17.0.2
resolution: "react@npm:17.0.2"
dependencies:
loose-envify: ^1.1.0
object-assign: ^4.1.1
checksum: b254cc17ce3011788330f7bbf383ab653c6848902d7936a87b09d835d091e3f295f7e9dd1597c6daac5dc80f90e778c8230218ba8ad599f74adcc11e33b9d61b
languageName: node
linkType: hard

"read-cache@npm:^1.0.0":
version: 1.0.0
resolution: "read-cache@npm:1.0.0"
Expand Down Expand Up @@ -18988,6 +19028,16 @@ __metadata:
languageName: node
linkType: hard

"scheduler@npm:^0.20.2":
version: 0.20.2
resolution: "scheduler@npm:0.20.2"
dependencies:
loose-envify: ^1.1.0
object-assign: ^4.1.1
checksum: c4b35cf967c8f0d3e65753252d0f260271f81a81e427241295c5a7b783abf4ea9e905f22f815ab66676f5313be0a25f47be582254db8f9241b259213e999b8fc
languageName: node
linkType: hard

"schema-utils@npm:2.7.0":
version: 2.7.0
resolution: "schema-utils@npm:2.7.0"
Expand Down