@@ -5,6 +5,19 @@ import { spacing, Stack } from '../../spacing';
55import { Text } from '../text/Text.component' ;
66import { FocusVisibleStyle } from '../buttonv2/Buttonv2.component' ;
77
8+ const getCheckmarkSvgUrl = ( color : string ) => {
9+ const encodedColor = color . replace ( '#' , '%23' ) ;
10+ return `url('data:image/svg+xml,%3Csvg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"%3E %3Cpath d="M3 6.68646L5.0671 9L9 3" stroke="${ encodedColor } " stroke-width="1.5"/%3E %3C/svg%3E')` ;
11+ } ;
12+
13+ const getIndeterminateSvgUrl = ( color : string ) => {
14+ const encodedColor = color . replace ( '#' , '%23' ) ;
15+ return `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E %3Cline x1='6' y1='12' x2='20' y2='12' style='stroke:${ encodedColor } ;stroke-width:4'/%3E %3C/svg%3E")` ;
16+ } ;
17+
18+ const CheckboxInput = styled . input `
19+ transform: scale(1.5);` ;
20+
821export type Props = {
922 label ?: string ;
1023 value ?: string ;
@@ -22,7 +35,7 @@ const Checkbox = forwardRef<HTMLInputElement, Props>(
2235 className = "sc-checkbox"
2336 >
2437 < Stack >
25- < input
38+ < CheckboxInput
2639 type = "checkbox"
2740 checked = { checked }
2841 disabled = { disabled }
@@ -77,8 +90,7 @@ const StyledCheckbox = styled.label<{
7790 border: 0;
7891 background-color: transparent;
7992 background-size: contain;
80- box-shadow: inset 0 0 0 ${ spacing . r1 }
81- ${ ( props ) => props . theme . textSecondary } ;
93+ box-shadow: inset 0 0 0 ${ spacing . r1 } ${ ( props ) => props . theme . textSecondary } ;
8294 }
8395
8496 /* Checked */
@@ -89,30 +101,17 @@ const StyledCheckbox = styled.label<{
89101
90102 [type='checkbox']:checked::before {
91103 box-shadow: none;
92- background-image: url('data:image/svg+xml,%3Csvg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"%3E %3Cpath d="M3 6.68646L5.0671 9L9 3" stroke="${ (
93- props ,
94- ) =>
95- props . theme . textPrimary . replace (
96- '#' ,
97- '%23' ,
98- ) } " stroke-width="1.5"/%3E %3C/svg%3E');
104+ background-image: ${ ( props ) => getCheckmarkSvgUrl ( props . theme . textPrimary ) } ;
99105 background-repeat: no-repeat;
100106 background-position: center;
101107 }
102108
103109 /* Indeterminate */
104110
105111 [type='checkbox']:indeterminate::before {
106- box-shadow: inset 0 0 0 ${ spacing . r1 }
107- ${ ( props ) => props . theme . selectedActive } ;
112+ box-shadow: inset 0 0 0 ${ spacing . r1 } ${ ( props ) => props . theme . selectedActive } ;
108113 background-color: ${ ( props ) => props . theme . highlight } ;
109- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E %3Cline x1='6' y1='12' x2='20' y2='12' style='stroke:${ (
110- props ,
111- ) =>
112- props . theme . textPrimary . replace (
113- '#' ,
114- '%23' ,
115- ) } ;stroke-width:4'/%3E %3C/svg%3E");
114+ background-image: ${ ( props ) => getIndeterminateSvgUrl ( props . theme . textPrimary ) } ;
116115 }
117116
118117 /* Hover & focus */
@@ -142,4 +141,4 @@ const StyledCheckbox = styled.label<{
142141 cursor: not-allowed;
143142 background-color: ${ ( props ) => props . theme . textSecondary } ;
144143 }
145- ` ;
144+ `
0 commit comments