Skip to content

Commit

Permalink
feat(react-storybook): use core package for preset and recipes
Browse files Browse the repository at this point in the history
- use Panda CSS + PostCSS instead of static CSS

Signed-off-by: Guillaume Bonnet <[email protected]>
  • Loading branch information
MrSquaare committed Nov 30, 2024
1 parent a7d6ae5 commit 2f59684
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/react-storybook/.storybook/preview.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "@sandwich-ui/react/style.css";
@layer reset, base, tokens, recipes, utilities;

body:has(#storybook-root:not([hidden])) {
background-color: #ffffff;
Expand Down
6 changes: 5 additions & 1 deletion packages/react-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
"version": "0.1.1",
"type": "module",
"scripts": {
"predev": "panda codegen",
"dev": "storybook dev -p 6006",
"prebuild": "rimraf storybook-static/",
"prebuild": "rimraf storybook-static/ && panda codegen",
"build": "storybook build",
"preview": "vite preview --outDir storybook-static/",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"clean": "rimraf storybook-static/ node_modules/.cache/"
},
"dependencies": {
"@sandwich-ui/core": "workspace:*",
"@sandwich-ui/react": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@pandacss/dev": "^0.48.0",
"@storybook/addon-essentials": "^8.4.5",
"@storybook/addon-interactions": "^8.4.5",
"@storybook/addon-links": "^8.4.5",
Expand All @@ -39,6 +42,7 @@
"eslint-plugin-react-refresh": "^0.4.14",
"eslint-plugin-storybook": "^0.11.1",
"globals": "^15.12.0",
"postcss": "^8.4.49",
"rimraf": "^6.0.1",
"storybook": "^8.4.5",
"typescript": "^5.7.2",
Expand Down
15 changes: 15 additions & 0 deletions packages/react-storybook/panda.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from "@pandacss/dev";
import sandwichUIPreset from "@sandwich-ui/core/preset";

export default defineConfig({
preflight: true,
prefix: "sw",
presets: ["@pandacss/dev/presets", sandwichUIPreset],
include: [
"./node_modules/@sandwich-ui/core/dist/panda.buildinfo.json",
"./node_modules/@sandwich-ui/react/dist/panda.buildinfo.json",
"./src/**/*.{js,jsx,ts,tsx}",
],
importMap: "@sandwich-ui/core",
outdir: "./node_modules/@sandwich-ui/core/dist/styled-system",
});
5 changes: 5 additions & 0 deletions packages/react-storybook/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
plugins: {
"@pandacss/dev/postcss": {},
},
};
8 changes: 2 additions & 6 deletions packages/react-storybook/src/components/Avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
Avatar,
AvatarFallback,
AvatarImage,
AvatarRecipe,
} from "@sandwich-ui/react";
import { AvatarRecipe } from "@sandwich-ui/core/recipes";
import { Avatar, AvatarFallback, AvatarImage } from "@sandwich-ui/react";
import type { Meta, StoryObj } from "@storybook/react";

const meta = {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-storybook/src/components/Badge.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Badge, BadgeRecipe } from "@sandwich-ui/react";
import { BadgeRecipe } from "@sandwich-ui/core/recipes";
import { Badge } from "@sandwich-ui/react";
import type { Meta, StoryObj } from "@storybook/react";

const meta = {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-storybook/src/components/Button.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button, ButtonRecipe } from "@sandwich-ui/react";
import { ButtonRecipe } from "@sandwich-ui/core/recipes";
import { Button } from "@sandwich-ui/react";
import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";

Expand Down
6 changes: 3 additions & 3 deletions packages/react-storybook/src/components/Menu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ export const Default: Story = {
<Button>Menu</Button>
</MenuTrigger>
<MenuContent>
<MenuItem id={"item-1"} onClick={fn()}>
<MenuItem onClick={fn()} value={"item-1"}>
Item 1
</MenuItem>
<MenuItem id={"item-2"} onClick={fn()}>
<MenuItem onClick={fn()} value={"item-2"}>
Item 2
</MenuItem>
<MenuItem id={"item-3"} onClick={fn()}>
<MenuItem onClick={fn()} value={"item-3"}>
Item 3
</MenuItem>
</MenuContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const Default: Story = {
</Avatar>
</MenuTrigger>
<MenuContent>
<MenuItem id={"item-1"}>Profile</MenuItem>
<MenuItem id={"item-2"}>Sign out</MenuItem>
<MenuItem value={"profile"}>Profile</MenuItem>
<MenuItem value={"sign-out"}>Sign out</MenuItem>
</MenuContent>
</Menu>
</NavigationList>
Expand Down

0 comments on commit 2f59684

Please sign in to comment.