@platformatic/ui-components 0.19.2 → 0.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Button.jsx +3 -2
- package/src/components/Button.module.css +1 -1
- package/src/components/LoadingSpinner.jsx +2 -2
- package/src/components/loaders/SpinnerCircularV2.jsx +31 -0
- package/src/components/loaders/SpinnerCircularV2.module.css +34 -0
- package/src/stories/Button.stories.jsx +20 -1
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
ACTIVE_AND_INACTIVE_STATUS,
|
|
13
13
|
TRANSPARENT
|
|
14
14
|
} from './constants'
|
|
15
|
-
import
|
|
15
|
+
import SpinnerCircularV2 from './loaders/SpinnerCircularV2'
|
|
16
16
|
|
|
17
17
|
function Button ({
|
|
18
18
|
textClass = '',
|
|
@@ -111,7 +111,8 @@ function Button ({
|
|
|
111
111
|
return (
|
|
112
112
|
<button className={`${buttonClassName} ${restClassName()} ${borderedClassName}`} disabled={disabled} alt={label} {...rest} onMouseLeave={() => setHover(false)} onMouseOver={() => setHover(true)}>
|
|
113
113
|
<div className={`${contentClassName} ${backgroundClassName}`}>
|
|
114
|
-
{loading ? <
|
|
114
|
+
{loading ? <SpinnerCircularV2 className={styles.spinner} size={28} thickness={1} color={color} /> : null}
|
|
115
|
+
|
|
115
116
|
{platformaticIcon ? <PlatformaticIcon key='left' iconName={platformaticIcon.iconName} color={platformaticIcon.color} data-testid='button-icon' onClick={null} inactive={inactive} /> : null}
|
|
116
117
|
<span className={styles.label}>{label}</span>
|
|
117
118
|
{platformaticIconAfter ? <PlatformaticIcon key='right' iconName={platformaticIconAfter.iconName} color={platformaticIconAfter.color} data-testid='button-icon' onClick={null} inactive={inactive} /> : null}
|
|
@@ -2,13 +2,13 @@ import React from 'react'
|
|
|
2
2
|
import styles from './LoadingSpinner.module.css'
|
|
3
3
|
import SpinnerCircular from './loaders/SpinnerCircular'
|
|
4
4
|
|
|
5
|
-
function LoadingSpinner ({ loading = false }) {
|
|
5
|
+
function LoadingSpinner ({ loading = false, size = 60 }) {
|
|
6
6
|
// If null then loading not started, if true then loading, if false then done loading
|
|
7
7
|
return loading
|
|
8
8
|
? (
|
|
9
9
|
<div className={styles.container} data-testid='loading-spinner'>
|
|
10
10
|
<div data-testid='loading-spinner-content' className={styles.relative}>
|
|
11
|
-
<SpinnerCircular className={styles.spinner} size={
|
|
11
|
+
<SpinnerCircular className={styles.spinner} size={size} />
|
|
12
12
|
</div>
|
|
13
13
|
</div>
|
|
14
14
|
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// https://loading.io/css/
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import styles from './SpinnerCircularV2.module.css'
|
|
4
|
+
import { WHITE } from '../constants'
|
|
5
|
+
|
|
6
|
+
function SpinnerCircular ({
|
|
7
|
+
className = '',
|
|
8
|
+
color = WHITE,
|
|
9
|
+
size = 60,
|
|
10
|
+
thickness = 4
|
|
11
|
+
}) {
|
|
12
|
+
const styleRing = { width: `${size / 4}px`, height: `${size / 4}px` }
|
|
13
|
+
const styleDiv = {
|
|
14
|
+
width: `${size - 16}px`,
|
|
15
|
+
height: `${size - 16}px`,
|
|
16
|
+
margin: `${thickness}px`,
|
|
17
|
+
borderWidth: `${thickness}px`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const spinnerClassName = styles[`ring${color}`] + ` ${styles.ring} ${className}`
|
|
21
|
+
return (
|
|
22
|
+
<div className={spinnerClassName} style={styleRing}>
|
|
23
|
+
<div style={styleDiv} />
|
|
24
|
+
<div style={styleDiv} />
|
|
25
|
+
<div style={styleDiv} />
|
|
26
|
+
<div style={styleDiv} />
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default SpinnerCircular
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.ringwhite {
|
|
2
|
+
color: white;
|
|
3
|
+
}
|
|
4
|
+
.ring,
|
|
5
|
+
.ring div {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
.ring div {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
display: block;
|
|
11
|
+
position: absolute;
|
|
12
|
+
border-style: solid;
|
|
13
|
+
border-color: currentColor;
|
|
14
|
+
border-radius: 50%;
|
|
15
|
+
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
|
16
|
+
border-color: currentColor transparent transparent transparent;
|
|
17
|
+
}
|
|
18
|
+
.ring div:nth-child(1) {
|
|
19
|
+
animation-delay: -0.45s;
|
|
20
|
+
}
|
|
21
|
+
.ring div:nth-child(2) {
|
|
22
|
+
animation-delay: -0.3s;
|
|
23
|
+
}
|
|
24
|
+
.ring div:nth-child(3) {
|
|
25
|
+
animation-delay: -0.15s;
|
|
26
|
+
}
|
|
27
|
+
@keyframes lds-ring {
|
|
28
|
+
0% {
|
|
29
|
+
transform: rotate(0deg);
|
|
30
|
+
}
|
|
31
|
+
100% {
|
|
32
|
+
transform: rotate(360deg);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
2
|
import Button from '../components/Button'
|
|
3
3
|
import {
|
|
4
4
|
ALTERNATE_RICH_BLACK,
|
|
@@ -676,3 +676,22 @@ LoadingButton.args = {
|
|
|
676
676
|
label: 'Loading Button',
|
|
677
677
|
loading: true
|
|
678
678
|
}
|
|
679
|
+
|
|
680
|
+
export const ClickToLoad = (args) => {
|
|
681
|
+
const [loading, setLoading] = useState(false)
|
|
682
|
+
return (
|
|
683
|
+
<Button
|
|
684
|
+
label='Click to Load'
|
|
685
|
+
loading={loading}
|
|
686
|
+
onClick={() => {
|
|
687
|
+
setLoading(true)
|
|
688
|
+
setTimeout(() => setLoading(false), 2000)
|
|
689
|
+
}}
|
|
690
|
+
/>
|
|
691
|
+
)
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
ClickToLoad.args = {
|
|
695
|
+
label: 'Click to Load',
|
|
696
|
+
loading: false
|
|
697
|
+
}
|