Skip to content

Commit 73b2182

Browse files
chore: reworks
Signed-off-by: Antonio Sonis <anthonysonis@gmail.com>
1 parent 53483d5 commit 73b2182

19 files changed

Lines changed: 297 additions & 60 deletions

src/components/Button.jsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import PlatformaticIcon from './PlatformaticIcon'
77
import { SIZES, COLORS_BUTTON, BOX_SHADOW, UNDERLINE, HOVER_EFFECTS_BUTTONS, BACKGROUND_COLOR_OPAQUE, MAIN_DARK_BLUE, LARGE } from './constants'
88

99
function Button ({
10-
icon,
10+
classes,
1111
label,
1212
color,
1313
backgroundColor,
@@ -21,30 +21,31 @@ function Button ({
2121
selected,
2222
...rest
2323
}) {
24-
let className = `${styles.button} ${commonStyles['background-color-' + backgroundColor]} ${styles['color-' + color]} ${styles['button-' + size]}`
25-
if (!bordered) className += ` ${styles['no-border']}`
24+
let buttonClassName = classes
25+
buttonClassName += ` ${styles.button} ${commonStyles['background-color-' + backgroundColor]} ${styles['color-' + color]} ${styles['button-' + size]}`
26+
if (!bordered) buttonClassName += ` ${styles['no-border']}`
2627
if (disabled) {
27-
className += ` ${styles.disabled}`
28+
buttonClassName += ` ${styles.disabled}`
2829
} else {
2930
switch (hoverEffect) {
3031
case BACKGROUND_COLOR_OPAQUE:
31-
className += ' ' + commonStyles[`hover-${BACKGROUND_COLOR_OPAQUE}-${color}`]
32+
buttonClassName += ' ' + commonStyles[`hover-${BACKGROUND_COLOR_OPAQUE}-${color}`]
3233
break
3334
case BOX_SHADOW:
34-
className += ' ' + styles[`hover-${BOX_SHADOW}-${backgroundColor}`]
35+
buttonClassName += ' ' + styles[`hover-${BOX_SHADOW}-${backgroundColor}`]
3536
break
3637
case UNDERLINE:
37-
className += ` ${styles['underline-effect']}`
38+
buttonClassName += ` ${styles['underline-effect']}`
3839
break
3940
default:
4041
break
4142
}
4243
}
43-
if (bold) className += ` ${styles.fontBold}`
44-
if (fullWidth) className += ` ${styles.fullWidth}`
45-
if (selected) className += ' ' + commonStyles[`selected-background-color-${color}`]
44+
if (bold) buttonClassName += ` ${styles.fontBold}`
45+
if (fullWidth) buttonClassName += ` ${styles.fullWidth}`
46+
if (selected) buttonClassName += ' ' + commonStyles[`selected-background-color-${color}`]
4647
return (
47-
<button className={className} disabled={disabled} alt={label} {...rest}>
48+
<button className={buttonClassName} disabled={disabled} alt={label} {...rest}>
4849
{platformaticIcon ? <PlatformaticIcon iconName={platformaticIcon.iconName} color={platformaticIcon.color} data-testid='button-icon' onClick={null} /> : null}
4950
<span className={styles.label}>{label}</span>
5051
</button>
@@ -53,9 +54,9 @@ function Button ({
5354

5455
Button.propTypes = {
5556
/**
56-
* Icon
57+
* classes
5758
*/
58-
icon: PropTypes.object,
59+
classes: PropTypes.string,
5960
/**
6061
* label
6162
*/
@@ -106,6 +107,7 @@ Button.propTypes = {
106107
}
107108

108109
Button.defaultProps = {
110+
classes: '',
109111
label: '',
110112
color: MAIN_DARK_BLUE,
111113
backgroundColor: 'transparent',

src/components/Checkbox.jsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
'use strict'
22
import React from 'react'
3+
import PropTypes from 'prop-types'
34
import styles from './Checkbox.module.css'
4-
export default function Checkbox (props) {
5-
const { disabled, ...rest } = props
6-
let className = `${styles.checkbox}`
5+
import { MAIN_DARK_BLUE, WHITE } from './constants'
6+
function Checkbox ({ disabled, color, ...rest }) {
7+
let className = `${styles.checkbox} `
8+
className += styles[`checkbox--${color}`]
79
if (disabled) className += ` ${styles.disabled}`
810
return (
911
<input type='checkbox' className={className} disabled={disabled} {...rest} />
1012
)
1113
}
14+
15+
Checkbox.propTypes = {
16+
/**
17+
* disabled
18+
*/
19+
disabled: PropTypes.bool,
20+
/**
21+
* color
22+
*/
23+
color: PropTypes.oneOf([WHITE, MAIN_DARK_BLUE])
24+
}
25+
26+
Checkbox.defaultProps = {
27+
disabled: false,
28+
color: MAIN_DARK_BLUE
29+
}
30+
31+
export default Checkbox

src/components/Checkbox.module.css

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
.checkbox {
2-
@apply border border-light-green p-2 rounded-sm bg-main-dark-blue relative inline-block h-2 w-2;
2+
@apply border p-2 rounded-sm relative inline-block h-2 w-2;
33
-webkit-appearance: none;
44
}
55

6-
.checkbox:checked {
6+
.checkbox--main-dark-blue {
7+
@apply border-light-green bg-main-dark-blue
8+
}
9+
10+
.checkbox--white {
11+
@apply border-main-dark-blue bg-white
12+
}
13+
14+
.checkbox--white:checked {
15+
@apply bg-main-dark-blue text-white;
16+
}
17+
18+
.checkbox--main-dark-blue:checked {
719
@apply bg-light-green text-main-dark-blue;
820
}
921

src/components/Common.module.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,23 @@
3434
.text--white {
3535
@apply text-white
3636
}
37+
.text--dark-green {
38+
@apply text-dark-green;
39+
}
3740
.text--main-green {
38-
@apply text-main-green
41+
@apply text-main-green;
3942
}
4043
.text--main-dark-blue {
4144
@apply text-main-dark-blue;
4245
}
4346

47+
.text--base {
48+
@apply text-base
49+
}
50+
.text--xs {
51+
@apply text-xs
52+
}
53+
4454
.background-color-main-green {
4555
@apply bg-main-green !important;
4656
}
Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
'use strict'
22
import React from 'react'
3+
import PropTypes from 'prop-types'
4+
import commonStyles from './Common.module.css'
5+
import { DARK_GREEN, MAIN_DARK_BLUE } from './constants'
36
import styles from './HorizontalSeparator.module.css'
4-
export default function HorizontalSeparator ({ marginTop = 4, marginBottom = 4, color = 'dark-green', opacity = 1 }) {
7+
function HorizontalSeparator ({ marginTop, marginBottom, color, opacity }) {
58
function getClassName () {
6-
let className = `text-${color} `
9+
let className = commonStyles[`text--${color}`] + ' '
710
// margin
811
className += (marginTop === marginBottom ? `${styles['marginY-' + marginTop]}` : `${styles['marginT-' + marginTop]} ${styles['marginB-' + marginBottom]}`)
912
// opacity
@@ -13,3 +16,31 @@ export default function HorizontalSeparator ({ marginTop = 4, marginBottom = 4,
1316

1417
return <hr className={getClassName()} />
1518
}
19+
20+
HorizontalSeparator.propTypes = {
21+
/**
22+
* marginTop
23+
*/
24+
marginTop: PropTypes.number,
25+
/**
26+
* marginBottom
27+
*/
28+
marginBottom: PropTypes.number,
29+
/**
30+
* color
31+
*/
32+
color: PropTypes.oneOf([DARK_GREEN, MAIN_DARK_BLUE]),
33+
/**
34+
* opacity
35+
*/
36+
opacity: PropTypes.number
37+
}
38+
39+
HorizontalSeparator.defaultProps = {
40+
marginTop: 4,
41+
marginBottom: 4,
42+
color: DARK_GREEN,
43+
opacity: 1
44+
}
45+
46+
export default HorizontalSeparator

src/components/Sidebar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function Sidebar (props) {
111111
{!collapsed && <span className={styles.item}>{addTitle}</span>}
112112
</button>
113113
</div>
114-
<HorizontalSeparator marginBottom='2' marginTop='2' />
114+
<HorizontalSeparator marginBottom={2} marginTop={2} />
115115

116116
<div className={styles.bottom}>
117117
<Button label={labelButtonSettings} color={WHITE} onClick={onClickSettings} platformaticIcon={{ iconName: 'GearIcon', color: WHITE }} fullWidth bold size={MEDIUM} hoverEffect={BACKGROUND_COLOR_OPAQUE} />

src/components/TextWithLabel.jsx

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
11
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import { FONT_BASE, FONT_XS, MAIN_DARK_BLUE, WHITE } from './constants'
4+
import commonStyles from './Common.module.css'
25
import styles from './TextWithLabel.module.css'
3-
export default function TextWithLabel ({ label, text, children }) {
6+
function TextWithLabel ({ label, text, children, color, fontSize }) {
7+
const className = commonStyles[`text--${color}`] + ' ' + commonStyles[`text--${fontSize}`]
48
return (
5-
<div className={styles.container}>
9+
<div className={className}>
610
<span className={styles.label}>{label}:</span>
711
{text && <span className={styles.text}>{text}</span>}
812
{children && <span>{children}</span>}
913
</div>
1014
)
1115
}
16+
17+
TextWithLabel.propTypes = {
18+
/**
19+
* label
20+
*/
21+
label: PropTypes.string,
22+
/**
23+
* text
24+
*/
25+
text: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
26+
/**
27+
* children
28+
*/
29+
children: PropTypes.node,
30+
/**
31+
* white
32+
*/
33+
color: PropTypes.oneOf([WHITE, MAIN_DARK_BLUE]),
34+
/**
35+
* Font Size
36+
*/
37+
fontSize: PropTypes.oneOf([FONT_BASE, FONT_XS])
38+
}
39+
40+
TextWithLabel.defaultProps = {
41+
label: '',
42+
text: '',
43+
children: null,
44+
color: WHITE,
45+
fontSize: FONT_BASE
46+
}
47+
48+
export default TextWithLabel

src/components/TextWithLabel.module.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
.container {
2-
@apply text-white
3-
}
41
.label {
52
@apply font-thin mr-2;
63
}
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
'use strict'
22
import React from 'react'
3-
export default function VerticalSeparator () {
4-
return <span className='text-dark-green my-auto mx-5'> | </span>
3+
import PropTypes from 'prop-types'
4+
import { DARK_GREEN, MAIN_DARK_BLUE } from './constants'
5+
import commonStyles from './Common.module.css'
6+
7+
function VerticalSeparator ({ color }) {
8+
const className = commonStyles[`text--${color}`] + ' my-auto mx-5'
9+
return <span className={className}> | </span>
510
}
11+
12+
VerticalSeparator.propTypes = {
13+
/**
14+
* color
15+
*/
16+
color: PropTypes.oneOf([DARK_GREEN, MAIN_DARK_BLUE])
17+
}
18+
19+
VerticalSeparator.defaultProps = {
20+
color: DARK_GREEN
21+
}
22+
23+
export default VerticalSeparator

src/components/constants.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const WHITE = 'white'
22
export const MAIN_DARK_BLUE = 'main-dark-blue'
3+
export const DARK_GREEN = 'dark-green'
34
export const MAIN_GREEN = 'main-green'
45
export const ERROR_RED = 'error-red'
56
export const WARNING_YELLOW = 'warning-yellow'
@@ -20,7 +21,7 @@ export const MODAL_SIZES = [SMALL, MEDIUM, FULL_WIDTH]
2021

2122
export const COLORS_ICON = [MAIN_GREEN, WHITE, MAIN_DARK_BLUE, ERROR_RED, WARNING_YELLOW]
2223
export const COLORS_BUTTON = [MAIN_GREEN, 'dark-green', 'light-green', MAIN_DARK_BLUE, 'dark-blue', 'light-blue', WHITE, ERROR_RED, 'tertiary-blue', 'transparent']
23-
export const COLORS_BORDERED_BOX = [MAIN_GREEN, ERROR_RED, WHITE, 'dark-blue', WARNING_YELLOW, 'transparent']
24+
export const COLORS_BORDERED_BOX = [MAIN_GREEN, ERROR_RED, WHITE, 'dark-blue', MAIN_DARK_BLUE, WARNING_YELLOW, 'transparent']
2425

2526
export const MODAL_POPUP = 'popup'
2627
export const MODAL_COVER = 'cover'
@@ -29,3 +30,10 @@ export const MODAL_LAYOUTS = [MODAL_POPUP, MODAL_COVER]
2930
export const FREE = 'free'
3031
export const BASIC = 'basic'
3132
export const PROFILE = ['', FREE, BASIC]
33+
34+
export const FONT_BASE = 'base'
35+
export const FONT_XS = 'xs'
36+
37+
export const ROLE_ADMIN = 'admin'
38+
export const ROLE_USER = 'user'
39+
export const ROLE_OWNER = 'owner'

0 commit comments

Comments
 (0)