Skip to content

Commit

Permalink
Setup Storybook with Tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Mar 5, 2024
1 parent 03f33cc commit 4b48b31
Show file tree
Hide file tree
Showing 11 changed files with 668 additions and 1,471 deletions.
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
auto-install-peers = true
public-hoist-pattern[]=*storybook*
hoist-pattern[]=!@storybook*
hoist-pattern[]=!storybook*
1 change: 1 addition & 0 deletions apps/docs/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "../../../packages/ui/index.css";
20 changes: 11 additions & 9 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@
},
"dependencies": {
"@acme/ui": "workspace:*",
"autoprefixer": "^10.4.18",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"tailwindcss": "^3.4.1"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@storybook/addon-actions": "^7.6.17",
"@storybook/addon-docs": "^7.6.17",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-links": "^7.6.17",
"@storybook/react": "^7.6.17",
"@storybook/react-vite": "^7.6.17",
"@repo/typescript-config": "workspace:*",
"@storybook/addon-actions": "^8.0.0-rc.1",
"@storybook/addon-docs": "^8.0.0-rc.1",
"@storybook/addon-essentials": "^8.0.0-rc.1",
"@storybook/addon-links": "^8.0.0-rc.1",
"@storybook/react": "^8.0.0-rc.1",
"@storybook/react-vite": "^8.0.0-rc.1",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.57.0",
"serve": "^14.2.1",
"storybook": "^7.6.17",
"@repo/typescript-config": "workspace:*",
"storybook": "^8.0.0-rc.1",
"typescript": "^5.3.3",
"vite": "^5.1.4"
}
Expand Down
9 changes: 9 additions & 0 deletions apps/docs/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: [
require("autoprefixer"),
require("tailwindcss")("../../packages/ui/tailwind.config.js"),
],
};

module.exports = config;
6 changes: 6 additions & 0 deletions apps/docs/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
plugins: [react()],
});
3 changes: 3 additions & 0 deletions packages/ui/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
7 changes: 6 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"autoprefixer": "^10.4.18",
"eslint": "^8.57.0",
"postcss": "^8.4.35",
"react": "^18.2.0",
"@repo/typescript-config": "workspace:*",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"tailwindcss": "^3.4.1"
}
}
6 changes: 6 additions & 0 deletions packages/ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
9 changes: 6 additions & 3 deletions packages/ui/src/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ export interface ButtonProps

export function Button({ children, ...other }: ButtonProps): JSX.Element {
return (
<button type="button" {...other}>
{children}
</button>
<div>
<button type="button" {...other}>
{children}
</button>
<p className="text-3xl font-bold underline">Hello world</p>
</div>
);
}

Expand Down
10 changes: 10 additions & 0 deletions packages/ui/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { join } = require("node:path");

/** @type {import('tailwindcss').Config} */
module.exports = {
content: [join(__dirname, "./src/**/*.{js,ts,jsx,tsx}")],
theme: {
extend: {},
},
plugins: [],
};
Loading

0 comments on commit 4b48b31

Please sign in to comment.