@platformatic/ui-components 0.1.38 → 0.1.40
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/index.js +3 -1
- package/package.json +1 -1
- package/src/components/Button.jsx +59 -7
- package/src/components/Button.module.css +57 -29
- package/src/components/Common.module.css +2 -2
- package/src/components/Loadable.jsx +1 -1
- package/src/components/Loader.jsx +22 -0
- package/src/components/Loader.module.css +13 -0
- package/src/components/Modal.module.css +2 -2
- package/src/components/forms/Field.jsx +20 -0
- package/src/components/forms/Field.module.css +18 -0
- package/src/components/forms/Input.jsx +44 -4
- package/src/components/forms/Input.module.css +8 -2
- package/src/components/forms/Preview.jsx +15 -0
- package/src/components/forms/Preview.module.css +12 -0
- package/src/components/forms/index.js +4 -2
- package/src/components/icons/index.js +10 -1
- package/src/stories/Button.stories.jsx +25 -45
- package/src/stories/Loader.stories.jsx +44 -0
- package/src/stories/forms/Field.stories.jsx +81 -0
- package/src/stories/forms/Input.stories.jsx +1 -1
- package/src/stories/forms/Preview.stories.jsx +36 -0
- package/src/stories/forms/ToggleSwitch.stories.jsx +1 -1
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import Layout from './src/components/layouts/Layout'
|
|
|
18
18
|
import List from './src/components/List'
|
|
19
19
|
import ListElement from './src/components/ListElement'
|
|
20
20
|
import Loadable from './src/components/Loadable'
|
|
21
|
+
import Loader from './src/components/Loader'
|
|
21
22
|
import LoginButton from './src/components/LoginButton'
|
|
22
23
|
import Logo from './src/components/Logo'
|
|
23
24
|
import Modal from './src/components/Modal'
|
|
@@ -50,6 +51,7 @@ export {
|
|
|
50
51
|
List,
|
|
51
52
|
ListElement,
|
|
52
53
|
Loadable,
|
|
54
|
+
Loader,
|
|
53
55
|
LoginButton,
|
|
54
56
|
Logo,
|
|
55
57
|
Modal,
|
|
@@ -61,5 +63,5 @@ export {
|
|
|
61
63
|
TextWithLabel,
|
|
62
64
|
TwoColumnsLayout,
|
|
63
65
|
Versions,
|
|
64
|
-
VerticalSeparator
|
|
66
|
+
VerticalSeparator,
|
|
65
67
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
|
|
3
2
|
import React from 'react'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
4
|
import styles from './Button.module.css'
|
|
5
5
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
function Button (props) {
|
|
8
|
+
const { icon, label, color, backgroundColor, size, disabled, bold, underlineEffect, bordered, ...rest } = props
|
|
9
|
+
let className = `${styles.button} ${styles['background-color-' + backgroundColor]} ${styles['color-' + color]} ${styles['button-' + size]}`
|
|
10
|
+
if (!bordered) className += ` ${styles['no-border']}`
|
|
9
11
|
if (disabled) {
|
|
10
12
|
className += ` ${styles.disabled}`
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
13
|
+
} else {
|
|
14
|
+
if (underlineEffect) className += ` ${styles['underline-effect']}`
|
|
14
15
|
}
|
|
15
16
|
if (bold) className += ` ${styles.fontBold}`
|
|
16
17
|
|
|
@@ -21,3 +22,54 @@ export default function Button (props) {
|
|
|
21
22
|
</button>
|
|
22
23
|
)
|
|
23
24
|
}
|
|
25
|
+
|
|
26
|
+
Button.propTypes = {
|
|
27
|
+
/**
|
|
28
|
+
* Icon
|
|
29
|
+
*/
|
|
30
|
+
icon: PropTypes.object,
|
|
31
|
+
/**
|
|
32
|
+
* label
|
|
33
|
+
*/
|
|
34
|
+
label: PropTypes.string,
|
|
35
|
+
/**
|
|
36
|
+
* color of text, icon and borders
|
|
37
|
+
*/
|
|
38
|
+
color: PropTypes.oneOf(['main-green', 'dark-green', 'light-green', 'main-dark-blue', 'dark-blue', 'light-blue', 'white', 'error-red', 'tertiary-blue', 'transparent']),
|
|
39
|
+
/**
|
|
40
|
+
* background color of the button
|
|
41
|
+
*/
|
|
42
|
+
backgroundColor: PropTypes.oneOf(['main-green', 'dark-green', 'light-green', 'main-dark-blue', 'dark-blue', 'light-blue', 'white', 'error-red', 'tertiary-blue', 'transparent']),
|
|
43
|
+
/**
|
|
44
|
+
* Size
|
|
45
|
+
*/
|
|
46
|
+
size: PropTypes.oneOf(['small', 'medium', 'large', 'extra-large']),
|
|
47
|
+
/**
|
|
48
|
+
* Disabled
|
|
49
|
+
*/
|
|
50
|
+
disabled: PropTypes.bool,
|
|
51
|
+
/**
|
|
52
|
+
* Bold
|
|
53
|
+
*/
|
|
54
|
+
bold: PropTypes.bool,
|
|
55
|
+
/**
|
|
56
|
+
* Underline effect on hover
|
|
57
|
+
*/
|
|
58
|
+
underlineEffect: PropTypes.bool,
|
|
59
|
+
/**
|
|
60
|
+
* Apply border: default true
|
|
61
|
+
*/
|
|
62
|
+
bordered: PropTypes.bool
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Button.defaultProps = {
|
|
66
|
+
color: 'main-dark-blue',
|
|
67
|
+
backgroundColor: 'transparent',
|
|
68
|
+
disabled: false,
|
|
69
|
+
size: 'large',
|
|
70
|
+
bold: false,
|
|
71
|
+
underlineEffect: false,
|
|
72
|
+
bordered: true
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default Button
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.button {
|
|
2
|
-
@apply rounded text-center cursor-pointer font-normal;
|
|
2
|
+
@apply rounded text-center cursor-pointer font-normal rounded-md border border-solid box-border;
|
|
3
3
|
}
|
|
4
4
|
.fontBold {
|
|
5
5
|
@apply font-semibold;
|
|
@@ -27,44 +27,72 @@
|
|
|
27
27
|
.margin-right-extra-large {
|
|
28
28
|
@apply mr-3;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@apply text-main-dark-blue bg-light-green;
|
|
30
|
+
.background-color-main-green {
|
|
31
|
+
@apply bg-main-green !important;
|
|
33
32
|
}
|
|
34
|
-
.
|
|
35
|
-
@apply
|
|
33
|
+
.background-color-light-green {
|
|
34
|
+
@apply bg-light-green !important;
|
|
36
35
|
}
|
|
37
|
-
.
|
|
38
|
-
@apply
|
|
36
|
+
.background-color-dark-green {
|
|
37
|
+
@apply bg-dark-green !important;
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@apply text-main-dark-blue bg-error-red;
|
|
39
|
+
.background-color-main-dark-blue{
|
|
40
|
+
@apply bg-main-dark-blue !important;
|
|
43
41
|
}
|
|
44
|
-
.
|
|
45
|
-
@apply
|
|
42
|
+
.background-color-dark-blue{
|
|
43
|
+
@apply bg-dark-blue !important;
|
|
46
44
|
}
|
|
47
|
-
.
|
|
48
|
-
@apply
|
|
45
|
+
.background-color-light-blue{
|
|
46
|
+
@apply bg-light-blue !important;
|
|
49
47
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
@apply text-main-dark-blue bg-white;
|
|
48
|
+
.background-color-white{
|
|
49
|
+
@apply bg-white !important;
|
|
53
50
|
}
|
|
54
|
-
.
|
|
55
|
-
@apply
|
|
51
|
+
.background-color-error-red{
|
|
52
|
+
@apply bg-error-red !important;
|
|
56
53
|
}
|
|
57
|
-
.
|
|
58
|
-
@apply
|
|
54
|
+
.background-color-tertiary-blue{
|
|
55
|
+
@apply bg-tertiary-blue !important;
|
|
59
56
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
.background-color-transparent{
|
|
58
|
+
@apply bg-transparent;
|
|
59
|
+
}
|
|
60
|
+
.color-main-green {
|
|
61
|
+
@apply text-main-green border-main-green;
|
|
62
|
+
}
|
|
63
|
+
.color-light-green {
|
|
64
|
+
@apply text-light-green border-light-green;
|
|
65
|
+
}
|
|
66
|
+
.color-dark-green {
|
|
67
|
+
@apply text-dark-green border-dark-green;
|
|
68
|
+
}
|
|
69
|
+
.color-main-dark-blue{
|
|
70
|
+
@apply text-main-dark-blue border-main-dark-blue;
|
|
71
|
+
}
|
|
72
|
+
.color-dark-blue{
|
|
73
|
+
@apply text-dark-blue border-dark-blue;
|
|
74
|
+
}
|
|
75
|
+
.color-light-blue{
|
|
76
|
+
@apply text-light-blue border-light-blue;
|
|
77
|
+
}
|
|
78
|
+
.color-white{
|
|
79
|
+
@apply text-white border-white;
|
|
80
|
+
}
|
|
81
|
+
.color-error-red{
|
|
82
|
+
@apply text-error-red border-error-red;
|
|
83
|
+
}
|
|
84
|
+
.color-tertiary-blue{
|
|
85
|
+
@apply text-tertiary-blue border-tertiary-blue;
|
|
86
|
+
}
|
|
87
|
+
.color-transparent{
|
|
88
|
+
@apply text-transparent border-transparent;
|
|
89
|
+
}
|
|
90
|
+
.no-border {
|
|
91
|
+
@apply border-0;
|
|
63
92
|
}
|
|
64
|
-
|
|
65
93
|
.disabled {
|
|
66
94
|
@apply opacity-30 cursor-default;
|
|
67
95
|
}
|
|
68
|
-
.
|
|
69
|
-
@apply hover:
|
|
70
|
-
}
|
|
96
|
+
.underline-effect {
|
|
97
|
+
@apply hover:underline;
|
|
98
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.bordered {
|
|
2
2
|
@apply border border-solid box-border rounded-md;
|
|
3
3
|
}
|
|
4
|
-
.bordered--green {
|
|
4
|
+
.bordered--main-green {
|
|
5
5
|
@apply border-main-green
|
|
6
6
|
}
|
|
7
7
|
.bordered--main-dark-blue {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.error-message {
|
|
12
|
-
@apply text-error-red text-xs px-2;
|
|
12
|
+
@apply absolute -bottom-5 text-error-red text-xs px-2;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.padded {
|
|
@@ -2,7 +2,7 @@ import React, { useState, cloneElement, Children } from 'react'
|
|
|
2
2
|
import styles from './Loadable.module.css'
|
|
3
3
|
import { SpinnerCircular } from 'spinners-react'
|
|
4
4
|
|
|
5
|
-
export default function
|
|
5
|
+
export default function Loadable ({ ...props }) {
|
|
6
6
|
// If null then loading not started, if true then loading, if false then done loading
|
|
7
7
|
const [loading, setLoading] = useState(null)
|
|
8
8
|
const startLoading = (reset = false) => {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import styles from './Loader.module.css'
|
|
3
|
+
import { SpinnerCircular } from 'spinners-react'
|
|
4
|
+
|
|
5
|
+
export default function Loader ({ loading, children }) {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
{
|
|
9
|
+
loading
|
|
10
|
+
? (
|
|
11
|
+
<div className={styles.container} data-testid='loading'>
|
|
12
|
+
<div data-testid='loading-content' className={styles.content}>
|
|
13
|
+
<SpinnerCircular className={styles.spinner} thickness={180} size={60} />
|
|
14
|
+
<div className={styles.blurred}>{children}</div>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
: children
|
|
19
|
+
}
|
|
20
|
+
</>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
.blur {
|
|
2
|
-
@apply
|
|
2
|
+
@apply fixed top-[50%] left-[50%] w-full h-screen translate-x-[-50%] translate-y-[-50%] z-10;
|
|
3
3
|
background-color: rgba(0, 0, 0, 0.75);
|
|
4
4
|
}
|
|
5
5
|
.container {
|
|
6
|
-
@apply z-
|
|
6
|
+
@apply z-20;
|
|
7
7
|
}
|
|
8
8
|
.centered {
|
|
9
9
|
@apply fixed top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import styles from './Field.module.css'
|
|
3
|
+
import HorizontalSeparator from '../HorizontalSeparator'
|
|
4
|
+
|
|
5
|
+
export default function Field ({ title, helper, children, disabled }) {
|
|
6
|
+
let className = `${styles.container}`
|
|
7
|
+
if (disabled) className += ` ${styles.disabled}`
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<div className={className}>
|
|
11
|
+
<p className={styles.title}>{title}</p>
|
|
12
|
+
<p className={styles.helper}>{helper}</p>
|
|
13
|
+
<div className={styles.content}>
|
|
14
|
+
{children}
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
<HorizontalSeparator color='main-dark-green' opacity={20} marginBottom={10} marginTop={10} />
|
|
18
|
+
</>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
@apply flex flex-col;
|
|
3
|
+
}
|
|
4
|
+
.title{
|
|
5
|
+
@apply text-xl font-semibold text-main-dark-blue;
|
|
6
|
+
}
|
|
7
|
+
.helper{
|
|
8
|
+
@apply text-sm text-main-dark-blue pb-4;
|
|
9
|
+
}
|
|
10
|
+
.content {
|
|
11
|
+
@apply flex gap-x-1 w-full;
|
|
12
|
+
}
|
|
13
|
+
.content button {
|
|
14
|
+
@apply shrink-0;
|
|
15
|
+
}
|
|
16
|
+
.disabled {
|
|
17
|
+
@apply opacity-20;
|
|
18
|
+
}
|
|
@@ -1,15 +1,55 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
import React from 'react'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
3
4
|
import styles from './Input.module.css'
|
|
4
5
|
import commonStyles from '../Common.module.css'
|
|
5
|
-
|
|
6
|
+
function Input ({ placeholder, value, name, borderColor, errorMessage, onChange, disabled }) {
|
|
6
7
|
const className = styles.inputContainer + ' ' + commonStyles[`bordered--${borderColor}`] + ' ' + commonStyles[`text--${borderColor}`] + ' ' + commonStyles.padded
|
|
7
8
|
return (
|
|
8
|
-
|
|
9
|
+
<div className={styles.container}>
|
|
9
10
|
<div className={className}>
|
|
10
|
-
<input type='text' name={name} value={value} placeholder={placeholder} className=
|
|
11
|
+
<input type='text' name={name} value={value} placeholder={placeholder} className={styles.fullWidth} onChange={onChange} disabled={disabled} />
|
|
11
12
|
</div>
|
|
12
13
|
{errorMessage.length > 0 && <span className={commonStyles['error-message']}>{errorMessage}</span>}
|
|
13
|
-
|
|
14
|
+
</div>
|
|
14
15
|
)
|
|
15
16
|
}
|
|
17
|
+
|
|
18
|
+
Input.propTypes = {
|
|
19
|
+
/**
|
|
20
|
+
* placeholder
|
|
21
|
+
*/
|
|
22
|
+
placeholder: PropTypes.string,
|
|
23
|
+
/**
|
|
24
|
+
* value
|
|
25
|
+
*/
|
|
26
|
+
value: PropTypes.string,
|
|
27
|
+
/**
|
|
28
|
+
* name
|
|
29
|
+
*/
|
|
30
|
+
name: PropTypes.string,
|
|
31
|
+
/**
|
|
32
|
+
* color of border
|
|
33
|
+
*/
|
|
34
|
+
borderColor: PropTypes.oneOf(['main-green', 'main-dark-blue']),
|
|
35
|
+
/**
|
|
36
|
+
* onChange
|
|
37
|
+
*/
|
|
38
|
+
onChange: PropTypes.func,
|
|
39
|
+
/**
|
|
40
|
+
* Disabled
|
|
41
|
+
*/
|
|
42
|
+
disabled: PropTypes.bool
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Input.defaultProps = {
|
|
46
|
+
placeholder: '',
|
|
47
|
+
value: null,
|
|
48
|
+
name: '',
|
|
49
|
+
borderColor: 'main-green',
|
|
50
|
+
errorMessage: '',
|
|
51
|
+
onChange: () => {},
|
|
52
|
+
disabled: false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default Input
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
@apply flex flex-col w-full relative;
|
|
3
|
+
}
|
|
1
4
|
.inputContainer {
|
|
2
|
-
@apply flex
|
|
5
|
+
@apply flex h-10 border border-solid box-border rounded-md;
|
|
6
|
+
}
|
|
7
|
+
.fullWidth {
|
|
8
|
+
@apply w-full;
|
|
3
9
|
}
|
|
4
10
|
.input {
|
|
5
|
-
@apply
|
|
11
|
+
@apply focus:outline-none focus-within:outline-none focus-visible:outline-none;
|
|
6
12
|
}
|
|
7
13
|
[type='text']:focus {
|
|
8
14
|
outline: none;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import styles from './Preview.module.css'
|
|
3
|
+
import HorizontalSeparator from '../HorizontalSeparator'
|
|
4
|
+
|
|
5
|
+
export default function Preview ({ title, value, isLink = false }) {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<div className={styles.container}>
|
|
9
|
+
<p className={styles.title}>{title}</p>
|
|
10
|
+
{isLink ? <a className={styles.link} href={value} target='_blank' rel='noreferrer'>{value}</a> : <p className={styles.value}>{value}</p>}
|
|
11
|
+
</div>
|
|
12
|
+
<HorizontalSeparator color='main-dark-green' opacity={20} marginBottom={10} marginTop={10} />
|
|
13
|
+
</>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import ToggleSwitch from './ToggleSwitch'
|
|
2
1
|
import Input from './Input'
|
|
2
|
+
import Field from './Field'
|
|
3
|
+
import Preview from './Preview'
|
|
4
|
+
import ToggleSwitch from './ToggleSwitch'
|
|
3
5
|
|
|
4
6
|
export default {
|
|
5
|
-
|
|
7
|
+
Input, Field, Preview, ToggleSwitch
|
|
6
8
|
}
|
|
@@ -5,8 +5,17 @@ import CloseModalIcon from './CloseModalIcon'
|
|
|
5
5
|
import RoundCloseIcon from './RoundCloseIcon'
|
|
6
6
|
import RoundCloseHoverIcon from './RoundCloseHoverIcon'
|
|
7
7
|
import MetricsIcon from './MetricsIcon'
|
|
8
|
+
import PuzzleIcon from './PuzzleIcon'
|
|
8
9
|
import PullRequestIcon from './PullRequestIcon'
|
|
9
10
|
|
|
10
11
|
export default {
|
|
11
|
-
ApiIcon,
|
|
12
|
+
ApiIcon,
|
|
13
|
+
ApiIconClosed,
|
|
14
|
+
ApiEmptyIcon,
|
|
15
|
+
CloseModalIcon,
|
|
16
|
+
RoundCloseIcon,
|
|
17
|
+
RoundCloseHoverIcon,
|
|
18
|
+
MetricsIcon,
|
|
19
|
+
PuzzleIcon,
|
|
20
|
+
PullRequestIcon
|
|
12
21
|
}
|
|
@@ -3,6 +3,8 @@ import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
|
|
3
3
|
import { useState } from 'react'
|
|
4
4
|
import Button from '../components/Button'
|
|
5
5
|
|
|
6
|
+
const colors = ['main-green', 'dark-green', 'light-green', 'main-dark-blue', 'dark-blue', 'light-blue', 'white', 'error-red', 'tertiary-blue', 'transparent']
|
|
7
|
+
|
|
6
8
|
export default {
|
|
7
9
|
title: 'Platformatic/Button',
|
|
8
10
|
component: Button,
|
|
@@ -14,18 +16,18 @@ export default {
|
|
|
14
16
|
bold: {
|
|
15
17
|
type: 'boolean'
|
|
16
18
|
},
|
|
17
|
-
|
|
19
|
+
backgroundColor: {
|
|
18
20
|
type: 'string',
|
|
19
21
|
control: {
|
|
20
22
|
type: 'radio',
|
|
21
|
-
options:
|
|
23
|
+
options: colors
|
|
22
24
|
}
|
|
23
25
|
},
|
|
24
26
|
color: {
|
|
25
27
|
type: 'string',
|
|
26
28
|
control: {
|
|
27
29
|
type: 'radio',
|
|
28
|
-
options:
|
|
30
|
+
options: colors
|
|
29
31
|
}
|
|
30
32
|
},
|
|
31
33
|
disabled: {
|
|
@@ -37,57 +39,38 @@ export default {
|
|
|
37
39
|
type: 'radio',
|
|
38
40
|
options: ['small', 'medium', 'large', 'extra-large']
|
|
39
41
|
}
|
|
42
|
+
},
|
|
43
|
+
underlineEffect: {
|
|
44
|
+
type: 'boolean'
|
|
45
|
+
},
|
|
46
|
+
bordered: {
|
|
47
|
+
type: 'boolean'
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
const Template = (args) => <Button {...args} />
|
|
45
53
|
|
|
46
|
-
export const
|
|
54
|
+
export const OnlyLabel = Template.bind({})
|
|
47
55
|
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
color: 'green',
|
|
52
|
-
bold: true
|
|
56
|
+
OnlyLabel.args = {
|
|
57
|
+
label: 'Sample label',
|
|
58
|
+
backgroundColor: 'light-green'
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
export const
|
|
56
|
-
|
|
57
|
-
label: '
|
|
58
|
-
color: 'red'
|
|
61
|
+
export const BorderedRed = Template.bind({})
|
|
62
|
+
BorderedRed.args = {
|
|
63
|
+
label: 'Borderer Red',
|
|
64
|
+
color: 'error-red'
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
export const TransparentWhite = Template.bind({})
|
|
62
68
|
TransparentWhite.args = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
color: 'white'
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const PrimaryWithIcon = Template.bind({})
|
|
69
|
-
PrimaryWithIcon.args = {
|
|
70
|
-
buttonClass: 'primary',
|
|
71
|
-
label: 'Primary with Icon',
|
|
69
|
+
label: 'White',
|
|
70
|
+
color: 'white',
|
|
72
71
|
icon: faCheck
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
export const SecondaryWithIcon = Template.bind({})
|
|
76
|
-
SecondaryWithIcon.args = {
|
|
77
|
-
buttonClass: 'secondary',
|
|
78
|
-
label: 'Secondary with Icon',
|
|
79
|
-
icon: faCheck,
|
|
80
|
-
color: 'white'
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const PrimaryRed = Template.bind({})
|
|
84
|
-
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
85
|
-
PrimaryRed.args = {
|
|
86
|
-
buttonClass: 'primary',
|
|
87
|
-
label: 'Primary Red',
|
|
88
|
-
color: 'red'
|
|
89
|
-
}
|
|
90
|
-
|
|
91
74
|
const DisabledTemplate = (args) => {
|
|
92
75
|
const [enabled, setEnabled] = useState(false)
|
|
93
76
|
return (
|
|
@@ -97,28 +80,25 @@ const DisabledTemplate = (args) => {
|
|
|
97
80
|
<span className='ml-4 text-xl'>👈 This button is {enabled ? 'enabled' : 'disabled'}</span>
|
|
98
81
|
</div>
|
|
99
82
|
<div>
|
|
100
|
-
<Button label='Toggle Disabled'
|
|
83
|
+
<Button label='Toggle Disabled' backgroundColor='main-green' onClick={() => setEnabled(!enabled)} />
|
|
101
84
|
</div>
|
|
102
|
-
|
|
103
85
|
</div>
|
|
104
|
-
|
|
105
86
|
)
|
|
106
87
|
}
|
|
107
88
|
|
|
108
89
|
export const DisabledGreen = DisabledTemplate.bind({})
|
|
109
90
|
|
|
110
91
|
DisabledGreen.args = {
|
|
111
|
-
|
|
92
|
+
backgroundColor: 'main-green',
|
|
112
93
|
label: 'A simple button',
|
|
113
|
-
color: '
|
|
94
|
+
color: 'main-dark-blue',
|
|
114
95
|
disabled: true
|
|
115
96
|
}
|
|
116
97
|
|
|
117
98
|
export const DisabledRed = DisabledTemplate.bind({})
|
|
118
99
|
|
|
119
100
|
DisabledRed.args = {
|
|
120
|
-
buttonClass: 'primary',
|
|
121
101
|
label: 'A simple button',
|
|
122
|
-
color: 'red',
|
|
102
|
+
color: 'error-red',
|
|
123
103
|
disabled: true
|
|
124
104
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import Loader from '../components/Loader'
|
|
3
|
+
import Button from '../components/Button'
|
|
4
|
+
import BorderedBox from '../components/BorderedBox'
|
|
5
|
+
|
|
6
|
+
const loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus est nisl, maximus aliquet urna eu, consequat semper nisi. Nam vel elit feugiat dui congue elementum. Sed turpis urna, egestas at pharetra et, lacinia ac mauris. Pellentesque cursus, ipsum nec malesuada ornare, dui purus ultrices elit, non blandit nisi quam non nisi. Suspendisse sapien leo, ultricies pretium vulputate sed, malesuada sed justo. Suspendisse euismod erat ut lacus feugiat malesuada. In tempor a eros et egestas. Nam pretium dolor sollicitudin, cursus sem vitae, elementum enim. Nam in nisi ipsum.'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Platformatic/Loader',
|
|
10
|
+
component: Loader
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Loading = args =>
|
|
14
|
+
<Loader {...args}>
|
|
15
|
+
<BorderedBox>{loremIpsum}</BorderedBox>
|
|
16
|
+
</Loader>
|
|
17
|
+
|
|
18
|
+
Loading.args = {
|
|
19
|
+
loading: true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const LoadsAndStops = ({ loading, ...args }) => {
|
|
23
|
+
const [showLoader, setShowLoader] = useState(args.loading)
|
|
24
|
+
const show = () => setShowLoader(true)
|
|
25
|
+
const hide = () => setShowLoader(false)
|
|
26
|
+
|
|
27
|
+
function load () {
|
|
28
|
+
show()
|
|
29
|
+
const timer = setTimeout(() => {
|
|
30
|
+
hide()
|
|
31
|
+
}, 2000)
|
|
32
|
+
return () => clearTimeout(timer)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Loader loading={showLoader} {...args}>
|
|
37
|
+
<Button label='Start Loading' color='error-red' onClick={() => load()} />
|
|
38
|
+
<BorderedBox>{loremIpsum}</BorderedBox>
|
|
39
|
+
</Loader>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
LoadsAndStops.args = {
|
|
43
|
+
loading: false
|
|
44
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
import Field from '../../components/forms/Field'
|
|
3
|
+
import Button from '../../components/Button'
|
|
4
|
+
import Input from '../../components/forms/Input'
|
|
5
|
+
|
|
6
|
+
const divStyle = {
|
|
7
|
+
width: '100%',
|
|
8
|
+
height: 'auto',
|
|
9
|
+
padding: '10px',
|
|
10
|
+
backgroundColor: 'white'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: 'Platformatic/Forms/Field',
|
|
15
|
+
component: Field,
|
|
16
|
+
parameters: {
|
|
17
|
+
backgrounds: {
|
|
18
|
+
default: 'white'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const SimpleTemplate = (args) => <div style={divStyle}><Field {...args} /></div>
|
|
24
|
+
|
|
25
|
+
export const BasicField = SimpleTemplate.bind({})
|
|
26
|
+
|
|
27
|
+
BasicField.args = {
|
|
28
|
+
title: 'Field basic',
|
|
29
|
+
helper: 'A very very very very very very very very very very very very very very simple helper'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const InputTemplate = (args) => {
|
|
33
|
+
function renderChild (combinationSelected) {
|
|
34
|
+
let rendered = <></>
|
|
35
|
+
|
|
36
|
+
switch (combinationSelected) {
|
|
37
|
+
case 'button':
|
|
38
|
+
rendered = (<Button label='Button for a purpose' color='error-red' onClick={() => { alert('clicked') }} />)
|
|
39
|
+
break
|
|
40
|
+
case 'input-buttons':
|
|
41
|
+
rendered =
|
|
42
|
+
(
|
|
43
|
+
<>
|
|
44
|
+
<Input name='test' placeholder='Platformatic' errorMessage='this is an error message' />
|
|
45
|
+
<Button label='Button for some purposes' color='main-dark-blue' onClick={() => { alert('clicked') }} />
|
|
46
|
+
<Button label='Button for other purposes' color='error-red' onClick={() => { alert('clicked') }} />
|
|
47
|
+
</>
|
|
48
|
+
)
|
|
49
|
+
break
|
|
50
|
+
case 'input':
|
|
51
|
+
rendered = (<Input name='test' placeholder='Platformatic' />)
|
|
52
|
+
break
|
|
53
|
+
case 'input-button':
|
|
54
|
+
rendered =
|
|
55
|
+
(
|
|
56
|
+
<>
|
|
57
|
+
<Input name='test' placeholder='Platformatic' />
|
|
58
|
+
<Button label='Button Simple' color='main-dark-blue' onClick={() => { alert('clicked') }} />
|
|
59
|
+
</>
|
|
60
|
+
)
|
|
61
|
+
break
|
|
62
|
+
default:
|
|
63
|
+
break
|
|
64
|
+
}
|
|
65
|
+
return rendered
|
|
66
|
+
}
|
|
67
|
+
return (
|
|
68
|
+
<div style={divStyle}>
|
|
69
|
+
{['input', 'input-button', 'input-buttons', 'button'].map(how => {
|
|
70
|
+
return (<Field key={how} {...args}>{renderChild(how)}</Field>)
|
|
71
|
+
})}
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const WithInput = InputTemplate.bind({})
|
|
77
|
+
|
|
78
|
+
WithInput.args = {
|
|
79
|
+
title: 'Different cases',
|
|
80
|
+
helper: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
|
|
81
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
import Preview from '../../components/forms/Preview'
|
|
3
|
+
|
|
4
|
+
const divStyle = {
|
|
5
|
+
width: '100%',
|
|
6
|
+
height: 'auto',
|
|
7
|
+
padding: '10px',
|
|
8
|
+
backgroundColor: 'white'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Platformatic/Forms/Preview',
|
|
13
|
+
component: Preview,
|
|
14
|
+
parameters: {
|
|
15
|
+
backgrounds: {
|
|
16
|
+
default: 'white'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SimpleTemplate = (args) => <div style={divStyle}><Preview {...args} /></div>
|
|
22
|
+
|
|
23
|
+
export const NormalPreview = SimpleTemplate.bind({})
|
|
24
|
+
|
|
25
|
+
NormalPreview.args = {
|
|
26
|
+
title: 'My title',
|
|
27
|
+
value: 'My value'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const WithLink = SimpleTemplate.bind({})
|
|
31
|
+
|
|
32
|
+
WithLink.args = {
|
|
33
|
+
title: 'My value is a link',
|
|
34
|
+
value: 'https://example.com',
|
|
35
|
+
isLink: true
|
|
36
|
+
}
|