@veracity/vui 2.5.0-beta.0 → 2.5.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.
Files changed (271) hide show
  1. package/dist/cjs/checkbox/checkbox.d.ts.map +1 -1
  2. package/dist/cjs/checkbox/checkbox.js +5 -5
  3. package/dist/cjs/checkbox/checkbox.types.d.ts +1 -1
  4. package/dist/cjs/checkbox/checkbox.types.d.ts.map +1 -1
  5. package/dist/cjs/checkbox/checkboxGroup.d.ts.map +1 -1
  6. package/dist/cjs/checkbox/checkboxGroup.js +2 -2
  7. package/dist/cjs/checkbox/checkboxGroup.types.d.ts +1 -1
  8. package/dist/cjs/checkbox/checkboxGroup.types.d.ts.map +1 -1
  9. package/dist/cjs/checkbox/consts.d.ts +6 -0
  10. package/dist/cjs/checkbox/consts.d.ts.map +1 -0
  11. package/dist/cjs/checkbox/consts.js +8 -0
  12. package/dist/cjs/checkbox/theme.d.ts +7 -13
  13. package/dist/cjs/checkbox/theme.d.ts.map +1 -1
  14. package/dist/cjs/checkbox/theme.js +8 -19
  15. package/dist/cjs/core/consts.d.ts +1 -0
  16. package/dist/cjs/core/consts.d.ts.map +1 -1
  17. package/dist/cjs/core/consts.js +2 -1
  18. package/dist/cjs/core/vuiProvider/fontFaces.d.ts.map +1 -1
  19. package/dist/cjs/core/vuiProvider/fontFaces.js +44 -4
  20. package/dist/cjs/core/vuiProvider/globalStyle.d.ts.map +1 -1
  21. package/dist/cjs/core/vuiProvider/globalStyle.js +5 -2
  22. package/dist/cjs/icons/baseIcons/fal/falClockRotateLeft.d.ts +4 -0
  23. package/dist/cjs/icons/baseIcons/fal/falClockRotateLeft.d.ts.map +1 -0
  24. package/dist/cjs/icons/baseIcons/fal/falClockRotateLeft.js +7 -0
  25. package/dist/cjs/icons/baseIcons/icons.d.ts +1 -0
  26. package/dist/cjs/icons/baseIcons/icons.d.ts.map +1 -1
  27. package/dist/cjs/icons/baseIcons/icons.js +7 -5
  28. package/dist/cjs/icons/baseIcons/types.d.ts +1 -1
  29. package/dist/cjs/icons/baseIcons/types.d.ts.map +1 -1
  30. package/dist/cjs/index.d.ts +1 -0
  31. package/dist/cjs/index.d.ts.map +1 -1
  32. package/dist/cjs/index.js +1 -0
  33. package/dist/cjs/input/inputInput.d.ts.map +1 -1
  34. package/dist/cjs/input/inputInput.js +0 -5
  35. package/dist/cjs/panel/theme.js +1 -1
  36. package/dist/cjs/progress/progress.d.ts +1 -1
  37. package/dist/cjs/progress/progress.d.ts.map +1 -1
  38. package/dist/cjs/progress/progress.js +10 -7
  39. package/dist/cjs/progress/progress.types.d.ts +0 -1
  40. package/dist/cjs/progress/progress.types.d.ts.map +1 -1
  41. package/dist/cjs/progress/theme.d.ts +15 -1
  42. package/dist/cjs/progress/theme.d.ts.map +1 -1
  43. package/dist/cjs/progress/theme.js +16 -2
  44. package/dist/cjs/progressCircular/consts.d.ts +12 -0
  45. package/dist/cjs/progressCircular/consts.d.ts.map +1 -0
  46. package/dist/cjs/progressCircular/consts.js +14 -0
  47. package/dist/cjs/progressCircular/index.d.ts +4 -0
  48. package/dist/cjs/progressCircular/index.d.ts.map +1 -0
  49. package/dist/cjs/progressCircular/index.js +24 -0
  50. package/dist/cjs/progressCircular/progressCircular.d.ts +6 -0
  51. package/dist/cjs/progressCircular/progressCircular.d.ts.map +1 -0
  52. package/dist/cjs/progressCircular/progressCircular.js +82 -0
  53. package/dist/cjs/progressCircular/progressCircular.types.d.ts +8 -0
  54. package/dist/cjs/progressCircular/progressCircular.types.d.ts.map +1 -0
  55. package/dist/cjs/progressCircular/progressCircular.types.js +2 -0
  56. package/dist/cjs/progressCircular/theme.d.ts +57 -0
  57. package/dist/cjs/progressCircular/theme.d.ts.map +1 -0
  58. package/dist/cjs/progressCircular/theme.js +47 -0
  59. package/dist/cjs/radio/consts.d.ts +6 -0
  60. package/dist/cjs/radio/consts.d.ts.map +1 -0
  61. package/dist/cjs/radio/consts.js +8 -0
  62. package/dist/cjs/radio/radio.d.ts.map +1 -1
  63. package/dist/cjs/radio/radio.js +5 -4
  64. package/dist/cjs/radio/radio.types.d.ts +1 -1
  65. package/dist/cjs/radio/radio.types.d.ts.map +1 -1
  66. package/dist/cjs/radio/radioGroup.d.ts.map +1 -1
  67. package/dist/cjs/radio/radioGroup.js +2 -3
  68. package/dist/cjs/radio/radioGroup.types.d.ts +1 -1
  69. package/dist/cjs/radio/radioGroup.types.d.ts.map +1 -1
  70. package/dist/cjs/radio/theme.d.ts +7 -13
  71. package/dist/cjs/radio/theme.d.ts.map +1 -1
  72. package/dist/cjs/radio/theme.js +8 -19
  73. package/dist/cjs/switch/consts.d.ts +9 -0
  74. package/dist/cjs/switch/consts.d.ts.map +1 -0
  75. package/dist/cjs/switch/consts.js +11 -0
  76. package/dist/cjs/switch/switch.types.d.ts +2 -2
  77. package/dist/cjs/switch/switch.types.d.ts.map +1 -1
  78. package/dist/cjs/switch/switchButton.d.ts.map +1 -1
  79. package/dist/cjs/switch/switchButton.js +19 -21
  80. package/dist/cjs/switch/switchMain.d.ts.map +1 -1
  81. package/dist/cjs/switch/switchMain.js +2 -3
  82. package/dist/cjs/switch/theme.d.ts +30 -14
  83. package/dist/cjs/switch/theme.d.ts.map +1 -1
  84. package/dist/cjs/switch/theme.js +33 -17
  85. package/dist/cjs/textarea/textarea.d.ts.map +1 -1
  86. package/dist/cjs/textarea/textarea.js +8 -17
  87. package/dist/cjs/textarea/textarea.types.d.ts +2 -2
  88. package/dist/cjs/textarea/textarea.types.d.ts.map +1 -1
  89. package/dist/cjs/textarea/theme.d.ts +29 -12
  90. package/dist/cjs/textarea/theme.d.ts.map +1 -1
  91. package/dist/cjs/textarea/theme.js +28 -17
  92. package/dist/cjs/theme/components.d.ts +132 -34
  93. package/dist/cjs/theme/components.d.ts.map +1 -1
  94. package/dist/cjs/theme/components.js +26 -24
  95. package/dist/cjs/theme/defaultTheme.d.ts +132 -34
  96. package/dist/cjs/theme/defaultTheme.d.ts.map +1 -1
  97. package/dist/cjs/tutorial/consts.d.ts +6 -0
  98. package/dist/cjs/tutorial/consts.d.ts.map +1 -0
  99. package/dist/cjs/tutorial/consts.js +8 -0
  100. package/dist/cjs/tutorial/tutorial.d.ts +1 -1
  101. package/dist/cjs/tutorial/tutorial.d.ts.map +1 -1
  102. package/dist/cjs/tutorial/tutorial.js +2 -2
  103. package/dist/cjs/tutorial/tutorial.types.d.ts +20 -12
  104. package/dist/cjs/tutorial/tutorial.types.d.ts.map +1 -1
  105. package/dist/cjs/tutorial/tutorialCard.d.ts +1 -1
  106. package/dist/cjs/tutorial/tutorialCard.d.ts.map +1 -1
  107. package/dist/cjs/tutorial/tutorialCard.js +19 -18
  108. package/dist/cjs/tutorial/tutorialStep.d.ts +1 -1
  109. package/dist/cjs/tutorial/tutorialStep.d.ts.map +1 -1
  110. package/dist/cjs/tutorial/tutorialStep.js +4 -5
  111. package/dist/esm/checkbox/checkbox.d.ts.map +1 -1
  112. package/dist/esm/checkbox/checkbox.js +5 -5
  113. package/dist/esm/checkbox/checkbox.types.d.ts +1 -1
  114. package/dist/esm/checkbox/checkbox.types.d.ts.map +1 -1
  115. package/dist/esm/checkbox/checkboxGroup.d.ts.map +1 -1
  116. package/dist/esm/checkbox/checkboxGroup.js +2 -2
  117. package/dist/esm/checkbox/checkboxGroup.types.d.ts +1 -1
  118. package/dist/esm/checkbox/checkboxGroup.types.d.ts.map +1 -1
  119. package/dist/esm/checkbox/consts.d.ts +6 -0
  120. package/dist/esm/checkbox/consts.d.ts.map +1 -0
  121. package/dist/esm/checkbox/consts.js +5 -0
  122. package/dist/esm/checkbox/theme.d.ts +7 -13
  123. package/dist/esm/checkbox/theme.d.ts.map +1 -1
  124. package/dist/esm/checkbox/theme.js +8 -19
  125. package/dist/esm/core/consts.d.ts +1 -0
  126. package/dist/esm/core/consts.d.ts.map +1 -1
  127. package/dist/esm/core/consts.js +1 -0
  128. package/dist/esm/core/vuiProvider/fontFaces.d.ts.map +1 -1
  129. package/dist/esm/core/vuiProvider/fontFaces.js +45 -5
  130. package/dist/esm/core/vuiProvider/globalStyle.d.ts.map +1 -1
  131. package/dist/esm/core/vuiProvider/globalStyle.js +5 -2
  132. package/dist/esm/icons/baseIcons/fal/falClockRotateLeft.d.ts +4 -0
  133. package/dist/esm/icons/baseIcons/fal/falClockRotateLeft.d.ts.map +1 -0
  134. package/dist/esm/icons/baseIcons/fal/falClockRotateLeft.js +5 -0
  135. package/dist/esm/icons/baseIcons/icons.d.ts +1 -0
  136. package/dist/esm/icons/baseIcons/icons.d.ts.map +1 -1
  137. package/dist/esm/icons/baseIcons/icons.js +1 -0
  138. package/dist/esm/icons/baseIcons/types.d.ts +1 -1
  139. package/dist/esm/icons/baseIcons/types.d.ts.map +1 -1
  140. package/dist/esm/index.d.ts +1 -0
  141. package/dist/esm/index.d.ts.map +1 -1
  142. package/dist/esm/index.js +1 -0
  143. package/dist/esm/input/inputInput.d.ts.map +1 -1
  144. package/dist/esm/input/inputInput.js +0 -5
  145. package/dist/esm/panel/theme.js +1 -1
  146. package/dist/esm/progress/progress.d.ts +1 -1
  147. package/dist/esm/progress/progress.d.ts.map +1 -1
  148. package/dist/esm/progress/progress.js +10 -7
  149. package/dist/esm/progress/progress.types.d.ts +0 -1
  150. package/dist/esm/progress/progress.types.d.ts.map +1 -1
  151. package/dist/esm/progress/theme.d.ts +15 -1
  152. package/dist/esm/progress/theme.d.ts.map +1 -1
  153. package/dist/esm/progress/theme.js +16 -2
  154. package/dist/esm/progressCircular/consts.d.ts +12 -0
  155. package/dist/esm/progressCircular/consts.d.ts.map +1 -0
  156. package/dist/esm/progressCircular/consts.js +11 -0
  157. package/dist/esm/progressCircular/index.d.ts +4 -0
  158. package/dist/esm/progressCircular/index.d.ts.map +1 -0
  159. package/dist/esm/progressCircular/index.js +3 -0
  160. package/dist/esm/progressCircular/progressCircular.d.ts +6 -0
  161. package/dist/esm/progressCircular/progressCircular.d.ts.map +1 -0
  162. package/dist/esm/progressCircular/progressCircular.js +45 -0
  163. package/dist/esm/progressCircular/progressCircular.types.d.ts +8 -0
  164. package/dist/esm/progressCircular/progressCircular.types.d.ts.map +1 -0
  165. package/dist/esm/progressCircular/progressCircular.types.js +1 -0
  166. package/dist/esm/progressCircular/theme.d.ts +57 -0
  167. package/dist/esm/progressCircular/theme.d.ts.map +1 -0
  168. package/dist/esm/progressCircular/theme.js +45 -0
  169. package/dist/esm/radio/consts.d.ts +6 -0
  170. package/dist/esm/radio/consts.d.ts.map +1 -0
  171. package/dist/esm/radio/consts.js +5 -0
  172. package/dist/esm/radio/radio.d.ts.map +1 -1
  173. package/dist/esm/radio/radio.js +5 -4
  174. package/dist/esm/radio/radio.types.d.ts +1 -1
  175. package/dist/esm/radio/radio.types.d.ts.map +1 -1
  176. package/dist/esm/radio/radioGroup.d.ts.map +1 -1
  177. package/dist/esm/radio/radioGroup.js +2 -3
  178. package/dist/esm/radio/radioGroup.types.d.ts +1 -1
  179. package/dist/esm/radio/radioGroup.types.d.ts.map +1 -1
  180. package/dist/esm/radio/theme.d.ts +7 -13
  181. package/dist/esm/radio/theme.d.ts.map +1 -1
  182. package/dist/esm/radio/theme.js +8 -19
  183. package/dist/esm/switch/consts.d.ts +9 -0
  184. package/dist/esm/switch/consts.d.ts.map +1 -0
  185. package/dist/esm/switch/consts.js +8 -0
  186. package/dist/esm/switch/switch.types.d.ts +2 -2
  187. package/dist/esm/switch/switch.types.d.ts.map +1 -1
  188. package/dist/esm/switch/switchButton.d.ts.map +1 -1
  189. package/dist/esm/switch/switchButton.js +19 -21
  190. package/dist/esm/switch/switchMain.d.ts.map +1 -1
  191. package/dist/esm/switch/switchMain.js +2 -3
  192. package/dist/esm/switch/theme.d.ts +30 -14
  193. package/dist/esm/switch/theme.d.ts.map +1 -1
  194. package/dist/esm/switch/theme.js +33 -17
  195. package/dist/esm/textarea/textarea.d.ts.map +1 -1
  196. package/dist/esm/textarea/textarea.js +8 -17
  197. package/dist/esm/textarea/textarea.types.d.ts +2 -2
  198. package/dist/esm/textarea/textarea.types.d.ts.map +1 -1
  199. package/dist/esm/textarea/theme.d.ts +29 -12
  200. package/dist/esm/textarea/theme.d.ts.map +1 -1
  201. package/dist/esm/textarea/theme.js +28 -17
  202. package/dist/esm/theme/components.d.ts +132 -34
  203. package/dist/esm/theme/components.d.ts.map +1 -1
  204. package/dist/esm/theme/components.js +2 -0
  205. package/dist/esm/theme/defaultTheme.d.ts +132 -34
  206. package/dist/esm/theme/defaultTheme.d.ts.map +1 -1
  207. package/dist/esm/tutorial/consts.d.ts +6 -0
  208. package/dist/esm/tutorial/consts.d.ts.map +1 -0
  209. package/dist/esm/tutorial/consts.js +5 -0
  210. package/dist/esm/tutorial/tutorial.d.ts +1 -1
  211. package/dist/esm/tutorial/tutorial.d.ts.map +1 -1
  212. package/dist/esm/tutorial/tutorial.js +2 -2
  213. package/dist/esm/tutorial/tutorial.types.d.ts +20 -12
  214. package/dist/esm/tutorial/tutorial.types.d.ts.map +1 -1
  215. package/dist/esm/tutorial/tutorialCard.d.ts +1 -1
  216. package/dist/esm/tutorial/tutorialCard.d.ts.map +1 -1
  217. package/dist/esm/tutorial/tutorialCard.js +20 -19
  218. package/dist/esm/tutorial/tutorialStep.d.ts +1 -1
  219. package/dist/esm/tutorial/tutorialStep.d.ts.map +1 -1
  220. package/dist/esm/tutorial/tutorialStep.js +5 -6
  221. package/package.json +1 -1
  222. package/src/checkbox/checkbox.tsx +5 -5
  223. package/src/checkbox/checkbox.types.ts +1 -1
  224. package/src/checkbox/checkboxGroup.tsx +3 -16
  225. package/src/checkbox/checkboxGroup.types.ts +1 -1
  226. package/src/checkbox/consts.ts +5 -0
  227. package/src/checkbox/theme.ts +7 -23
  228. package/src/core/consts.ts +1 -0
  229. package/src/core/vuiProvider/fontFaces.ts +46 -5
  230. package/src/core/vuiProvider/globalStyle.tsx +5 -2
  231. package/src/icons/baseIcons/fal/falClockRotateLeft.ts +8 -0
  232. package/src/icons/baseIcons/icons.ts +1 -0
  233. package/src/icons/baseIcons/types.ts +1 -0
  234. package/src/index.ts +1 -0
  235. package/src/input/inputInput.tsx +0 -5
  236. package/src/panel/theme.ts +1 -1
  237. package/src/progress/progress.tsx +11 -7
  238. package/src/progress/progress.types.ts +0 -1
  239. package/src/progress/theme.ts +16 -2
  240. package/src/progressCircular/consts.ts +13 -0
  241. package/src/progressCircular/index.ts +3 -0
  242. package/src/progressCircular/progressCircular.tsx +89 -0
  243. package/src/progressCircular/progressCircular.types.ts +9 -0
  244. package/src/progressCircular/theme.ts +50 -0
  245. package/src/radio/consts.ts +5 -0
  246. package/src/radio/radio.tsx +5 -5
  247. package/src/radio/radio.types.ts +1 -1
  248. package/src/radio/radioGroup.tsx +3 -17
  249. package/src/radio/radioGroup.types.ts +1 -1
  250. package/src/radio/theme.ts +7 -23
  251. package/src/switch/consts.ts +8 -0
  252. package/src/switch/switch.types.ts +2 -2
  253. package/src/switch/switchButton.tsx +20 -20
  254. package/src/switch/switchMain.tsx +1 -3
  255. package/src/switch/theme.ts +34 -22
  256. package/src/textarea/textarea.tsx +7 -17
  257. package/src/textarea/textarea.types.ts +2 -2
  258. package/src/textarea/theme.ts +28 -23
  259. package/src/theme/components.ts +2 -0
  260. package/src/tutorial/consts.ts +5 -0
  261. package/src/tutorial/tutorial.tsx +7 -5
  262. package/src/tutorial/tutorial.types.ts +20 -12
  263. package/src/tutorial/tutorialCard.tsx +71 -80
  264. package/src/tutorial/tutorialStep.tsx +5 -11
  265. package/dist/cjs/textarea/consts.d.ts +0 -4
  266. package/dist/cjs/textarea/consts.d.ts.map +0 -1
  267. package/dist/cjs/textarea/consts.js +0 -6
  268. package/dist/esm/textarea/consts.d.ts +0 -4
  269. package/dist/esm/textarea/consts.d.ts.map +0 -1
  270. package/dist/esm/textarea/consts.js +0 -3
  271. package/src/textarea/consts.ts +0 -3
