@startupjs-ui/checkbox 0.2.0-alpha.1 → 0.3.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/CHANGELOG.md +25 -0
- package/checkbox.tsx +8 -0
- package/index.cssx.styl +16 -0
- package/index.d.ts +2 -0
- package/index.tsx +4 -0
- package/package.json +6 -6
- package/switch.tsx +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.3.0](https://github.com/startupjs/startupjs-ui/compare/v0.2.3...v0.3.0) (2026-05-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @startupjs-ui/checkbox
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.2.0](https://github.com/startupjs/startupjs-ui/compare/v0.1.23...v0.2.0) (2026-05-04)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* [v0.2] add accessibility features to most components, which also dramatically improves E2E testability ([#22](https://github.com/startupjs/startupjs-ui/issues/22)) ([b563e2f](https://github.com/startupjs/startupjs-ui/commit/b563e2fa498a8a83bd5abc7836d120f6d2381e3f))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [0.2.0-alpha.1](https://github.com/startupjs/startupjs-ui/compare/v0.2.0-alpha.0...v0.2.0-alpha.1) (2026-04-10)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @startupjs-ui/checkbox
|
|
@@ -17,6 +36,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
17
36
|
### Features
|
|
18
37
|
|
|
19
38
|
* fix and improve accessibility of various components. Add storybook with tests. ([#21](https://github.com/startupjs/startupjs-ui/issues/21)) ([83b6576](https://github.com/startupjs/startupjs-ui/commit/83b65767ed61b24209f71b143ba1c2986170ab58))
|
|
39
|
+
## [0.1.23](https://github.com/startupjs/startupjs-ui/compare/v0.1.22...v0.1.23) (2026-03-27)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* **Checkbox:** add prop for background color ([#23](https://github.com/startupjs/startupjs-ui/issues/23)) ([613a522](https://github.com/startupjs/startupjs-ui/commit/613a5226e15d9a682f7652155f084c26c747ea4d))
|
|
20
45
|
|
|
21
46
|
|
|
22
47
|
|
package/checkbox.tsx
CHANGED
|
@@ -13,6 +13,7 @@ const AnimatedView = Animated.View
|
|
|
13
13
|
interface CheckboxInputProps {
|
|
14
14
|
value?: boolean
|
|
15
15
|
icon?: any
|
|
16
|
+
checkedBgColor?: string
|
|
16
17
|
_hasError?: boolean
|
|
17
18
|
[key: string]: any
|
|
18
19
|
}
|
|
@@ -20,7 +21,9 @@ interface CheckboxInputProps {
|
|
|
20
21
|
function CheckboxInput ({
|
|
21
22
|
value,
|
|
22
23
|
icon,
|
|
24
|
+
checkedBgColor,
|
|
23
25
|
_hasError,
|
|
26
|
+
style,
|
|
24
27
|
...props
|
|
25
28
|
}: CheckboxInputProps): ReactNode {
|
|
26
29
|
const animation = useRef(new Animated.Value(value ? 1 : 0)).current
|
|
@@ -47,14 +50,19 @@ function CheckboxInput ({
|
|
|
47
50
|
}, [value])
|
|
48
51
|
|
|
49
52
|
const checkedStyleName = { checked: value }
|
|
53
|
+
const checkedBgStyle = value && checkedBgColor
|
|
54
|
+
? { backgroundColor: checkedBgColor }
|
|
55
|
+
: undefined
|
|
50
56
|
|
|
51
57
|
return pug`
|
|
52
58
|
Div.checkbox(
|
|
53
59
|
styleName=[checkedStyleName, { error: _hasError }]
|
|
54
60
|
role='checkbox'
|
|
61
|
+
style=style
|
|
55
62
|
onLayout=(event) => setWidth(event.nativeEvent.layout.width)
|
|
56
63
|
...props
|
|
57
64
|
)
|
|
65
|
+
Div.checkbox-bg(style=checkedBgStyle)
|
|
58
66
|
Icon.checkbox-icon(
|
|
59
67
|
styleName=[checkedStyleName]
|
|
60
68
|
icon= icon || faCheck
|
package/index.cssx.styl
CHANGED
|
@@ -51,6 +51,14 @@ $this = merge({
|
|
|
51
51
|
background-color var(--color-bg-primary)
|
|
52
52
|
border-color var(--color-border-primary)
|
|
53
53
|
|
|
54
|
+
.checkbox-bg
|
|
55
|
+
position absolute
|
|
56
|
+
left 0
|
|
57
|
+
right 0
|
|
58
|
+
top 0
|
|
59
|
+
bottom 0
|
|
60
|
+
border-radius: $this.checkbox.borderRadius
|
|
61
|
+
|
|
54
62
|
.checkbox-icon
|
|
55
63
|
display none
|
|
56
64
|
color $checkedIconColor
|
|
@@ -87,6 +95,14 @@ $this = merge({
|
|
|
87
95
|
&.checked
|
|
88
96
|
background-color var(--color-bg-primary)
|
|
89
97
|
|
|
98
|
+
.switch-bg
|
|
99
|
+
position absolute
|
|
100
|
+
left 0
|
|
101
|
+
right 0
|
|
102
|
+
top 0
|
|
103
|
+
bottom 0
|
|
104
|
+
radius(circle)
|
|
105
|
+
|
|
90
106
|
.switch-circle
|
|
91
107
|
width: $this.switch.circleSize
|
|
92
108
|
height @width
|
package/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface CheckboxProps {
|
|
|
15
15
|
value?: boolean;
|
|
16
16
|
/** Custom icon for the checkbox variant */
|
|
17
17
|
icon?: any;
|
|
18
|
+
/** Custom background color when checked */
|
|
19
|
+
checkedBgColor?: string;
|
|
18
20
|
/** Disable interactions @default false */
|
|
19
21
|
disabled?: boolean;
|
|
20
22
|
/** Render a non-interactive value @default false */
|
package/index.tsx
CHANGED
|
@@ -31,6 +31,8 @@ export interface CheckboxProps {
|
|
|
31
31
|
value?: boolean
|
|
32
32
|
/** Custom icon for the checkbox variant */
|
|
33
33
|
icon?: any
|
|
34
|
+
/** Custom background color when checked */
|
|
35
|
+
checkedBgColor?: string
|
|
34
36
|
/** Disable interactions @default false */
|
|
35
37
|
disabled?: boolean
|
|
36
38
|
/** Render a non-interactive value @default false */
|
|
@@ -55,6 +57,7 @@ function Checkbox ({
|
|
|
55
57
|
readonly = false,
|
|
56
58
|
value = false,
|
|
57
59
|
disabled = false,
|
|
60
|
+
checkedBgColor,
|
|
58
61
|
onChange,
|
|
59
62
|
onFocus, // skip due to pointless triggering when clicked on the View
|
|
60
63
|
onBlur, // skip due to pointless triggering when clicked on the View
|
|
@@ -79,6 +82,7 @@ function Checkbox ({
|
|
|
79
82
|
role=variant === 'switch' ? 'switch' : 'checkbox'
|
|
80
83
|
aria-checked=value
|
|
81
84
|
aria-disabled=disabled
|
|
85
|
+
checkedBgColor=checkedBgColor
|
|
82
86
|
...props
|
|
83
87
|
)
|
|
84
88
|
`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs-ui/checkbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
"types": "index.d.ts",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@startupjs-ui/core": "^0.
|
|
12
|
-
"@startupjs-ui/div": "^0.
|
|
13
|
-
"@startupjs-ui/icon": "^0.
|
|
14
|
-
"@startupjs-ui/span": "^0.
|
|
11
|
+
"@startupjs-ui/core": "^0.3.0",
|
|
12
|
+
"@startupjs-ui/div": "^0.3.0",
|
|
13
|
+
"@startupjs-ui/icon": "^0.3.0",
|
|
14
|
+
"@startupjs-ui/span": "^0.3.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": "*",
|
|
18
18
|
"react-native": "*",
|
|
19
19
|
"startupjs": "*"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "8d212b47680af1dfe582f9759b38724b46488e25"
|
|
22
22
|
}
|
package/switch.tsx
CHANGED
|
@@ -17,13 +17,16 @@ const AnimatedView = Animated.View
|
|
|
17
17
|
|
|
18
18
|
interface SwitchInputProps {
|
|
19
19
|
value?: boolean
|
|
20
|
+
checkedBgColor?: string
|
|
20
21
|
_hasError?: boolean
|
|
21
22
|
[key: string]: any
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
function SwitchInput ({
|
|
25
26
|
value,
|
|
27
|
+
checkedBgColor,
|
|
26
28
|
_hasError,
|
|
29
|
+
style,
|
|
27
30
|
...props
|
|
28
31
|
}: SwitchInputProps): ReactNode {
|
|
29
32
|
const animation = useRef(new Animated.Value(value ? 1 : 0)).current
|
|
@@ -52,11 +55,17 @@ function SwitchInput ({
|
|
|
52
55
|
}
|
|
53
56
|
}, [value])
|
|
54
57
|
|
|
58
|
+
const checkedBgStyle = value && checkedBgColor
|
|
59
|
+
? { backgroundColor: checkedBgColor }
|
|
60
|
+
: undefined
|
|
61
|
+
|
|
55
62
|
return pug`
|
|
56
63
|
Div.switch(
|
|
57
64
|
styleName=[{ checked: value, error: _hasError }]
|
|
65
|
+
style=style
|
|
58
66
|
...props
|
|
59
67
|
)
|
|
68
|
+
Div.switch-bg(style=checkedBgStyle)
|
|
60
69
|
AnimatedView.switch-circle(
|
|
61
70
|
part='switchCircle'
|
|
62
71
|
style={
|