Skip to content

Commit 45c2150

Browse files
committed
added rollup-plugin-string and react as peerdep
1 parent efac488 commit 45c2150

13 files changed

+241
-25
lines changed

package-lock.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,16 @@
5454
"rimraf": "^3.0.2",
5555
"rollup": "^2.22.2",
5656
"rollup-plugin-node-resolve": "^5.2.0",
57+
"rollup-plugin-string": "^3.0.0",
5758
"rollup-plugin-terser": "^6.1.0"
5859
},
5960
"dependencies": {
6061
"prettier": "^2.0.5"
62+
},
63+
"peerDependencies": {
64+
"react": ">=16.2"
65+
},
66+
"engines": {
67+
"node": ">=8"
6168
}
62-
}
69+
}

rollup.config.js

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
11
import babel from '@rollup/plugin-babel'
22
import resolve from 'rollup-plugin-node-resolve'
33
import { terser } from 'rollup-plugin-terser'
4+
import { string } from 'rollup-plugin-string'
45

56
const dist = 'dist'
67
const bundle = 'bundle'
78
const production = !process.env.ROLLUP_WATCH
89

9-
export default {
10+
const outputs = [
11+
{
12+
file: `${dist}/${bundle}.cjs.js`,
13+
format: 'cjs',
14+
},
15+
{
16+
file: `${dist}/${bundle}.esm.js`,
17+
format: 'esm',
18+
},
19+
{
20+
name: 'ReactSpinnerCSS',
21+
file: `${dist}/${bundle}.umd.js`,
22+
globals: {
23+
react: 'React',
24+
},
25+
format: 'umd',
26+
},
27+
]
28+
const common = {
1029
input: 'src/index.js',
1130
external: ['react'],
12-
output: [
13-
{
14-
file: `${dist}/${bundle}.cjs.js`,
15-
format: 'cjs',
16-
},
17-
{
18-
file: `${dist}/${bundle}.esm.js`,
19-
format: 'esm',
20-
},
21-
{
22-
name: 'ReactSpinnerCSS',
23-
file: `${dist}/${bundle}.umd.js`,
24-
globals: {
25-
react: 'React',
26-
},
27-
format: 'umd',
28-
},
29-
],
3031
plugins: [
3132
resolve(),
3233
babel({
3334
exclude: 'node_modules/**',
3435
}),
36+
string({
37+
include: '**/*.css',
38+
}),
3539
production && terser(),
3640
],
3741
}
42+
export default outputs.map((output) => ({
43+
...common,
44+
output,
45+
}))

src/Components/Loader1/Loader.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react'
2+
import styles from './style.css'
3+
const Loader1 = (props) => (
4+
<>
5+
<style>{styles}</style>
6+
<div className="loader-div one">
7+
<div className="loader1"></div>
8+
</div>
9+
</>
10+
)
11+
12+
export default Loader1

src/Components/Loader1/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Loader1 } from './Loader'

src/Components/Loader1/style.css

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
* {
2+
padding: 0px;
3+
margin: 0px;
4+
box-sizing: border-box;
5+
}
6+
7+
.loader-div {
8+
display: flex;
9+
flex-direction: column;
10+
justify-content: center;
11+
align-items: center;
12+
height: 300px;
13+
width: 380px;
14+
margin: 8px;
15+
border-radius: 4px;
16+
}
17+
.loader-div.one {
18+
background-color: lightyellow;
19+
}
20+
21+
.loader1 {
22+
width: 90px;
23+
height: 90px;
24+
border-top: 4px solid blue;
25+
border-radius: 100%;
26+
animation: spin 2s linear infinite;
27+
}
28+
29+
@keyframes spin {
30+
0% {
31+
transform: rotate(0deg);
32+
}
33+
100% {
34+
transform: rotate(360deg);
35+
}
36+
}

