Skip to content

Commit

Permalink
chore(storybook): add custom SB theme
Browse files Browse the repository at this point in the history
  • Loading branch information
itsjavi committed Aug 31, 2024
1 parent 1f1e0ca commit 7c59fcb
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { addons } from "@storybook/manager-api";
import registerDarkModeAddon from "./addons/toggle-dark-mode/addon-setup";
import customTheme from "./theme";

addons.setConfig({
theme: customTheme,
});

// Register the addon
registerDarkModeAddon();
4 changes: 4 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import "./preview.css";

import type { Preview } from "@storybook/react";
import * as darkModeConstants from "./addons/toggle-dark-mode/addon-constants";
import customTheme from "./theme";

const preview: Preview = {
parameters: {
docs: {
theme: customTheme,
},
controls: {
matchers: {
color: /(background|color)$/i,
Expand Down
11 changes: 11 additions & 0 deletions .storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { create } from "@storybook/theming/create";

export default create({
base: "dark",
brandTitle: "Glassy UI",
brandUrl: "https://itsjavi.com/glassy-ui",
brandTarget: "_self",
brandImage: undefined, //url
});

// @see https://storybook.js.org/docs/configure/user-interface/theming#create-a-theme-quickstart
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"@storybook/react": "^8.2.9",
"@storybook/react-vite": "^8.2.9",
"@storybook/test": "^8.2.9",
"@storybook/theming": "^8.2.9",
"@types/node": "^22.5.1",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 36 additions & 8 deletions src/stories/breadcrumb.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import type { Meta, StoryObj } from '@storybook/react';
import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator } from '../components/ui/breadcrumb';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import type { Meta, StoryObj } from "@storybook/react";
import {
Breadcrumb,
BreadcrumbEllipsis,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "../components/ui/breadcrumb";

const meta: Meta<typeof Breadcrumb> = {
title: 'UI/Breadcrumb',
title: "UI/Breadcrumb",
component: Breadcrumb,
tags: ['autodocs'],
tags: ["autodocs"],
};

export default meta;
Expand All @@ -13,19 +27,33 @@ type Story = StoryObj<typeof Breadcrumb>;
export const Default: Story = {
render: () => (
<Breadcrumb>
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/">Home</BreadcrumbLink>
<BreadcrumbLink href="#/">Home</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink href="/docs">Docs</BreadcrumbLink>
<DropdownMenu>
<DropdownMenuTrigger className="flex items-center gap-1">
<BreadcrumbEllipsis className="h-4 w-4" />
<span className="sr-only">Toggle menu</span>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem>Documentation</DropdownMenuItem>
<DropdownMenuItem>Themes</DropdownMenuItem>
<DropdownMenuItem>GitHub</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbLink href="#/docs/components">Components</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>Breadcrumb</BreadcrumbPage>
</BreadcrumbItem>
</Breadcrumb>
</BreadcrumbList>
</Breadcrumb>
),
};

0 comments on commit 7c59fcb

Please sign in to comment.