@@ -0,0 +1,89 @@
1
+ import React, { useEffect, useState } from 'react'
2
+
3
+ import { Box, BoxProps } from '../box'
4
+ import { styled, useStyleConfig, vui } from '../core'
5
+ import { T } from '../t'
6
+ import { cs } from '../utils'
7
+ import { absCenterStyles, labelBottom, maxValue } from './consts'
8
+ import { ProgressCircularProps } from './progressCircular.types'
9
+
10
+ export const ProgressCircularBase = styled.divBox`
11
+ display: flex;
12
+ position: relative;
13
+ width: 100%;
14
+ `
15
+ const MainCircle = styled.circle`
16
+ fill: transparent;
17
+ `
18
+
19
+ const ProgressCircle = styled(MainCircle)`
20
+ transform: rotate(-90deg);
21
+ transform-origin: 50% 50%;
22
+ transition: stroke-dashoffset 0.5s ease-out;
23
+ `
24
+
25
+ /** [Beta] Indicates a process progress. */
26
+ export const ProgressCircular = vui<'div', ProgressCircularProps>((props, ref) => {
27
+ const { children, className, label, value = 0, showPercentage, ...rest } = props
28
+
29
+ const styles = useStyleConfig('ProgressCircular', props)
30
+
31
+ const [progress, setProgress] = useState(value)
32
+
33
+ useEffect(() => {
34
+ setProgress(value ? Math.ceil(value) : 0)
35
+ }, [value])
36
+
37
+ useEffect(() => {
38
+ const w = !value ? 0 : Math.ceil(value)
39
+ setProgress(w > maxValue ? maxValue : w)
40
+ }, [value])
41
+
42
+ const radius = maxValue / 2 - styles.strokeWidth * 2
43
+ const angle = radius * 2 * Math.PI
44
+ const offset = angle - (progress / maxValue) * angle
45
+
46
+ return (
47
+ <ProgressCircularBase className={cs('vui-progress-circular', className)} ref={ref} w={styles.width} {...rest}>
48
+ <svg
49
+ aria-valuemax={maxValue}
50
+ aria-valuemin={0}
51
+ aria-valuenow={progress}
52
+ height={styles.width}
53
+ version="1.1"
54
+ viewBox="0 0 100 100"
55
+ width={styles.width}
56
+ xmlns="http://www.w3.org/2000/svg"
57
+ >
58
+ <MainCircle cx="50" cy="50" r={radius} stroke={styles.stroke.main} strokeWidth={styles.strokeWidth} />
59
+ <ProgressCircle
60
+ cx="50"
61
+ cy="50"
62
+ r={radius}
63
+ stroke={styles.stroke.progress}
64
+ strokeDasharray={`${angle} ${angle}`}
65
+ strokeDashoffset={offset}
66
+ strokeWidth={styles.strokeWidth}
67
+ />
68
+ </svg>
69
+ <Box {...(absCenterStyles as BoxProps)} top={styles.top}>
70
+ {children ? (
71
+ children
72
+ ) : showPercentage ? (
73
+ <T color={styles.color} fontSize={styles.fontSize}>
74
+ {progress}%
75
+ </T>
76
+ ) : null}
77
+ </Box>
78
+ {!!label && (
79
+ <Box {...(absCenterStyles as BoxProps)} bottom={labelBottom}>
80
+ <T color={styles.color} fontSize={styles.fontSize}>
81
+ {label}
82
+ </T>
83
+ </Box>
84
+ )}
85
+ </ProgressCircularBase>
86
+ )
87
+ })
88
+
89
+ export default ProgressCircular
@@ -0,0 +1,9 @@
1
+ import { SystemProps } from '../system'
2
+ import { ThemingProps } from '../theme'
3
+
4
+ export type ProgressCircularProps = SystemProps &
5
+ ThemingProps<'ProgressCircular'> & {
6
+ label?: string
7
+ value?: number
8
+ showPercentage?: boolean
9
+ }
@@ -0,0 +1,50 @@
1
+ import { darkBlue, energyRed, landGreen } from '../theme/foundations/colors'
2
+
3
+ const baseStyle = {
4
+ color: 'darkBlue.main'
5
+ }
6
+
7
+ const defaultProps = {
8
+ size: 'md',
9
+ variant: 'primary'
10
+ }
11
+
12
+ const sizes = {
13
+ sm: {
14
+ strokeWidth: 4,
15
+ width: 46,
16
+ top: 15,
17
+ fontSize: 12
18
+ },
19
+ md: { strokeWidth: 5, width: 80, top: 30, fontSize: 16 },
20
+ lg: { strokeWidth: 6, width: 120, top: 48, fontSize: 18 },
21
+ xl: { strokeWidth: 7, width: 160, top: 64, fontSize: 22 }
22
+ }
23
+
24
+ const variants = {
25
+ primary: {
26
+ stroke: {
27
+ main: darkBlue[95],
28
+ progress: darkBlue.main
29
+ }
30
+ },
31
+ green: {
32
+ stroke: {
33
+ main: landGreen[95],
34
+ progress: landGreen.main
35
+ }
36
+ },
37
+ red: {
38
+ stroke: {
39
+ main: energyRed[95],
40
+ progress: energyRed.main
41
+ }
42
+ }
43
+ }
44
+
45
+ export default {
46
+ baseStyle,
47
+ defaultProps,
48
+ sizes,
49
+ variants
50
+ }
@@ -0,0 +1,5 @@
1
+ export const radioColors = {
2
+ main: 'seaBlue.main',
3
+ hover: 'seaBlue.40',
4
+ disabled: 'sandstone.main'
5
+ }
@@ -4,6 +4,7 @@ import { omitThemingProps, styled, th, useStyleConfig, vui } from '../core'
4
4
  import Icon from '../icon'
