Skip to content

Commit be0334a

Browse files
committed
add size option to ring component and update readme with a nice table of component with props
1 parent 194d9d1 commit be0334a

5 files changed

Lines changed: 58 additions & 26 deletions

File tree

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,27 @@ Amazing collection of pure CSS react spinners components of css spinners for aja
1111
<a href="https://bit.dev/joshk/react-spinners-css"><img src="https://i.imagesup.co/images2/010e655fd10abc5621d067f8b8ad33c7cac7d840.gif"></a>
1212
</p>
1313

14-
## 🚀 List of components
14+
## 🚀 List of Spinners - PropTypes and Default Props
1515

16-
- `<Circle />`
17-
- `<Default />`
18-
- `<DualRing />`
19-
- `<Ellipsis />`
20-
- `<Facebook />`
21-
- `<Grid />`
22-
- `<Heart />`
23-
- `<Hourglass />`
24-
- `<Ring />`
25-
- `<Ripple />`
26-
- `<Roller />`
27-
- `<Spinner />`
16+
Each component accepts a `color` prop, and few accepts also `size` prop.
17+
The default `color` prop is `#7f58af`.
18+
Component that accepts `size` prop have a default size in pixel.
2819

29-
#### Props
20+
| Spinner | Color: string | Size: number |
21+
| ---------------- | ------------ | ------------- |
22+
| Circle Spinner | `#7f58af` | `64px` |
23+
| Default Spinner | `#7f58af` | - |
24+
| DualRing Spinner | `#7f58af` | - |
25+
| Ellipsis Spinner | `#7f58af` | - |
26+
| Facebook Spinner | `#7f58af` | - |
27+
| Grid Spinner | `#7f58af` | - |
28+
| Heart Spinner | `#7f58af` | - |
29+
| Hourglass Spinner| `#7f58af` | - |
30+
| Ring Spinner | `#7f58af` | `80px` |
31+
| Ripple Spinner | `#7f58af` | - |
32+
| Roller Spinner | `#7f58af` | - |
33+
| Spinner Spinner | `#7f58af` | - |
3034

31-
| Prop | Type | Default |
32-
| ------- | -------- | ------- |
33-
| `color` | `string` | `#7f58af` |
3435

3536
## 📦 Installation
3637
### Using [npm](https://www.npmjs.com/package/react-spinners-css) to install react-spinners-css:

src/app.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
float: left;
88
border: 1px solid #ccc;
99
border-radius: 3px;
10+
width: 240px;
11+
height: 84px;
1012
margin: 10px;
1113
padding: 10px;
1214
}

src/components/Ring/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,28 @@ import './style.css'
44

55
export default class Ring extends Component {
66
Circles = () => {
7+
const { color, size } = this.props;
78
let div = []
89
for (let index = 0; index < 4; index++) {
9-
div.push(<div key={index} style={{ borderColor: `${this.props.color} transparent transparent transparent` }}></div>)
10+
div.push(<div key={index} style={{ borderColor: `${color} transparent transparent transparent`, width: size * 0.8, height: size * 0.8, margin: size * 0.1, borderWidth: size * 0.1 }}></div>)
1011
}
1112
return div;
1213
}
1314

1415
render() {
15-
return <div className="lds-ring">{this.Circles()}</div>
16+
const { size } = this.props;
17+
return <div className="lds-ring" style={{ width: size, height: size }}>{this.Circles()}</div>
1618
}
1719
}
1820

1921
Ring.propTypes = {
2022
/** hex color */
2123
color: PropTypes.string,
24+
/** size in pixel */
25+
size: PropTypes.number,
2226
}
2327

2428
Ring.defaultProps = {
2529
color: '#7f58af',
30+
size: 80,
2631
}

src/components/Ring/style.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
.lds-ring {
22
display: inline-block;
33
position: relative;
4-
width: 80px;
5-
height: 80px;
64
}
75
.lds-ring div {
86
box-sizing: border-box;
97
display: block;
108
position: absolute;
11-
width: 64px;
12-
height: 64px;
13-
margin: 8px;
149
border: 8px solid #fff;
1510
border-radius: 50%;
1611
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;

src/index.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import {
1616
} from './components'
1717
import './app.css'
1818

19-
const App = () => {
19+
const ColorProp = () => {
2020
return (
2121
<div className="main">
22-
<h1>React Spinners</h1>
22+
<h2>Color Property</h2>
2323
<div className="block">
2424
<Circle color="black" />
2525
<Circle color="#de3541" />
@@ -85,4 +85,33 @@ const App = () => {
8585
)
8686
}
8787

88+
const SizeProp = () => {
89+
return (
90+
<div className="main">
91+
<h2>Size Property</h2>
92+
<div className="block">
93+
<Circle />
94+
<Circle size={32} />
95+
<Circle size={16} />
96+
</div>
97+
<div className="block">
98+
<Ring />
99+
<Ring size={40} />
100+
<Ring size={20} />
101+
</div>
102+
<div style={{ clear: 'both' }}></div>
103+
</div>
104+
)
105+
}
106+
107+
const App = () => {
108+
return (
109+
<div className="main">
110+
<h1>React Spinners</h1>
111+
<ColorProp />
112+
<SizeProp />
113+
</div>
114+
)
115+
}
116+
88117
ReactDOM.render(<App />, document.getElementById('root'))

0 commit comments

Comments
 (0)