@platformatic/ui-components 0.1.25 → 0.1.27
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 +2 -2
- package/src/components/Button.module.css +4 -0
- package/src/components/DropDown.module.css +1 -1
- package/src/components/Modal.module.css +1 -1
- package/src/stories/Button.stories.jsx +36 -0
- package/src/stories/DropDown.stories.jsx +12 -2
- package/src/stories/Modal.stories.jsx +31 -0
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import React from 'react'
|
|
|
4
4
|
import styles from './Button.module.css'
|
|
5
5
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
6
6
|
export default function Button (props) {
|
|
7
|
-
const { icon, label, primary, color } = props
|
|
7
|
+
const { icon, label, primary, color, disabled } = props
|
|
8
8
|
let buttonClass = 'primary'
|
|
9
9
|
if (!primary) {
|
|
10
10
|
buttonClass = 'secondary'
|
|
@@ -15,7 +15,7 @@ export default function Button (props) {
|
|
|
15
15
|
colorClass = 'red'
|
|
16
16
|
}
|
|
17
17
|
return (
|
|
18
|
-
<button className={`${styles.button} ${styles[buttonClass + '-' + colorClass]}`} {...props}>
|
|
18
|
+
<button className={`${styles.button} ${styles[buttonClass + '-' + colorClass]} ${disabled ? styles.disabled : null}`} disabled={disabled} {...props}>
|
|
19
19
|
{icon ? <FontAwesomeIcon icon={icon} className='mr-2' data-testid='button-icon' /> : null}
|
|
20
20
|
<span>{label}</span>
|
|
21
21
|
</button>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
@apply hover:cursor-pointer
|
|
17
17
|
}
|
|
18
18
|
.menu {
|
|
19
|
-
@apply absolute border-solid border border-main-green p-4 bg-dark-blue mt-8 rounded-md z-[
|
|
19
|
+
@apply absolute border-solid border border-main-green p-4 bg-dark-blue mt-8 rounded-md z-[999];
|
|
20
20
|
}
|
|
21
21
|
.item {
|
|
22
22
|
@apply mb-2
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.blur {
|
|
2
|
-
@apply absolute top-[50%] left-[50%] z-0 w-[100vw] h-[100vh] translate-x-[-50%] translate-y-[-50%];
|
|
2
|
+
@apply absolute top-[50%] left-[50%] z-0 w-[100vw] h-[100vh] translate-x-[-50%] translate-y-[-50%] z-[9999];
|
|
3
3
|
background-color: rgba(0, 0, 0, 0.75);
|
|
4
4
|
}
|
|
5
5
|
.container {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
|
3
|
+
import { useState } from 'react'
|
|
3
4
|
import Button from '../components/Button'
|
|
4
5
|
|
|
5
6
|
export default {
|
|
@@ -69,3 +70,38 @@ SecondaryRed.args = {
|
|
|
69
70
|
label: 'Secondary Red',
|
|
70
71
|
color: 'red'
|
|
71
72
|
}
|
|
73
|
+
|
|
74
|
+
const DisabledTemplate = (args) => {
|
|
75
|
+
const [enabled, setEnabled] = useState(false)
|
|
76
|
+
return (
|
|
77
|
+
<div className='flex flex-col gap-y-6 text-white'>
|
|
78
|
+
<div>
|
|
79
|
+
<Button {...args} disabled={!enabled} onClick={() => alert('clicked')} />
|
|
80
|
+
<span className='ml-4 text-xl'>👈 This button is {enabled ? 'enabled' : 'disabled'}</span>
|
|
81
|
+
</div>
|
|
82
|
+
<div>
|
|
83
|
+
<Button label='Toggle Disabled' primary='true' onClick={() => setEnabled(!enabled)} />
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const DisabledGreen = DisabledTemplate.bind({})
|
|
92
|
+
|
|
93
|
+
DisabledGreen.args = {
|
|
94
|
+
primary: true,
|
|
95
|
+
label: 'A simple button',
|
|
96
|
+
color: 'green',
|
|
97
|
+
disabeld: true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const DisabledRed = DisabledTemplate.bind({})
|
|
101
|
+
|
|
102
|
+
DisabledRed.args = {
|
|
103
|
+
primary: true,
|
|
104
|
+
label: 'A simple button',
|
|
105
|
+
color: 'red',
|
|
106
|
+
disabeld: true
|
|
107
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import DropDown from '../components/DropDown'
|
|
3
3
|
import BorderedBox from '../components/BorderedBox'
|
|
4
4
|
import HorizontalSeparator from '../components/HorizontalSeparator'
|
|
5
|
+
import { useState } from 'react'
|
|
5
6
|
export default {
|
|
6
7
|
title: 'Platformatic/DropDown',
|
|
7
8
|
component: DropDown,
|
|
@@ -12,10 +13,19 @@ const Template = (args) => (
|
|
|
12
13
|
<div>
|
|
13
14
|
<DropDown {...args} />
|
|
14
15
|
<HorizontalSeparator />
|
|
15
|
-
<
|
|
16
|
+
<ContentThatLoads />
|
|
16
17
|
</div>
|
|
17
|
-
|
|
18
18
|
)
|
|
19
|
+
|
|
20
|
+
const ContentThatLoads = () => {
|
|
21
|
+
const [content, setContent] = useState(null)
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
setContent(<div className='mt-4'><BorderedBox>This is rendered after</BorderedBox></div>)
|
|
24
|
+
}, 1000)
|
|
25
|
+
|
|
26
|
+
return content
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
export const DefaultAlignment = Template.bind({})
|
|
20
30
|
|
|
21
31
|
DefaultAlignment.args = {
|
|
@@ -2,6 +2,8 @@ import React, { useState } from 'react'
|
|
|
2
2
|
import Modal from '../components/Modal'
|
|
3
3
|
import Button from '../components/Button'
|
|
4
4
|
import BorderedBox from '../components/BorderedBox'
|
|
5
|
+
import DropDown from '../components/DropDown'
|
|
6
|
+
import HorizontalSeparator from '../components/HorizontalSeparator'
|
|
5
7
|
export default {
|
|
6
8
|
title: 'Platformatic/Modal',
|
|
7
9
|
component: Modal
|
|
@@ -12,13 +14,42 @@ const Template = (args) => {
|
|
|
12
14
|
return (
|
|
13
15
|
<main>
|
|
14
16
|
<BorderedBox>This Is another Content</BorderedBox>
|
|
17
|
+
<ContentThatLoads />
|
|
15
18
|
<Button color='green' primary='true' onClick={() => setIsOpen(true)} label='Open Modal' />
|
|
16
19
|
{isOpen && <Modal setIsOpen={setIsOpen} title='Modal Title'>Hello world!</Modal>}
|
|
17
20
|
</main>
|
|
18
21
|
)
|
|
19
22
|
}
|
|
20
23
|
|
|
24
|
+
const ContentThatLoads = () => {
|
|
25
|
+
const [content, setContent] = useState(null)
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
setContent(<div className='mt-4'><BorderedBox>This is a Future Component</BorderedBox></div>)
|
|
28
|
+
}, 1000)
|
|
29
|
+
|
|
30
|
+
return content
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
export const Default = Template.bind({})
|
|
22
34
|
Default.args = {
|
|
23
35
|
title: 'List Title'
|
|
24
36
|
}
|
|
37
|
+
|
|
38
|
+
const MenuTemplate = () => {
|
|
39
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
40
|
+
const dropDownArgs = {
|
|
41
|
+
header: 'My Menu',
|
|
42
|
+
items: [
|
|
43
|
+
<span className='hover:cursor-pointer' key='2' onClick={() => setIsOpen(true)}>Show Modal</span>
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
return (
|
|
47
|
+
<div>
|
|
48
|
+
<div className='text-white'><DropDown {...dropDownArgs} /></div>
|
|
49
|
+
<HorizontalSeparator />
|
|
50
|
+
{isOpen && <Modal setIsOpen={setIsOpen} title='Modal Title'>Hello world!</Modal>}
|
|
51
|
+
<ContentThatLoads />
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
export const WithDropDown = MenuTemplate.bind({})
|