@platformatic/ui-components 0.7.34 → 0.7.35
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
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import styles from './Checkbox.module.css'
|
|
5
|
-
import { MAIN_DARK_BLUE, RICH_BLACK, WHITE } from './constants'
|
|
5
|
+
import { MAIN_DARK_BLUE, MEDIUM, RICH_BLACK, SMALL, WHITE } from './constants'
|
|
6
6
|
function Checkbox ({
|
|
7
7
|
disabled = false,
|
|
8
8
|
color = MAIN_DARK_BLUE,
|
|
9
|
+
size = MEDIUM,
|
|
9
10
|
...rest
|
|
10
11
|
}) {
|
|
11
|
-
let className = `${styles.checkbox}
|
|
12
|
-
className += styles[`checkbox--${
|
|
12
|
+
let className = `${styles.checkbox}`
|
|
13
|
+
className += ' ' + styles[`checkbox--${size}`]
|
|
14
|
+
className += ' ' + styles[`checkbox--${color}`]
|
|
13
15
|
if (disabled) className += ` ${styles.disabled}`
|
|
14
16
|
return (
|
|
15
17
|
<input type='checkbox' className={className} disabled={disabled} {...rest} />
|
|
@@ -24,7 +26,11 @@ Checkbox.propTypes = {
|
|
|
24
26
|
/**
|
|
25
27
|
* color
|
|
26
28
|
*/
|
|
27
|
-
color: PropTypes.oneOf([WHITE, MAIN_DARK_BLUE, RICH_BLACK])
|
|
29
|
+
color: PropTypes.oneOf([WHITE, MAIN_DARK_BLUE, RICH_BLACK]),
|
|
30
|
+
/**
|
|
31
|
+
* size
|
|
32
|
+
*/
|
|
33
|
+
size: PropTypes.oneOf([SMALL, MEDIUM])
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
export default Checkbox
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
.checkbox {
|
|
2
|
-
@apply border border-solid
|
|
2
|
+
@apply border border-solid rounded-sm relative inline-block m-0;
|
|
3
3
|
-webkit-appearance: none;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
.checkbox--medium {
|
|
7
|
+
@apply p-2 h-2 w-2;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.checkbox--small {
|
|
11
|
+
@apply p-[5px] h-[10px] w-[10px];
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
.checkbox--main-dark-blue {
|
|
7
15
|
@apply border-light-green bg-main-dark-blue
|
|
8
16
|
}
|
|
@@ -16,14 +24,20 @@
|
|
|
16
24
|
.checkbox--white:checked {
|
|
17
25
|
@apply bg-white text-rich-black;
|
|
18
26
|
}
|
|
19
|
-
.checkbox--main-dark-blue:checked:after,
|
|
20
|
-
.checkbox--rich-black:checked:after {
|
|
27
|
+
.checkbox--medium.checkbox--main-dark-blue:checked:after,
|
|
28
|
+
.checkbox--medium.checkbox--rich-black:checked:after {
|
|
21
29
|
@apply absolute h-full w-full;
|
|
22
30
|
top: 1px;
|
|
23
31
|
left: 1.5px;
|
|
24
32
|
content: url('data:image/svg+xml,%3Csvg%20width%3D%2213%22%20height%3D%229%22%20viewBox%3D%220%200%2013%209%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M1%204L5%208L12%201%22%20stroke%3D%22white%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
|
|
25
33
|
}
|
|
26
|
-
|
|
34
|
+
.checkbox--small.checkbox--main-dark-blue:checked:after,
|
|
35
|
+
.checkbox--small.checkbox--rich-black:checked:after {
|
|
36
|
+
@apply absolute h-full w-full;
|
|
37
|
+
top: 1px;
|
|
38
|
+
left: 1px;
|
|
39
|
+
content: url('data:image/svg+xml,%3Csvg%20width%3D%2211%22%20height%3D%228%22%20viewBox%3D%220%200%2011%208%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%3Cpath%20d%3D%22M1.25%203.5L4.25%206.5L9.5%201.25%22%20stroke%3D%22white%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%20%3C%2Fsvg%3E');
|
|
40
|
+
}
|
|
27
41
|
.disabled {
|
|
28
42
|
@apply border-white;
|
|
29
43
|
}
|
|
@@ -34,9 +48,16 @@
|
|
|
34
48
|
.checkbox--rich-black:checked {
|
|
35
49
|
@apply bg-white text-rich-black;
|
|
36
50
|
}
|
|
37
|
-
.checkbox--white:checked:after {
|
|
51
|
+
.checkbox--medium.checkbox--white:checked:after {
|
|
38
52
|
@apply absolute h-full w-full;
|
|
39
53
|
top: 1px;
|
|
40
54
|
left: 1.5px;
|
|
41
55
|
content: url('data:image/svg+xml,%3Csvg%20width=%2213%22%20height=%229%22%20viewBox=%220%200%2013%209%22%20fill=%22none%22%20xmlns=%22http://www.w3.org/2000/svg%22%3E%3Cpath%20d=%22M1%204L5%208L12%201%22%20stroke%3D%22%2300050B%22%20stroke-width=%222%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22/%3E%3C/svg%3E');
|
|
42
56
|
}
|
|
57
|
+
|
|
58
|
+
.checkbox--small.checkbox--white:checked:after {
|
|
59
|
+
@apply absolute h-full w-full;
|
|
60
|
+
top: -2px;
|
|
61
|
+
left: 0px;
|
|
62
|
+
content: url('data:image/svg+xml,%3Csvg%20width%3D%2211%22%20height%3D%228%22%20viewBox%3D%220%200%2011%208%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%20%3Cpath%20d%3D%22M1.25%203.5L4.25%206.5L9.5%201.25%22%20stroke%3D%22%2300050B%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%20%3C%2Fsvg%3E');
|
|
63
|
+
}
|
|
@@ -3,6 +3,7 @@ import React from 'react'
|
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import styles from './ToggleSwitch.module.css'
|
|
5
5
|
import commonStyles from '../Common.module.css'
|
|
6
|
+
import { MEDIUM, SMALL } from '../constants'
|
|
6
7
|
|
|
7
8
|
function ToggleSwitch ({
|
|
8
9
|
name = '',
|
|
@@ -12,19 +13,23 @@ function ToggleSwitch ({
|
|
|
12
13
|
errorMessageTextClassName = '',
|
|
13
14
|
onChange = () => {},
|
|
14
15
|
checked = false,
|
|
15
|
-
disabled = false
|
|
16
|
+
disabled = false,
|
|
17
|
+
size = MEDIUM
|
|
16
18
|
}) {
|
|
17
19
|
let className = `${styles.switch} `
|
|
20
|
+
className += styles[`switch--${size}`] + ' '
|
|
18
21
|
if (disabled) className += styles.disabled
|
|
19
22
|
const styleLabel = labelClassName || styles.defaultLabel
|
|
20
23
|
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
24
|
+
let sliderClassName = `${styles.slider} ${styles.round} `
|
|
25
|
+
sliderClassName += styles[`slider--${size}`]
|
|
21
26
|
|
|
22
27
|
return (
|
|
23
28
|
<>
|
|
24
29
|
<div className={styles.container}>
|
|
25
30
|
<label className={className}>
|
|
26
31
|
<input type='checkbox' name={name} onChange={onChange} checked={checked} disabled={disabled} />
|
|
27
|
-
<span className={
|
|
32
|
+
<span className={sliderClassName} />
|
|
28
33
|
</label>
|
|
29
34
|
<span className={styleLabel}>{label}</span>
|
|
30
35
|
</div>
|
|
@@ -65,7 +70,11 @@ ToggleSwitch.propTypes = {
|
|
|
65
70
|
/**
|
|
66
71
|
* labelClassName
|
|
67
72
|
*/
|
|
68
|
-
labelClassName: PropTypes.string
|
|
73
|
+
labelClassName: PropTypes.string,
|
|
74
|
+
/**
|
|
75
|
+
* size
|
|
76
|
+
*/
|
|
77
|
+
size: PropTypes.oneOf([SMALL, MEDIUM])
|
|
69
78
|
|
|
70
79
|
}
|
|
71
80
|
|
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
@apply flex w-full h-10 items-center gap-x-2;
|
|
3
3
|
}
|
|
4
4
|
.switch {
|
|
5
|
-
@apply relative inline-block
|
|
5
|
+
@apply relative inline-block cursor-pointer;
|
|
6
|
+
}
|
|
7
|
+
.switch--medium {
|
|
8
|
+
@apply w-[50px] h-[24px]
|
|
9
|
+
}
|
|
10
|
+
.switch--small {
|
|
11
|
+
@apply w-[30px] h-[16px]
|
|
6
12
|
}
|
|
7
13
|
.switch input {
|
|
8
14
|
@apply opacity-0 w-0 h-0;
|
|
@@ -13,26 +19,40 @@
|
|
|
13
19
|
-webkit-transition: .4s;
|
|
14
20
|
transition: .4s;
|
|
15
21
|
}
|
|
22
|
+
|
|
16
23
|
.defaultLabel {
|
|
17
24
|
@apply px-2 text-xs font-normal text-main-dark-blue;
|
|
18
25
|
}
|
|
19
|
-
.slider:before
|
|
20
|
-
|
|
26
|
+
.slider--small:before,
|
|
27
|
+
.slider--medium:before {
|
|
21
28
|
content: "";
|
|
22
29
|
-webkit-transition: .4s;
|
|
23
30
|
transition: .4s;
|
|
24
31
|
}
|
|
25
32
|
|
|
33
|
+
.slider--medium:before {
|
|
34
|
+
@apply absolute h-[22px] w-[22px] left-[1px] bottom-[1px] bg-white;
|
|
35
|
+
}
|
|
36
|
+
.slider--small:before{
|
|
37
|
+
@apply absolute h-[14px] w-[14px] left-[1px] bottom-[1px] bg-white;
|
|
38
|
+
}
|
|
39
|
+
|
|
26
40
|
input:checked + .slider {
|
|
27
41
|
@apply bg-main-green;
|
|
28
42
|
}
|
|
29
43
|
|
|
30
|
-
input:checked + .slider:before {
|
|
44
|
+
input:checked + .slider--medium:before {
|
|
31
45
|
-webkit-transform: translateX(26px);
|
|
32
46
|
-ms-transform: translateX(26px);
|
|
33
47
|
transform: translateX(26px);
|
|
34
48
|
}
|
|
35
49
|
|
|
50
|
+
input:checked + .slider--small:before {
|
|
51
|
+
-webkit-transform: translateX(14px);
|
|
52
|
+
-ms-transform: translateX(14px);
|
|
53
|
+
transform: translateX(14px);
|
|
54
|
+
}
|
|
55
|
+
|
|
36
56
|
/* Rounded sliders */
|
|
37
57
|
.slider.round {
|
|
38
58
|
border-radius: 100px;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
import Checkbox from '../components/Checkbox'
|
|
3
|
-
import { WHITE } from '../components/constants'
|
|
3
|
+
import { MEDIUM, SMALL, WHITE } from '../components/constants'
|
|
4
4
|
const divStyle = {
|
|
5
5
|
width: '100%',
|
|
6
6
|
height: 'auto',
|
|
@@ -24,6 +24,10 @@ export default {
|
|
|
24
24
|
},
|
|
25
25
|
disabled: {
|
|
26
26
|
type: 'boolean'
|
|
27
|
+
},
|
|
28
|
+
size: {
|
|
29
|
+
type: 'radio',
|
|
30
|
+
options: [SMALL, MEDIUM]
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
}
|