Skip to content
This repository was archived by the owner on Aug 3, 2020. It is now read-only.

Commit 5957ea4

Browse files
hacknugjoshmanders
authored andcommitted
Add size and border options (#5)
1 parent 84af769 commit 5957ea4

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
lib/
2+
.DS_STORE
3+
node_modules

readme.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ To get started using the plugin, you can require it into your Tailwind CSS confi
1515

1616
```js
1717
plugins: [
18-
// Other plugins...
19-
18+
// Other plugins…
2019
require('tailwindcss-spinner')(),
2120
],
2221
```
@@ -27,11 +26,12 @@ If you want to customize the spinner, you can pass any combination of the follow
2726

2827
```js
2928
plugins: [
30-
// Other plugins...
31-
29+
// Other plugins…
3230
require('tailwindcss-spinner')({
3331
name: 'spinner', // change class name
3432
color: 'grey-light', // color from config to make it
33+
size: '1em', // size of the spinner (used for both width and height)
34+
border: '2px', // border-width of the spinner (shouldn't be bigger than half the spinner's size)
3535
}),
3636
],
3737
```

src/index.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
export default ({name = 'spinner', color = 'grey-light'} = {}) => ({addUtilities, config}) => addUtilities({
1+
export default ({
2+
name = 'spinner',
3+
color = '#dae1e7',
4+
size = '1em',
5+
border = '2px',
6+
} = {}) => ({
7+
addUtilities,
8+
config
9+
}) => addUtilities({
210
[`.${name}`]: {
311
'color': 'transparent !important',
412
'pointer-events': 'none',
513
'position': 'relative',
614
'&:after': {
715
'animation': 'spinAround 500ms infinite linear',
8-
'border': `2px solid ${config(`colors.${color}`)}`,
16+
'border': `${border} solid ${color}`,
917
'border-radius': '290486px',
1018
'border-right-color': 'transparent',
1119
'border-top-color': 'transparent',
1220
'content': '""',
1321
'display': 'block',
14-
'width': '1em',
15-
'height': '1em',
16-
'left': 'calc(50% - (1em / 2))',
17-
'top': 'calc(50% - (1em / 2))',
22+
'width': size,
23+
'height': size,
24+
'left': `calc(50% - (${size} / 2))`,
25+
'top': `calc(50% - (${size} / 2))`,
1826
'position': 'absolute !important',
1927
},
2028
},

0 commit comments

Comments
 (0)