Skip to content

Commit ca628bf

Browse files
authored
docs(development): migrate to storybook (danilowoz#171)
* docs(dev mode): migrate to storybook * style(codebase): update eslint rules * build(dev dependencies): update
1 parent cc64259 commit ca628bf

32 files changed

+11992
-8368
lines changed

.eslintrc.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
2-
"extends": "react-app",
2+
"extends": "@significa/eslint-config",
3+
"plugins": ["jest"],
34
"rules": {
4-
"@typescript-eslint/no-angle-bracket-type-assertion": 0 // I don't know wtf it is
5+
"@typescript-eslint/interface-name-prefix": "off",
6+
"@typescript-eslint/ban-ts-ignore": "off"
7+
},
8+
"env": {
9+
"jest": true
510
}
611
}

.prettierrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.prettierrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("@significa/prettier-config");

.storybook/addons.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@storybook/addon-notes/register'
2+
import '@storybook/addon-notes/register-panel'

.storybook/config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react'
2+
import { configure, addParameters, addDecorator } from '@storybook/react'
3+
import { themes } from '@storybook/theming'
4+
5+
addParameters({ options: { theme: themes.normal } })
6+
7+
addDecorator(storyFn => (
8+
<div style={{ maxWidth: '400px', margin: 'auto', fontFamily: 'sans-serif' }}>
9+
{storyFn()}
10+
</div>
11+
))
12+
13+
configure(require.context('../docs', true, /\.stories\.(mdx|[tj]sx?)$/), module)

