@platformatic/ui-components 0.7.35 → 0.8.0

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@platformatic/ui-components",
3
3
  "description": "Platformatic UI Components",
4
- "version": "0.7.35",
4
+ "version": "0.8.0",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -37,6 +37,7 @@ function Button ({
37
37
  ...rest
38
38
  }) {
39
39
  let buttonClassName = textClass
40
+ let tmpBorderedClassName = ''
40
41
  buttonClassName += ` ${styles.button} ${styles['color-' + color]} `
41
42
  let contentClassName = `${styles.content} `
42
43
  if (paddingClass) {
@@ -45,10 +46,10 @@ function Button ({
45
46
  contentClassName += `${styles['button-' + size]} `
46
47
  }
47
48
  if (disabled) {
48
- buttonClassName += ' ' + commonStyles[`bordered--${color}-30`]
49
+ tmpBorderedClassName = commonStyles[`bordered--${color}-30`]
49
50
  buttonClassName += ` ${styles.disabled}`
50
51
  } else {
51
- buttonClassName += bordered ? commonStyles[`bordered--${color}-100`] : ''
52
+ tmpBorderedClassName = bordered ? commonStyles[`bordered--${color}-70`] : ''
52
53
  }
53
54
  if (!bordered) buttonClassName += ` ${styles['no-border']}`
54
55
  if (fullWidth) {
@@ -58,10 +59,14 @@ function Button ({
58
59
  const [hover, setHover] = useState(false)
59
60
  const [inactive, setInactive] = useState(false)
60
61
  const [backgroundClassName, setBackgroundClassName] = useState(restClassName())
62
+ const [borderedClassName, setBorderedClassName] = useState(tmpBorderedClassName)
61
63
 
62
64
  useEffect(() => {
63
65
  if (!disabled) {
64
66
  if (hover) {
67
+ if (bordered) {
68
+ setBorderedClassName(commonStyles[`bordered--${color}-100`])
69
+ }
65
70
  switch (hoverEffect) {
66
71
  case DULLS_BACKGROUND_COLOR:
67
72
  setBackgroundClassName(restClassName() + ' ' + commonStyles[`hover-${DULLS_BACKGROUND_COLOR}-${color}`])
@@ -89,6 +94,13 @@ function Button ({
89
94
  } else {
90
95
  setBackgroundClassName(restClassName())
91
96
  }
97
+ if (bordered) {
98
+ setBorderedClassName(commonStyles[`bordered--${color}-70`])
99
+ }
100
+ }
101
+ } else {
102
+ if (bordered) {
103
+ setBorderedClassName(commonStyles[`bordered--${color}-30`])
92
104
  }
93
105
  }
94
106
  }, [disabled, hover, hoverEffect])
@@ -101,7 +113,7 @@ function Button ({
101
113
  }
102
114
 
103
115
  return (
104
- <button className={`${buttonClassName} ${restClassName()}`} disabled={disabled} alt={label} {...rest} onMouseLeave={() => setHover(false)} onMouseOver={() => setHover(true)}>
116
+ <button className={`${buttonClassName} ${restClassName()} ${borderedClassName}`} disabled={disabled} alt={label} {...rest} onMouseLeave={() => setHover(false)} onMouseOver={() => setHover(true)}>
105
117
  <div className={`${contentClassName} ${backgroundClassName}`}>
106
118
  {platformaticIcon ? <PlatformaticIcon key='left' iconName={platformaticIcon.iconName} color={platformaticIcon.color} data-testid='button-icon' onClick={null} inactive={inactive} /> : null}
107
119
  <span className={styles.label}>{label}</span>