Skip to content

Commit

Permalink
docs: sidebar tags (#1559)
Browse files Browse the repository at this point in the history
  • Loading branch information
talkor authored Oct 16, 2023
1 parent dc05b74 commit 0e6ec8c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion .storybook/addons.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from "react";
import "@storybook/addon-docs/register";
import "@storybook/addon-interactions/register";
import "@storybook/addon-actions/register";
import "@storybook/addon-links/register";
import { create } from "@storybook/theming";
import { addons } from "@storybook/addons";
import logo from "./logo.png";
import { SidebarItem } from "vibe-storybook-components";
import "vibe-storybook-components/index.css";

window.STORYBOOK_GA_ID = "UA-308574295";
window.STORYBOOK_REACT_GA_OPTIONS = {};
Expand All @@ -22,5 +25,22 @@ const theme = create({
});

addons.setConfig({
theme
theme,
sidebar: {
renderLabel: ({ name, parameters = {} }) => {
const statusRegex = /\[([^)]+)\]/gi;
const [statusMatch, statusType] = statusRegex.exec(name) || [];

if (statusMatch) {
return <SidebarItem status={statusType}>{name.replace(statusMatch, "").trim()}</SidebarItem>;
}

const { status: storyStatus } = parameters;
if (!storyStatus) {
return name;
}

return <SidebarItem status={parameters.status}>{name.replace(storyStatus, "").trim()}</SidebarItem>;
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const metaSettings = createStoryMetaSettingsDecorator({
});

<Meta
title="Text/LegacyHeading"
title="Text/LegacyHeading [deprecated]"
component={Heading}
argTypes={metaSettings.argTypes}
decorators={metaSettings.decorators}
Expand Down

0 comments on commit 0e6ec8c

Please sign in to comment.