src/Components/Loader2/Loader.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react'
2+
import styles from './style.css'
3+
4+
const Loader2 = (props) => (
5+
<>
6+
<style>{styles}</style>
7+
<div className="loader-div two">
8+
<div className="loader2">
9+
<div className="loader-ring">
10+
<div></div>
11+
<div></div>
12+
<div></div>
13+
<div></div>
14+
</div>
15+
</div>
16+
</div>
17+
</>
18+
)
19+
20+
export default Loader2

src/Components/Loader2/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Loader2 } from './Loader'

src/Components/Loader2/style.css

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
* {
2+
padding: 0px;
3+
margin: 0px;
4+
box-sizing: border-box;
5+
}
6+
7+
.loader-div {
8+
display: flex;
9+
flex-direction: column;
10+
justify-content: center;
11+
align-items: center;
12+
height: 300px;
13+
width: 380px;
14+
margin: 8px;
15+
border-radius: 4px;
16+
}
17+
.loader-div.two {
18+
background-color: lightgreen;
19+
}
20+
21+
.loader2 {
22+
width: 100px;
23+
height: 100px;
24+
}
25+
26+
.loader2 .loader-ring {
27+
display: inline-block;
28+
position: relative;
29+
width: 95px;
30+
height: 95px;
31+
}
32+
33+
.loader2 .loader-ring div {
34+
display: block;
35+
position: absolute;
36+
width: 90px;
37+
height: 90px;
38+
border: 6px solid black;
39+
border-radius: 50%;
40+
border-color: white transparent transparent transparent;
41+
animation: spin 2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
42+
}
43+
44+
@keyframes spin {
45+
0% {
46+
transform: rotate(0deg);
47+
}
48+
100% {
49+
transform: rotate(360deg);
50+
}
51+
}

src/Components/Loader3/Loader.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react'
2+
import styles from './style.css'
3+
const Loader3 = (props) => (
4+
<>
5+
<styles>{styles}</styles>
6+
<div className="loader3">
7+
<div className="loader-ring">
8+
<div></div>
9+
<div></div>
10+
<div></div>
11+
<div></div>
12+
</div>
13+
</div>
14+
</>
15+
)
16+
17+
export default Loader3

src/Components/Loader3/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Loader3 } from './Loader'

src/Components/Loader3/style.css

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
* {
2+
padding: 0px;
3+
margin: 0px;
4+
box-sizing: border-box;
5+
}
6+
7+
.loader-div {
8+
display: flex;
9+
flex-direction: column;
10+
justify-content: center;
11+
align-items: center;
12+
height: 300px;
13+
width: 380px;
14+
margin: 8px;
15+
border-radius: 4px;
16+
}
17+
18+
.loader-div.three {
19+
background-color: orange;
20+
}
21+
22+
.loader3 {
23+
width: 100px;
24+
height: 100px;
25+
}
26+
27+
.loader3 .loader-ring {
28+
display: inline-block;
29+
position: relative;
30+
width: 95px;
31+
height: 95px;
32+
}
33+
34+
.loader3 .loader-ring div {
35+
display: block;
36+
position: absolute;
37+
width: 90px;
38+
height: 90px;
39+
border: 6px solid black;
40+
border-radius: 50%;
41+
border-color: white transparent transparent transparent;
42+
animation: spin 2s cubic-bezier(0.4, 0, 1, 1) infinite;
43+
}
44+
.loader3 .loader-ring div:nth-child(2) {
45+
animation-delay: -1s;
46+
}
47+
48+
@keyframes spin {
49+
0% {
50+
transform: rotate(0deg);
51+
}
52+
100% {
53+
transform: rotate(360deg);
54+
}
55+
}

src/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react'
2-
3-
const Spinner = (props) => <h1>Spinners</h1>
4-
5-
export default Spinner
1+
export * from './Components/Loader1'
2+
export * from './Components/Loader2'
3+
export * from './Components/Loader3'

0 commit comments

Comments
 (0)