Skip to content

Commit 0a492df

Browse files
Add size to Grid
1 parent cdd46ef commit 0a492df

4 files changed

Lines changed: 31 additions & 23 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Component that accepts `size` prop have a default size in pixel.
3939
| `<Ellipsis/>` | `#7f58af` | `80` | `""` | `{}` |
4040
| `<DualRing/>` | `#7f58af` | `80` | `""` | `{}` |
4141
| `<Facebook/>` | `#7f58af` | `80` | `""` | `{}` |
42-
| `<Grid/>` | `#7f58af` | - | `""` | `{}` |
42+
| `<Grid/>` | `#7f58af` | `80` | `""` | `{}` |
4343
| `<Heart/>` | `#7f58af` | `80` | `""` | `{}` |
4444
| `<Hourglass/>` | `#7f58af` | `32` | `""` | `{}` |
4545
| `<Ring/>` | `#7f58af` | `80` | `""` | `{}` |

src/components/Grid/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import './style.css'
44

5-
export default function Grid({ color, className, style }) {
5+
export default function Grid({ color, className, style, size }) {
66
const circles = [...Array(9)].map((_, index) => <div key={index} style={{ background: `${color}` }} />)
77

88
return (
9-
<div className={`lds-grid ${className}`} style={{ ...style }}>
9+
<div className={`lds-grid ${className}`} style={{ width: size, height: size, ...style }}>
1010
{circles}
1111
</div>
1212
)
@@ -15,6 +15,8 @@ export default function Grid({ color, className, style }) {
1515
Grid.propTypes = {
1616
/** hex color */
1717
color: PropTypes.string,
18+
/** size in pixel */
19+
size: PropTypes.number,
1820
/** class name */
1921
className: PropTypes.string,
2022
/** style object */
@@ -23,6 +25,7 @@ Grid.propTypes = {
2325

2426
Grid.defaultProps = {
2527
color: '#7f58af',
28+
size: 80,
2629
className: '',
2730
style: {},
2831
}

src/components/Grid/style.css

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,55 @@
66
}
77
.lds-grid div {
88
position: absolute;
9-
width: 16px;
10-
height: 16px;
9+
width: 20%;
10+
height: 20%;
1111
border-radius: 50%;
1212
background: #fff;
1313
animation: lds-grid 1.2s linear infinite;
1414
}
1515
.lds-grid div:nth-child(1) {
16-
top: 8px;
17-
left: 8px;
16+
top: 10%;
17+
left: 10%;
1818
animation-delay: 0s;
1919
}
2020
.lds-grid div:nth-child(2) {
21-
top: 8px;
22-
left: 32px;
21+
top: 10%;
22+
left: 40%;
2323
animation-delay: -0.4s;
2424
}
2525
.lds-grid div:nth-child(3) {
26-
top: 8px;
27-
left: 56px;
26+
top: 10%;
27+
left: 70%;
2828
animation-delay: -0.8s;
2929
}
3030
.lds-grid div:nth-child(4) {
31-
top: 32px;
32-
left: 8px;
31+
top: 40%;
32+
left: 10%;
3333
animation-delay: -0.4s;
3434
}
3535
.lds-grid div:nth-child(5) {
36-
top: 32px;
37-
left: 32px;
36+
top: 40%;
37+
left: 40%;
3838
animation-delay: -0.8s;
3939
}
4040
.lds-grid div:nth-child(6) {
41-
top: 32px;
42-
left: 56px;
41+
top: 40%;
42+
left: 70%;
4343
animation-delay: -1.2s;
4444
}
4545
.lds-grid div:nth-child(7) {
46-
top: 56px;
47-
left: 8px;
46+
top: 70%;
47+
left: 10%;
4848
animation-delay: -0.8s;
4949
}
5050
.lds-grid div:nth-child(8) {
51-
top: 56px;
52-
left: 32px;
51+
top: 70%;
52+
left: 40%;
5353
animation-delay: -1.2s;
5454
}
5555
.lds-grid div:nth-child(9) {
56-
top: 56px;
57-
left: 56px;
56+
top: 70%;
57+
left: 70%;
5858
animation-delay: -1.6s;
5959
}
6060
@keyframes lds-grid {

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ const SizeProp = () => {
167167
<Default color="#be97e8" size={40} />
168168
<Default color="#be97e8" size={20} />
169169
</div>
170+
<div className="block">
171+
<Grid color="#be97e8" />
172+
<Grid color="#be97e8" size={40} />
173+
<Grid color="#be97e8" size={20} />
174+
</div>
170175
<div style={{ clear: 'both' }}></div>
171176
</div>
172177
)

0 commit comments

Comments
 (0)