Skip to content

Commit 16ed7fa

Browse files
committed
chore(viz): setup tailwind for storybook
1 parent ca985e6 commit 16ed7fa

File tree

10 files changed

+218
-41
lines changed

10 files changed

+218
-41
lines changed

packages/viz/.storybook/main.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
module.exports = {
2-
"stories": [
3-
"../src/**/*.stories.mdx",
4-
"../src/**/*.stories.@(js|jsx|ts|tsx)"
5-
],
6-
"addons": [
7-
"@storybook/addon-links",
8-
"@storybook/addon-essentials",
9-
"@storybook/addon-interactions"
10-
],
11-
"framework": "@storybook/react",
12-
"core": {
13-
"builder": "@storybook/builder-webpack5"
14-
}
15-
}
2+
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
3+
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
4+
framework: '@storybook/react',
5+
core: {
6+
builder: '@storybook/builder-webpack5',
7+
},
8+
};

packages/viz/.storybook/preview.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import '../dist/styles.css';
2+
13
export const parameters = {
2-
actions: { argTypesRegex: "^on[A-Z].*" },
4+
actions: { argTypesRegex: '^on[A-Z].*' },
35
controls: {
46
matchers: {
57
color: /(background|color)$/i,
68
date: /Date$/,
79
},
810
},
9-
}
11+
};

packages/viz/package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,39 @@
1010
"data structure",
1111
"collections-typescript"
1212
],
13+
"resolutions": {
14+
"webpack": "^5"
15+
},
1316
"author": "tur1ng <mohammadali.ap.2000@gmail.com>",
1417
"license": "ISC",
1518
"bugs": {
1619
"url": "https://github.com/always-maap/TS-Collection/issues"
1720
},
21+
"scripts": {
22+
"storybook": "yarn build-tailwind && start-storybook -p 6006",
23+
"build-storybook": "build-storybook",
24+
"build-tailwind": "tailwindcss -i ./src/styles.css -o ./dist/styles.css"
25+
},
1826
"homepage": "https://github.com/always-maap/TS-Collection#readme",
1927
"devDependencies": {
2028
"@babel/core": "^7.18.9",
2129
"@storybook/addon-actions": "^6.5.9",
2230
"@storybook/addon-essentials": "^6.5.9",
2331
"@storybook/addon-interactions": "^6.5.9",
2432
"@storybook/addon-links": "^6.5.9",
33+
"@storybook/addon-postcss": "^3.0.0-alpha.1",
2534
"@storybook/builder-webpack5": "^6.5.9",
2635
"@storybook/manager-webpack5": "^6.5.9",
2736
"@storybook/react": "^6.5.9",
2837
"@storybook/testing-library": "^0.0.13",
38+
"autoprefixer": "^10.4.7",
2939
"babel-loader": "^8.2.5",
30-
"config": "*"
40+
"config": "*",
41+
"postcss": "^8.4.14",
42+
"tailwindcss": "^3.1.6"
3143
},
3244
"dependencies": {
3345
"react": "^18.2.0",
3446
"react-dom": "^18.2.0"
35-
},
36-
"scripts": {
37-
"storybook": "start-storybook -p 6006",
38-
"build-storybook": "build-storybook"
3947
}
4048
}

packages/viz/postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
};

packages/viz/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './renderers/Array1D';
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
export default function Array1D() {
2-
return <div>Array 1D</div>;
1+
import { Array1DAction } from '@ts-collection/protocol';
2+
3+
type Props = {
4+
initial: number[];
5+
actions: Array1DAction[];
6+
};
7+
8+
export default function Array1D(props: Props) {
9+
const { initial, actions } = props;
10+
return (
11+
<div className="flex">
12+
{initial.map((value, index) => {
13+
return <div key={index}>{value}</div>;
14+
})}
15+
</div>
16+
);
317
}

packages/viz/src/stories/Array1D.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export default {
88
},
99
};
1010

11-
const Template = () => <Array1D />;
11+
const Template = () => <Array1D initial={[1, 2, 3, 4]} actions={[]} />;
1212

1313
export const LoggedOut = Template.bind({});

packages/viz/src/styles.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

packages/viz/tailwind.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
content: [`src/**/*.{js,ts,jsx,tsx}`],
4+
theme: {
5+
extend: {},
6+
},
7+
plugins: [],
8+
};

0 commit comments

Comments
 (0)