5
5
  import T from '../t'
6
6
  import { ChangeEvent, cs, filterUndefined } from '../utils'
7
+ import { radioColors } from './consts'
7
8
  import { useRadioGroupContext } from './context'
8
9
  import { RadioProps, RadioStyleProps } from './radio.types'
9
10
 
@@ -39,11 +40,11 @@ export const RadioBase = styled.labelBox<RadioStyleProps>`
39
40
  }
40
41
 
41
42
  &[aria-disabled='true'] {
42
- color: disabled.color;
43
+ color: ${radioColors.disabled};
43
44
  cursor: not-allowed;
44
45
 
45
46
  .vui-radioControl {
46
- color: disabled.color;
47
+ color: ${radioColors.disabled};
47
48
  }
48
49
  }
49
50
  `
@@ -87,8 +88,8 @@ export const Radio = vui<'span', RadioProps>((props, ref) => {
87
88
 
88
89
  const icon = isChecked ? iconChecked : iconProp
89
90
  const controlMr = children || label ? 1 : 0
90
- const color = isChecked ? controlColor : 'grey.60'
91
- const controlHoverColor = isChecked ? hoverColor : 'grey.90'
91
+ const color = controlColor ? controlColor : radioColors.main
92
+ const controlHoverColor = hoverColor ? hoverColor : radioColors.hover
92
93
 
93
94
  useEffect(() => {
94
95
  if (groupIsChecked !== undefined) {
@@ -132,7 +133,6 @@ export const Radio = vui<'span', RadioProps>((props, ref) => {
132
133
  {...{ checked, defaultChecked, disabled, id, name, required, value }}
133
134
  {...inputProps}
134
135
  />
135
-
136
136
  <Icon className="vui-radioIcon" h="100%" name={icon} w="100%" />
137
137
  </RadioControl>
138
138
 
@@ -9,7 +9,7 @@ export type RadioProps = SystemProps &
9
9
  ThemingProps<'Radio'> & {
10
10
  /** Provides value to radio in controlled mode. */
11
11
  checked?: boolean
12
- /** Available theme colors for this component. @default blue */
12
+ /** Deprecated. Please use variant instead. @deprecated */
13
13
  colorScheme?: 'blue' | 'prussian'
14
14
  /** Disables radio and related elements with the right styling. */
15
15
  disabled?: boolean
@@ -16,21 +16,8 @@ export const RadioGroupBase = styled.divBox`
16
16
  * Exposes some props to the children via context.
17
17
  */
18
18
  export const RadioGroup = vui<'div', RadioGroupProps>((props, ref) => {
19
- const {
20
- className,
21
- colorScheme,
22
- defaultValue,
23
- disabled,
24
- isRow,
25
- name,
26
- onBlur,
27
- onChange,
28
- onFocus,
29
- size,
30
- value,
31
- variant,
32
- ...rest
33
- } = props
19
+ const { className, defaultValue, disabled, isRow, name, onBlur, onChange, onFocus, size, value, variant, ...rest } =
20
+ props
34
21
  const [isChecked, setIsChecked] = useState(value ?? defaultValue)
35
22
 
36
23
  const handleOnChange = useCallback(
@@ -44,7 +31,6 @@ export const RadioGroup = vui<'div', RadioGroupProps>((props, ref) => {
44
31
  const context = useMemo(
45
32
  () =>
46
33
  filterUndefined({
47
- colorScheme,
48
34
  defaultValue,
49
35
  disabled,
50
36
  isChecked,
@@ -56,7 +42,7 @@ export const RadioGroup = vui<'div', RadioGroupProps>((props, ref) => {
56
42
  value,
57
43
  variant
58
44
  }),
59
- [colorScheme, defaultValue, disabled, handleOnChange, isChecked, name, onBlur, onFocus, size, value, variant]
45
+ [defaultValue, disabled, handleOnChange, isChecked, name, onBlur, onFocus, size, value, variant]
60
46
  )
61
47
 
62
48
  const aliasedProps = filterUndefined({
@@ -4,7 +4,7 @@ import { ChangeEventHandler, FocusEventHandler } from '../utils'
4
4
 
5
5
  export type RadioGroupProps = SystemProps &
6
6
  ThemingProps<'Radio'> & {
7
- /** Available theme colors for this component. */
7
+ /** Deprecated. Please use variant instead. @deprecated */
8
8
  colorScheme?: 'blue' | 'prussian'
9
9
  /** Passes the prop to each radio. */
10
10
  disabled?: boolean
@@ -1,28 +1,14 @@
1
- import { Dict } from '../utils'
1
+ import { radioColors } from './consts'
2
2
 
3
- function variantDefault(props: Dict) {
4
- const { colorScheme: c } = props
5
-
6
- const control = {
7
- color: `${c}.80`,
8
- hoverColor: `${c}.90`
9
- }
10
-
11
- if (c === 'prussian') {
12
- control.hoverColor = 'prussian.70'
13
- }
14
-
15
- return {
16
- control
3
+ const baseStyle = {
4
+ control: {
5
+ color: radioColors.main,
6
+ hoverColor: radioColors.hover
17
7
  }
18
8
  }
19
9
 
20
- const baseStyle = {}
21
-
22
10
  const defaultProps = {
23
- colorScheme: 'blue',
24
- size: 'md',
25
- variant: 'default'
11
+ size: 'md'
26
12
  }
27
13
 
28
14
  const parts = ['container', 'control', 'label']
@@ -57,9 +43,7 @@ const sizes = {
57
43
  }
58
44
  }
59
45
 
60
- const variants = {
61
- default: variantDefault
62
- }
46
+ const variants = {}
63
47
 
64
48
  export default {
65
49
  baseStyle,
@@ -0,0 +1,8 @@
1
+ export const switchColors = {
2
+ main: 'seaBlue.main',
3
+ hover: 'seaBlue.40',
4
+ disabled: 'sandstone.main',
5
+ disabledBg: 'sandstone.95',
6
+ green: 'landGreen.main',
7
+ red: 'energyRed.main'
8
+ }
@@ -8,7 +8,7 @@ export type SwitchButtonProps = SystemProps &
8
8
  ThemingProps<'Switch'> & {
9
9
  /** Provides value to switch in controlled mode. */
10
10
  checked?: boolean
11
- /** Available theme colors for this component. */
11
+ /** Deprecated. Please use variant instead. @deprecated */
12
12
  colorScheme?: 'blue' | 'green' | 'prussian'
13
13
  /** Disables switch and related elements with the right styling. */
14
14
  disabled?: boolean
@@ -57,7 +57,7 @@ export type SwitchProps = SystemProps &
57
57
  button?: ReactNode
58
58
  /** Provides value to switch button in controlled mode. */
59
59
  checked?: boolean
60
- /** Available theme colors for this component. @default blue */
60
+ /** Deprecated. Please use variant instead. @deprecated */
61
61
  colorScheme?: 'blue' | 'green' | 'prussian'
62
62
  /** Disables switch and related elements with the right styling. */
63
63
  disabled?: boolean
@@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState } from 'react'
2
2
 
3
3
  import { omitThemingProps, styled, useStyleConfig, vui } from '../core'
4
4
  import { ChangeEvent, cs, filterUndefined, FocusEvent } from '../utils'
5
+ import { switchColors } from './consts'
5
6
  import { useSwitchContext } from './context'
6
7
  import { SwitchButtonProps } from './switch.types'
7
8
 
@@ -18,43 +19,41 @@ const SwitchInput = styled.inputBox`
18
19
  z-index: 1;
19
20
  `
20
21
 
21
- /** Circular element that moves along the track when toggled. */
22
- const SwitchThumb = styled.spanBox`
23
- border-radius: round;
22
+ const SwitchFoundation = styled.spanBox`
23
+ border-radius: 100px;
24
24
  display: inline-flex;
25
25
  flex-shrink: 0;
26
- position: absolute;
27
26
  transition-duration: fast;
27
+ position: relative;
28
+ `
29
+
30
+ /** Circular element that moves along the track when toggled. */
31
+ const SwitchThumb = styled(SwitchFoundation)`
32
+ position: absolute;
28
33
  `
29
34
 
30
35
  /** Track element along which the thumb moves when toggled. */
31
- const SwitchTrack = styled.spanBox`
36
+ const SwitchTrack = styled(SwitchFoundation)`
32
37
  align-items: center;
33
- border-radius: round;
34
- display: inline-flex;
35
38
  flex: 1;
36
- position: relative;
37
- transition-duration: fast;
38
39
  `
39
40
 
40
- export const SwitchButtonBase = styled.spanBox`
41
+ export const SwitchButtonBase = styled(SwitchFoundation)`
41
42
  color: white;
42
43
  cursor: pointer;
43
- display: inline-flex;
44
- flex-shrink: 0;
45
- position: relative;
44
+ --x-ring-color: green;
46
45
 
47
46
  &[aria-disabled='true'] {
48
47
  cursor: not-allowed;
49
48
 
50
49
  .vui-switchThumb {
51
- background-color: disabled.color;
50
+ background-color: ${switchColors.disabled};
52
51
  }
53
52
 
54
53
  .vui-switchTrack {
55
- // Using ring instead of border when disabled, because it's easier
56
- --x-ring-color: var(--vui-colors-disabled-border);
57
- background-color: disabled.bg;
54
+ --x-ring-color: ${switchColors.disabled};
55
+ background-color: ${switchColors.disabledBg};
56
+ color: ${switchColors.disabled};
58
57
  }
59
58
  }
60
59
  `
@@ -124,10 +123,10 @@ export const SwitchButton = vui<'span', SwitchButtonProps>((props, ref) => {
124
123
  })
125
124
 
126
125
  const trackAliasedProps = filterUndefined({
127
- bg: isChecked ? trackStyles.bg : 'grey.50',
126
+ bg: isChecked ? trackStyles.bg : switchColors.disabled,
128
127
  pl: isChecked ? 1 : labelOffset,
129
128
  pr: isChecked ? labelOffset : 1,
130
- ring: !disabled ? (isFocused ? trackStyles.ring : 0) : 1
129
+ ring: !disabled ? (isFocused ? trackStyles.ring : 0) : 3
131
130
  })
132
131
 
133
132
  return (
@@ -144,12 +143,13 @@ export const SwitchButton = vui<'span', SwitchButtonProps>((props, ref) => {
144
143
  onChange={handleOnChange}
145
144
  onFocus={handleOnFocus}
146
145
  ref={inputRef}
146
+ tabIndex={-1}
147
147
  type="checkbox"
148
148
  {...{ checked, defaultChecked, disabled, id, name, required, value }}
149
149
  {...inputProps}
150
150
  />
151
151
 
152
- <SwitchTrack className="vui-switchTrack" {...trackStyles} {...trackAliasedProps}>
152
+ <SwitchTrack className="vui-switchTrack" tabIndex={0} {...trackStyles} {...trackAliasedProps}>
153
153
  {!isChecked && innerLabelOff}
154
154
 
155
155
  <SwitchThumb className="vui-switchThumb" {...thumbStyles} {...thumbAliasedProps} />
@@ -33,7 +33,6 @@ export const Switch = vui<'label', SwitchProps>((props, ref) => {
33
33
  checked,
34
34
  children,
35
35
  className,
36
- colorScheme,
37
36
  defaultChecked,
38
37
  disabled,
39
38
  id,
@@ -59,7 +58,6 @@ export const Switch = vui<'label', SwitchProps>((props, ref) => {
59
58
  () =>
60
59
  filterUndefined({
61
60
  checked,
62
- colorScheme,
63
61
  defaultChecked,
64
62
  disabled,
65
63
  name,
@@ -71,7 +69,7 @@ export const Switch = vui<'label', SwitchProps>((props, ref) => {
71
69
  value,
72
70
  variant
73
71
  }),
74
- [checked, colorScheme, defaultChecked, disabled, name, onBlur, onChange, onFocus, required, size, value, variant]
72
+ [checked, defaultChecked, disabled, name, onBlur, onChange, onFocus, required, size, value, variant]
75
73
  )
76
74
 
77
75
  const aliasedProps = filterUndefined({
@@ -1,4 +1,15 @@
1
- import { Dict } from '../utils'
1
+ import { switchColors } from './consts'
2
+
3
+ const baseStyle = {
4
+ button: {
5
+ thumb: {
6
+ bg: 'white'
7
+ },
8
+ track: {
9
+ ring: 3
10
+ }
11
+ }
12
+ }
2
13
 
3
14
  function sizeLg() {
4
15
  const button = {
@@ -60,28 +71,9 @@ function sizeSm() {
60
71
  return { button, label }
61
72
  }
62
73
 
63
- function variantContained(props: Dict) {
64
- const { colorScheme: c } = props
65
-
66
- const button = {
67
- thumb: {
68
- bg: 'white'
69
- },
70
- track: {
71
- bg: `${c}.80`,
72
- ring: 3
73
- }
74
- }
75
-
76
- return { button }
77
- }
78
-
79
- const baseStyle = {}
80
-
81
74
  const defaultProps = {
82
- colorScheme: 'blue',
83
75
  size: 'md',
84
- variant: 'contained'
76
+ variant: 'primary'
85
77
  }
86
78
 
87
79
  const parts = ['container', 'button', 'label']
@@ -93,7 +85,27 @@ const sizes = {
93
85
  }
94
86
 
95
87
  const variants = {
96
- contained: variantContained
88
+ primary: {
89
+ button: {
90
+ track: {
91
+ bg: switchColors.main
92
+ }
93
+ }
94
+ },
95
+ green: {
96
+ button: {
97
+ track: {
98
+ bg: switchColors.green
99
+ }
100
+ }
101
+ },
102
+ red: {
103
+ button: {
104
+ track: {
105
+ bg: switchColors.red
106
+ }
107
+ }
108
+ }
97
109
  }
98
110
 
99
111
  export default {
@@ -1,9 +1,9 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
 
3
3
  import { omitThemingProps, styled, useStyleConfig, vui } from '../core'
4
+ import { inputColors } from '../input/consts'
4
5
  import T from '../t'
5
6
  import { ChangeEvent, cs, filterUndefined } from '../utils'
6
- import { greyColor, greyLightColor, redColor } from './consts'
7
7
  import { getInitialCount } from './helpers'
8
8
  import { TextareaProps } from './textarea.types'
9
9
 
@@ -16,15 +16,9 @@ const TextareaTextarea = styled.textareaBox`
16
16
  transition-duration: fast;
17
17
  width: 100%;
18
18
 
19
- &::placeholder {
20
- color: grey.60;
21
- }
22
-
23
19
  &[aria-disabled='true'],
24
20
  &[aria-disabled='true']::placeholder {
25
- background-color: disabled.bg;
26
- border-color: disabled.border;
27
- color: disabled.color;
21
+ opacity: 0.5;
28
22
  cursor: not-allowed;
29
23
  }
30
24
  `
@@ -49,7 +43,6 @@ export const Textarea = vui<'div', TextareaProps>((props, ref) => {
49
43
  defaultValue,
50
44
  disabled,
51
45
  id,
52
- isInvalid,
53
46
  maxLength,
54
47
  name,
55
48
  onBlur,
@@ -70,10 +63,7 @@ export const Textarea = vui<'div', TextareaProps>((props, ref) => {
70
63
  const [count, setCount] = useState(getInitialCount(props))
71
64
  const [valueInternal, setValueInternal] = useState(defaultValue)
72
65
 
73
- const colorProps = filterUndefined({
74
- colorScheme: colorSchemeProp ?? (isInvalid ? 'red' : undefined)
75
- })
76
- const styles = useStyleConfig('Textarea', { ...colorProps, ...props })
66
+ const styles = useStyleConfig('Textarea', props)
77
67
 
78
68
  function onChange(e: ChangeEvent<HTMLTextAreaElement>) {
79
69
  setValueInternal(e.target.value)
@@ -87,9 +77,9 @@ export const Textarea = vui<'div', TextareaProps>((props, ref) => {
87
77
 
88
78
  const textareaAliasedProps = filterUndefined({
89
79
  'aria-disabled': disabled,
90
- bg: readOnly ? greyLightColor : undefined,
91
- focusBorderColor: !readOnly ? 'transparent' : undefined,
92
- focusRing: readOnly ? 0 : undefined
80
+ bg: readOnly ? inputColors.disabled : undefined,
81
+ focusWithinBorderColor: !readOnly ? 'transparent' : undefined,
82
+ focusWithinRingColor: readOnly ? 'transparent' : undefined
93
83
  })
94
84
 
95
85
  useEffect(() => {
@@ -128,7 +118,7 @@ export const Textarea = vui<'div', TextareaProps>((props, ref) => {
128
118
  {showCount && (
129
119
  <T
130
120
  className="vui-textareaCount"
131
- color={maxLength && count > maxLength ? redColor : greyColor}
121
+ color={maxLength && count > maxLength ? inputColors.error : inputColors.helpText}
132
122
  position="absolute"
133
123
  right={0}
134
124
  size="sm"
@@ -8,7 +8,7 @@ export type TextareaProps = SystemProps &
8
8
  autoFocus?: boolean
9
9
  /** Children are disabled for this component. */
10
10
  children?: never
11
- /** Available theme colors for this component. @default grey */
11
+ /** Deprecated. Please use variant instead. @deprecated */
12
12
  colorScheme?: 'green' | 'grey' | 'red'
13
13
  /** Passed to the inner input. */
14
14
  cols?: number
@@ -16,7 +16,7 @@ export type TextareaProps = SystemProps &
16
16
  defaultValue?: number | string
17
17
  /** Passed to the inner input. */
18
18
  disabled?: boolean
19
- /** Styles the textarea in invalid state. */
19
+ /** Deprecated. Please use variant="red" instead. @deprecated*/
20
20
  isInvalid?: boolean
21
21
  /** Passed to the inner input. */
22
22
  maxLength?: number
@@ -1,29 +1,17 @@
1
- import { Dict } from '../utils'
2
-
3
- function variantDefault(props: Dict) {
4
- const { colorScheme: c } = props
5
-
6
- const container = {}
7
-
8
- const textarea = {
9
- borderColor: `${c}.80`,
10
- focusRing: 2,
11
- focusRingColor: `${c}.80`
12
- }
13
-
14
- if (c === 'grey') {
15
- textarea.borderColor = `${c}.60`
16
- textarea.focusRingColor = 'blue.50'
1
+ import { inputColors } from '../input/consts'
2
+
3
+ const baseStyle = {
4
+ textarea: {
5
+ focusWithinRing: 2,
6
+ color: inputColors.inputText
7
+ },
8
+ input: {
9
+ color: { placeholder: inputColors.placeholder }
17
10
  }
18
-
19
- return { container, textarea }
20
11
  }
21
12
 
22
- const baseStyle = {}
23
-
24
13
  const defaultProps = {
25
- colorScheme: 'grey',
26
- variant: 'default'
14
+ variant: 'grey'
27
15
  }
28
16
 
29
17
  const parts = ['container', 'textarea']
@@ -31,7 +19,24 @@ const parts = ['container', 'textarea']
31
19
  const sizes = {}
32
20
 
33
21
  const variants = {
34
- default: variantDefault
22
+ grey: {
23
+ textarea: {
24
+ borderColor: inputColors.border,
25
+ focusWithinRingColor: inputColors.focus
26
+ }
27
+ },
28
+ green: {
29
+ textarea: {
30
+ borderColor: inputColors.success,
31
+ focusWithinRingColor: inputColors.success
32
+ }
33
+ },
34
+ red: {
35
+ textarea: {
36
+ borderColor: inputColors.error,
37
+ focusWithinRingColor: inputColors.error
38
+ }
39
+ }
35
40
  }
36
41
 
37
42
  export default {