Skip to content

Commit 46e433b

Browse files
committed
add tailwind to storybook
1 parent dceb563 commit 46e433b

File tree

7 files changed

+478
-23
lines changed

7 files changed

+478
-23
lines changed

.storybook/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
module.exports = {
22
stories: ['../stories/**/*.stories.@(ts|tsx|js|jsx)'],
33
addons: [
4+
{
5+
name: '@storybook/addon-postcss',
6+
options: {
7+
postcssLoaderOptions: {
8+
implementation: require('postcss'),
9+
},
10+
},
11+
},
412
'@storybook/addon-links',
513
'@storybook/addon-essentials',
614
{

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"@storybook/addon-essentials": "^6.3.12",
8383
"@storybook/addon-info": "^5.3.21",
8484
"@storybook/addon-links": "^6.3.12",
85+
"@storybook/addon-postcss": "^2.0.0",
8586
"@storybook/addons": "^6.3.12",
8687
"@storybook/preset-scss": "^1.0.3",
8788
"@storybook/react": "^6.3.12",
@@ -93,6 +94,7 @@
9394
"css-loader": "^5.0.0",
9495
"husky": "^7.0.4",
9596
"np": "^7.6.0",
97+
"postcss": "^8",
9698
"react": "^17.0.2",
9799
"react-dom": "^17.0.2",
98100
"react-is": "^17.0.2",
@@ -101,6 +103,7 @@
101103
"sass-loader": "^10.1.0",
102104
"size-limit": "^6.0.4",
103105
"style-loader": "^2.0.0",
106+
"tailwindcss": "^2.2.19",
104107
"tsdx": "^0.14.1",
105108
"tslib": "^2.3.1",
106109
"typescript": "^4.4.4"

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+
};

stories/Parallax/7_ParallaxEasing.stories.tsx

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,79 @@ WithEasing.args = {
7676
easing: options[0],
7777
};
7878

79+
const Template2 = () => {
80+
const amount = 16;
81+
const offA = 0;
82+
const offB = 500;
83+
const unit = 'px';
84+
const elements = new Array(amount).fill(null).map((x, i) => i);
85+
86+
return (
87+
<ParallaxProvider>
88+
<div className="w-full p-20">
89+
{options.map((easing) => (
90+
<div
91+
className="relative flex flex-row items-center justify-between"
92+
style={{ height: '150vh' }}
93+
>
94+
<h1 className="absolute top-1/2 left-0 w-full text-center text-white text-4xl z-10">
95+
{easing}
96+
</h1>
97+
<div className="w-1/2 flex flex-col">
98+
{elements.map((_, i) => {
99+
const n = amount - i;
100+
return (
101+
<Parallax
102+
key={n}
103+
className="bg-blue-500 m-1 opacity-1 w-10 h-10"
104+
easing={easing}
105+
rootMargin={{
106+
top: 0,
107+
right: 0,
108+
bottom: 0,
109+
left: 0,
110+
}}
111+
rotate={[0, 90]}
112+
translateX={[`${offA}${unit}`, `${offB}${unit}`]}
113+
// translateX={[`${offA * n}${unit}`, `${offB * n}${unit}`]}
114+
>
115+
<div className="w-10 h-10 bg-purple-400 rounded-md" />
116+
</Parallax>
117+
);
118+
})}
119+
</div>
120+
<div className="w-1/2 flex flex-col items-end">
121+
{elements.map((_, i) => {
122+
const n = amount - i;
123+
return (
124+
<Parallax
125+
key={n}
126+
className="bg-blue-500 m-1 opacity-1 w-10 h-10"
127+
easing={easing}
128+
rootMargin={{
129+
top: 0,
130+
right: 0,
131+
bottom: 0,
132+
left: 0,
133+
}}
134+
rotate={[0, 90]}
135+
translateX={[`${-1 * offA}${unit}`, `${-1 * offB}${unit}`]}
136+
// translateX={[`${offA * n}${unit}`, `${offB * n}${unit}`]}
137+
>
138+
<div className="w-10 h-10 bg-green-400 rounded-md" />
139+
</Parallax>
140+
);
141+
})}
142+
</div>
143+
</div>
144+
))}
145+
</div>
146+
</ParallaxProvider>
147+
);
148+
};
149+
150+
export const WithAllEasing = Template2.bind({});
151+
79152
export default {
80153
title: '<Parallax> Easing',
81154
component: WithEasing,

stories/styles.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
14
@import url('https://fonts.googleapis.com/css?family=Roboto+Mono:400,700');
25

36
html {

tailwind.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
purge: ['./stories/**/*.tsx'],
3+
darkMode: false, // or 'media' or 'class'
4+
theme: {
5+
extend: {},
6+
},
7+
variants: {
8+
extend: {},
9+
},
10+
plugins: [],
11+
};

0 commit comments

Comments
 (0)