@platformatic/ui-components 0.1.26 → 0.1.29
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
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>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
@apply fixed top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]
|
|
10
10
|
}
|
|
11
11
|
.modal {
|
|
12
|
-
@apply bg-[#E9F7FF] p-4 rounded-md mx-auto my-auto min-w-[480px];
|
|
12
|
+
@apply bg-[#E9F7FF] p-4 rounded-md mx-auto my-auto min-w-[480px] max-h-[85vh] overflow-y-scroll;
|
|
13
13
|
}
|
|
14
14
|
.header {
|
|
15
15
|
@apply flex justify-between items-center;
|
|
@@ -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
|
+
}
|
|
@@ -16,7 +16,7 @@ const Template = (args) => {
|
|
|
16
16
|
<BorderedBox>This Is another Content</BorderedBox>
|
|
17
17
|
<ContentThatLoads />
|
|
18
18
|
<Button color='green' primary='true' onClick={() => setIsOpen(true)} label='Open Modal' />
|
|
19
|
-
{isOpen && <Modal setIsOpen={setIsOpen} title='Modal Title'>
|
|
19
|
+
{isOpen && <Modal setIsOpen={setIsOpen} title='Modal Title'>{args.text}</Modal>}
|
|
20
20
|
</main>
|
|
21
21
|
)
|
|
22
22
|
}
|
|
@@ -32,7 +32,17 @@ const ContentThatLoads = () => {
|
|
|
32
32
|
|
|
33
33
|
export const Default = Template.bind({})
|
|
34
34
|
Default.args = {
|
|
35
|
-
title: 'List Title'
|
|
35
|
+
title: 'List Title',
|
|
36
|
+
text: 'Hello World'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const WithLongText = Template.bind({})
|
|
40
|
+
|
|
41
|
+
WithLongText.args = {
|
|
42
|
+
title: 'Modal',
|
|
43
|
+
text: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi fermentum, lorem nec tincidunt pellentesque, odio orci posuere lacus, et hendrerit turpis dolor nec metus. Nunc quis finibus enim. Vestibulum a mollis velit. Ut nec vestibulum urna. Phasellus ut odio nec leo hendrerit laoreet eget at turpis. Nulla facilisi. Vivamus accumsan arcu malesuada, imperdiet ligula vitae, varius elit. Morbi blandit eros nec eros rutrum mattis. Nulla nibh nisi, pellentesque a ornare at, ultrices sit amet felis. Nulla bibendum metus diam, vitae gravida dui semper iaculis.
|
|
44
|
+
|
|
45
|
+
`.repeat(5)
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
const MenuTemplate = () => {
|