1
1
const svgToDataUri = require ( 'mini-svg-data-uri' )
2
- const defaultTheme = require ( 'tailwindcss/defaultTheme' )
2
+ const defaultTheme = require ( 'tailwindcss/resolveConfig' ) ( require ( 'tailwindcss/defaultConfig' ) ) . theme
3
3
4
4
module . exports = function ( { addUtilities, addComponents, theme } ) {
5
5
@@ -16,8 +16,8 @@ module.exports = function ({ addUtilities, addComponents, theme }) {
16
16
focusShadow : defaultTheme . boxShadow . outline ,
17
17
checkboxSize : '1em' ,
18
18
radioSize : '1em' ,
19
- checkboxIcon : `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#fff" ><path d="M13.293 4 .293a1 1 0 0 1 0 1.414L7 12a1 1 0 0 1-1 .414 0L3.293 9.707a1 1 0 0 1 1 .414-1.414l1.586 1 .586 5.586-5.586a1 1 0 0 1 1.414 0z "/></svg>` ,
20
- radioIcon : `<svg viewBox="0 0 24 24 " fill="#fff" xmlns="http://www.w3.org/2000/svg"><circle cx="12 " cy="12 " r="5 "/></svg>` ,
19
+ checkboxIcon : `<svg viewBox="0 0 14 14" fill="#fff" xmlns="http://www.w3.org/2000/svg"><path d="M4.707 6 .293a1 1 0 0 0-1.414 1.414l2 2a1 1 0 0 0 1 .414 0l4-4a1 1 0 0 0-1 .414-1.414L6 7 .586 4.707 6.293z "/></svg>` ,
20
+ radioIcon : `<svg viewBox="0 0 14 14 " fill="#fff" xmlns="http://www.w3.org/2000/svg"><circle cx="7 " cy="7 " r="3 "/></svg>` ,
21
21
checkedColor : 'currentColor' ,
22
22
selectIcon : `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="${ defaultTheme . colors . gray [ 500 ] } "><path d="M15.3 9.3a1 1 0 0 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 1.4-1.4l3.3 3.29 3.3-3.3z"/></svg>` ,
23
23
selectIconOffset : defaultTheme . spacing [ 2 ] ,
@@ -32,26 +32,29 @@ module.exports = function ({ addUtilities, addComponents, theme }) {
32
32
height : options . checkboxSize ,
33
33
width : options . checkboxSize ,
34
34
verticalAlign : 'middle' ,
35
- borderColor : options . borderColor ,
36
- borderWidth : options . borderWidth ,
35
+ boxShadow : `inset 0 0 0 ${ options . borderWidth } ${ options . borderColor } ` ,
37
36
borderRadius : options . borderRadius ,
38
37
backgroundColor : options . backgroundColor ,
39
38
userSelect : 'none' ,
40
39
'&:focus' : {
41
40
outline : 'none' ,
42
- boxShadow : options . focusShadow ,
41
+ boxShadow : `inset 0 0 0 ${ options . borderWidth } ${ options . borderColor } , ${ options . focusShadow } ` ,
43
42
} ,
44
43
'&:focus:not(:checked)' : {
45
- borderColor : options . focusBorderColor ,
44
+ boxShadow : `inset 0 0 0 ${ options . borderWidth } ${ options . focusBorderColor } , ${ options . focusShadow } ` ,
46
45
} ,
47
46
'&:checked' : {
47
+ boxShadow : 'none' ,
48
48
backgroundColor : options . checkedColor ,
49
49
borderColor : options . checkedColor ,
50
50
backgroundImage : `url("${ svgToDataUri ( options . checkboxIcon ) } ")` ,
51
- backgroundSize : 'cover ' ,
51
+ backgroundSize : '100% 100% ' ,
52
52
backgroundPosition : 'center' ,
53
53
backgroundRepeat : 'no-repeat' ,
54
54
} ,
55
+ '&:focus:checked' : {
56
+ boxShadow : `${ options . focusShadow } ` ,
57
+ } ,
55
58
'&::-ms-check' : {
56
59
color : 'transparent' , // Hide the check
57
60
background : 'inherit' ,
@@ -66,26 +69,28 @@ module.exports = function ({ addUtilities, addComponents, theme }) {
66
69
height : options . radioSize ,
67
70
width : options . radioSize ,
68
71
verticalAlign : 'middle' ,
69
- borderColor : options . borderColor ,
70
- borderWidth : options . borderWidth ,
72
+ boxShadow : `inset 0 0 0 ${ options . borderWidth } ${ options . borderColor } ` ,
71
73
borderRadius : '50%' ,
72
74
backgroundColor : options . backgroundColor ,
73
75
userSelect : 'none' ,
74
76
'&:focus' : {
75
77
outline : 'none' ,
76
- boxShadow : options . focusShadow ,
78
+ boxShadow : `inset 0 0 0 ${ options . borderWidth } ${ options . borderColor } , ${ options . focusShadow } ` ,
77
79
} ,
78
80
'&:focus:not(:checked)' : {
79
- borderColor : options . focusBorderColor ,
81
+ boxShadow : `inset 0 0 0 ${ options . borderWidth } ${ options . focusBorderColor } , ${ options . focusShadow } ` ,
80
82
} ,
81
83
'&:checked' : {
84
+ boxShadow : 'none' ,
82
85
backgroundColor : options . checkedColor ,
83
- borderColor : options . checkedColor ,
84
86
backgroundImage : `url("${ svgToDataUri ( options . radioIcon ) } ")` ,
85
- backgroundSize : 'cover ' ,
87
+ backgroundSize : '100% 100% ' ,
86
88
backgroundPosition : 'center' ,
87
89
backgroundRepeat : 'no-repeat' ,
88
90
} ,
91
+ '&:focus:checked' : {
92
+ boxShadow : `${ options . focusShadow } ` ,
93
+ } ,
89
94
'&::-ms-check' : {
90
95
color : 'transparent' , // Hide the dot
91
96
background : 'inherit' ,
0 commit comments