File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change
1
+
1
2
# react-loading-ui
2
3
React loaing component.
3
4
@@ -23,6 +24,7 @@ $ npm install react-loading-ui
23
24
- To use, just call the ```` Loading() ```` function.
24
25
25
26
> Note: The ```` Loading() ```` function ** toggle** between ** hide** and ** show** .
27
+ > But instead of ** toggling** , you can also use ```` ShowLoading() ```` and ```` HideLoading() ````
26
28
27
29
``` jsx
28
30
import React , { Component } from ' react' ;
@@ -84,17 +86,21 @@ SetDefault({
84
86
```
85
87
##### Loading
86
88
87
- ```` Loading() ```` preview with light color theme.
89
+ ```` Loading() ```` and ``` ShowLoading() ``` preview with light color theme.
88
90
89
91
![ Loading()] ( http://barisates.com/git/rlui/loading.jpg " Loading ")
90
92
91
93
##### Progress
92
- ``` Loading({ progress: true }) ``` preview with light color theme.
94
+ ``` Loading({ progress: true }) ``` and ``` ShowLoading({ progress: true }) ``` preview with light color theme.
93
95
94
96
With the ``` Progress(progress) ``` function you can ensure the loading progress, see the [ demo] ( https://codesandbox.io/s/react-loading-ui-khrt7 " demo ") .
95
97
96
98
![ Porgress] ( http://barisates.com/git/rlui/progress.jpg " Porgress ")
97
99
100
+ ##### Hide Loading
101
+ If you want to force hiding, you can use ``` HideLoading() ``` function.
102
+
103
+
98
104
##### CSS Overrides
99
105
100
106
If you want to customize the styles, you can use the following classNames:
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ const Element = {
32
32
} ,
33
33
Remove : ( ) => {
34
34
const div = document . getElementById ( 'loading-ui' )
35
-
35
+
36
36
unmountComponentAtNode ( div )
37
37
div . parentNode . removeChild ( div )
38
38
}
@@ -133,6 +133,27 @@ export function Loading(props) {
133
133
}
134
134
}
135
135
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
+ }
136
157
137
158
/**
138
159
* @param {number } progress
Original file line number Diff line number Diff line change 1
- import { Loading } from './index' ;
1
+ import { Loading , HideLoading , ShowLoading } from './index' ;
2
2
3
3
it ( 'renders without crashing' , ( ) => {
4
4
Loading ( ) ;
5
5
Loading ( { progress : true } ) ;
6
6
} ) ;
7
+
8
+ it ( 'renders without crashing' , ( ) => {
9
+ HideLoading ( ) ;
10
+ ShowLoading ( { progress : true } ) ;
11
+ ShowLoading ( ) ;
12
+ HideLoading ( ) ;
13
+ } ) ;
You can’t perform that action at this time.
0 commit comments