Skip to content

Commit eb30bc3

Browse files
authored
Merge pull request #4 from Sametyzc/master
show and hide functions
2 parents 323fb26 + f1d12b3 commit eb30bc3

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# react-loading-ui
23
React loaing component.
34

@@ -23,6 +24,7 @@ $ npm install react-loading-ui
2324
- To use, just call the ````Loading()```` function.
2425

2526
> Note: The ````Loading()```` function **toggle** between **hide** and **show**.
27+
> But instead of **toggling**, you can also use ````ShowLoading()```` and ````HideLoading()````
2628
2729
```jsx
2830
import React, { Component } from 'react';
@@ -84,17 +86,21 @@ SetDefault({
8486
```
8587
##### Loading
8688

87-
````Loading()```` preview with light color theme.
89+
````Loading()```` and ```ShowLoading()``` preview with light color theme.
8890

8991
![Loading()](http://barisates.com/git/rlui/loading.jpg "Loading")
9092

9193
##### Progress
92-
```Loading({ progress: true })``` preview with light color theme.
94+
```Loading({ progress: true })``` and ```ShowLoading({ progress: true })``` preview with light color theme.
9395

9496
With the ```Progress(progress)``` function you can ensure the loading progress, see the [demo](https://codesandbox.io/s/react-loading-ui-khrt7 "demo").
9597

9698
![Porgress](http://barisates.com/git/rlui/progress.jpg "Porgress")
9799

100+
##### Hide Loading
101+
If you want to force hiding, you can use ```HideLoading()``` function.
102+
103+
98104
##### CSS Overrides
99105

100106
If you want to customize the styles, you can use the following classNames:

src/index.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const Element = {
3232
},
3333
Remove: () => {
3434
const div = document.getElementById('loading-ui')
35-
35+
3636
unmountComponentAtNode(div)
3737
div.parentNode.removeChild(div)
3838
}
@@ -133,6 +133,27 @@ export function Loading(props) {
133133
}
134134
}
135135

136+
/**
137+
* @param {object} props
138+
* @param {string} [props.title]
139+
* @param {string} [props.text]
140+
* @param {bool} [props.progress]
141+
* @param {boolean} [props.progressedClose]
142+
* @param {string} [props.theme]
143+
* @param {bool} [props.topBar]
144+
* @param {string} [props.topBarColor]
145+
*/
146+
export function ShowLoading(props) {
147+
if (!document.getElementById('loading-ui')) {
148+
Loading(props);
149+
}
150+
}
151+
152+
export function HideLoading() {
153+
if (document.getElementById('loading-ui')) {
154+
Loading();
155+
}
156+
}
136157

137158
/**
138159
* @param {number} progress

src/index.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import {Loading} from './index';
1+
import {Loading, HideLoading, ShowLoading} from './index';
22

33
it('renders without crashing', () => {
44
Loading();
55
Loading({progress: true});
66
});
7+
8+
it('renders without crashing', () => {
9+
HideLoading();
10+
ShowLoading({progress: true});
11+
ShowLoading();
12+
HideLoading();
13+
});

0 commit comments

Comments
 (0)