.storybook/webpack.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = ({ config }) => {
2+
config.module.rules.push({
3+
test: /\.(ts|tsx)$/,
4+
use: [
5+
{
6+
loader: require.resolve('awesome-typescript-loader'),
7+
options: {
8+
reportFiles: ['src/**/*.{ts,tsx}', 'docs/**/*.{ts,tsx}'],
9+
},
10+
},
11+
],
12+
})
13+
14+
config.resolve.extensions.push('.ts', '.tsx')
15+
16+
config.module.rules[0].use[0].options.presets = [
17+
require.resolve('@babel/preset-react'),
18+
require.resolve('@babel/preset-env'),
19+
]
20+
config.resolve.mainFields = ['browser', 'module', 'main']
21+
22+
return config
23+
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ Defaults to `#f3f3f3` which is used as background of animation.
166166

167167
#### **`secondaryColor?: string`**
168168

169-
Defaults to `#ecebeb` which is used as the placeholder/layer of animation.
169+
Defaults to `#ecebeb` which is used as the foreground of animation.
170170

171-
#### **`primaryOpacity?: string`** - _Web only_
171+
#### **`primaryOpacity?: number`** - _Web only_
172172

173173
Defaults to `1`. Background opacity (0 = transparent, 1 = opaque) used to solve a issue in [Safari](#safari--ios)
174174

175-
#### **`secondaryOpacity?: string`** - _Web only_
175+
#### **`secondaryOpacity?: number`** - _Web only_
176176

177177
Defaults to `1`. Animation opacity (0 = transparent, 1 = opaque) used to solve a issue in [Safari](#safari--ios)
178178

__mocks__/jestSetupFile.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

docs/index.stories.tsx

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
import React from 'react'
2+
3+
import { Facebook, Instagram } from '../src'
4+
5+
export default {
6+
title: 'React Content Loader',
7+
}
8+
9+
/**
10+
* Animated
11+
*/
12+
export const animate = () => {
13+
return <Facebook animate={false} />
14+
}
15+
16+
animate.story = {
17+
parameters: {
18+
notes: `##\`animate?: boolean\`
19+
20+
Defaults to \`true\`. Opt-out of animations with \`false\``,
21+
},
22+
}
23+
24+
/**
25+
* Aria label
26+
*/
27+
export const ariaLabel = () => {
28+
return <Facebook ariaLabel="my custom loader" />
29+
}
30+
31+
ariaLabel.story = {
32+
parameters: {
33+
notes: `## \`ariaLabel? string | boolean\`
34+
35+
Defaults to \`Loading interface...\`. It's used to describe what element it is. Use \`false\` to remove.
36+
`,
37+
},
38+
}
39+
40+
/**
41+
* Base URL
42+
*/
43+
export const baseURL = () => {
44+
return <Facebook baseUrl="path/" />
45+
}
46+
47+
baseURL.story = {
48+
parameters: {
49+
notes: `## \`baseUrl? string\`
50+
51+
Required if you're using \`<base url="/" />\` in the \`<head/>\`. Defaults to an empty string. This prop is common used as: \`<ContentLoader baseUrl={window.location.pathname} />\` which will fill the SVG attribute with the relative path. Related [#93](https://github.com/danilowoz/react-content-loader/issues/93).
52+
`,
53+
},
54+
}
55+
56+
/**
57+
* Speed
58+
*/
59+
export const speed = () => {
60+
return (
61+
<>
62+
<Facebook speed={4} />
63+
<Facebook speed={1} />
64+
</>
65+
)
66+
}
67+
68+
speed.story = {
69+
parameters: {
70+
notes: `## \`speed?: number\`
71+
72+
Defaults to \`2\`. Animation speed in seconds.`,
73+
},
74+
}
75+
76+
/**
77+
* Interval
78+
*/
79+
export const interval = () => {
80+
return <Facebook interval={0.8} />
81+
}
82+
83+
interval.story = {
84+
parameters: {
85+
notes: `## \`interval?: number\`
86+
87+
Defaults to \`0.25\`. Interval of time between runs of the animation, as a fraction of the animation speed.`,
88+
},
89+
}
90+
91+
/**
92+
* Width
93+
*/
94+
export const width = () => {
95+
return <Facebook width={200} />
96+
}
97+
98+
width.story = {
99+
parameters: {
100+
notes: `## \`width? number\`
101+
102+
Defaults to \`400\`. It will be set in the viewbox attr in the \`<svg />\`.`,
103+
},
104+
}
105+
106+
/**
107+
* Height
108+
*/
109+
export const height = () => {
110+
return <Facebook height={50} />
111+
}
112+
113+
height.story = {
114+
parameters: {
115+
notes: `## \`height? number\`
116+
117+
Defaults to \`130\`. It will be set in the viewbox attr in the \`<svg />\`.`,
118+
},
119+
}
120+
121+
/**
122+
* Gradient Ratio
123+
*/
124+
export const gradientRatio = () => {
125+
return (
126+
<>
127+
<Instagram
128+
gradientRatio={0.2}
129+
primaryColor={'#333'}
130+
secondaryColor={'#999'}
131+
/>
132+
<Instagram
133+
gradientRatio={4}
134+
primaryColor={'#333'}
135+
secondaryColor={'#999'}
136+
/>
137+
</>
138+
)
139+
}
140+
141+
gradientRatio.story = {
142+
parameters: {
143+
notes: `## \`gradientRatio? number\`
144+
145+
Defaults to \`2\`. Width of the animated gradient as a fraction of the viewbox width.`,
146+
},
147+
}
148+
149+
/**
150+
* RTL
151+
*/
152+
export const RTL = () => {
153+
return <Instagram rtl />
154+
}
155+
156+
RTL.story = {
157+
parameters: {
158+
notes: `## \`rtl? boolean\`
159+
160+
Defaults to \`false\`. Content right-to-left.`,
161+
},
162+
}
163+
164+
/**
165+
* Primary color
166+
*/
167+
export const primaryColor = () => {
168+
return <Facebook primaryColor="#333" />
169+
}
170+
171+
primaryColor.story = {
172+
parameters: {
173+
notes: `## \`primaryColor?: string\`
174+
175+
Defaults to \`#f3f3f3\` which is used as background of animation.`,
176+
},
177+
}
178+
179+
/**
180+
* Secondary color
181+
*/
182+
export const secondaryColor = () => {
183+
return <Facebook secondaryColor="#333" />
184+
}
185+
186+
secondaryColor.story = {
187+
parameters: {
188+
notes: `## \`secondaryColor?: string\`
189+
190+
Defaults to \`#ecebeb\` which is used as foreground of animation.`,
191+
},
192+
}
193+
194+
/**
195+
* Primary opacity
196+
*/
197+
export const primaryOpacity = () => {
198+
return <Facebook primaryOpacity={0.06} />
199+
}
200+
201+
primaryOpacity.story = {
202+
parameters: {
203+
notes: `## \`primaryOpacity?: number\`
204+
205+
Defaults to \`1\`. Background opacity (0 = transparent, 1 = opaque) used to solve a issue in [Safari](#bugfix-in-safari)`,
206+
},
207+
}
208+
209+
/**
210+
* Secondary opacity
211+
*/
212+
export const secondaryOpacity = () => {
213+
return <Facebook secondaryOpacity={0.06} />
214+
}
215+
216+
secondaryOpacity.story = {
217+
parameters: {
218+
notes: `## \`secondaryOpacity?: number\`
219+
220+
Defaults to \`1\`. Animation opacity (0 = transparent, 1 = opaque) used to solve a issue in [Safari](#bugfix-in-safari)`,
221+
},
222+
}
223+
224+
/**
225+
* Unique key
226+
*/
227+
export const uniqueKey = () => {
228+
return <Facebook uniquekey="my-uniqye-key" />
229+
}
230+
231+
uniqueKey.story = {
232+
parameters: {
233+
notes: `## \`uniquekey?: string\`
234+
235+
Defaults to random unique id. Use the same value of prop key, that will solve inconsistency on the SSR, see more [here](https://github.com/danilowoz/react-content-loader/issues/78).`,
236+
},
237+
}
238+
239+
/**
240+
* View box
241+
*/
242+
// export const viewBox = () => {
243+
// return <Facebook viewBox="" />
244+
// }
245+
246+
// viewBox.story = {
247+
// parameters: {
248+
// notes: `## \`viewBox?: string\`
249+
250+
// Use viewbox props to set viewbox value.
251+
// Additionally, pass viewBox props as empty string to remove viewBox.`,
252+
// },
253+
// }

0 commit comments

Comments
 (0)