@@ -8,7 +8,7 @@ import { Spinner } from './Spinner';
8
8
9
9
const vars = createCssVariables ( 'accent' , 'accentDark' , 'accentDarker' , 'accentLighter' , 'accentLightest' , 'border' ) ;
10
10
11
- const { applyVariants, filterProps } = createVariants ( theme => {
11
+ const { applyVariants, filterProps } = createVariants ( ( theme , opts : { hoverAsFocus : boolean } ) => {
12
12
return {
13
13
base : {
14
14
margin : 0 ,
@@ -60,35 +60,40 @@ const { applyVariants, filterProps } = createVariants(theme => {
60
60
solid : {
61
61
backgroundColor : vars . accent ,
62
62
color : theme . colors . $colorTextOnPrimaryBackground ,
63
- '&:hover, :focus' : { backgroundColor : vars . accentDark } ,
63
+ '&:hover' : { backgroundColor : vars . accentDark } ,
64
+ '&:focus' : opts . hoverAsFocus ? { backgroundColor : vars . accentDark } : undefined ,
64
65
'&:active' : { backgroundColor : vars . accentDarker } ,
65
66
} ,
66
67
outline : {
67
68
border : theme . borders . $normal ,
68
69
borderColor : vars . accentLighter ,
69
70
color : vars . accent ,
70
- '&:hover, :focus' : { backgroundColor : vars . accentLightest } ,
71
+ '&:hover' : { backgroundColor : vars . accentLightest } ,
72
+ '&:focus' : opts . hoverAsFocus ? { backgroundColor : vars . accentLightest } : undefined ,
71
73
'&:active' : { backgroundColor : vars . accentLighter } ,
72
74
} ,
73
75
ghost : {
74
76
color : vars . accent ,
75
- '&:hover, :focus' : { backgroundColor : vars . accentLightest } ,
77
+ '&:hover' : { backgroundColor : vars . accentLightest } ,
78
+ '&:focus' : opts . hoverAsFocus ? { backgroundColor : vars . accentLightest } : undefined ,
76
79
'&:active' : { backgroundColor : vars . accentLighter } ,
77
80
} ,
78
81
icon : {
79
82
color : vars . accent ,
80
83
border : theme . borders . $normal ,
81
84
borderRadius : theme . radii . $lg ,
82
85
borderColor : vars . border ,
83
- '&:hover, :focus' : { backgroundColor : vars . accentLightest } ,
86
+ '&:hover' : { backgroundColor : vars . accentLightest } ,
87
+ '&:focus' : opts . hoverAsFocus ? { backgroundColor : vars . accentLightest } : undefined ,
84
88
'&:active' : { backgroundColor : vars . accentLighter } ,
85
89
} ,
86
90
ghostIcon : {
87
91
color : vars . accent ,
88
92
minHeight : theme . sizes . $6 ,
89
93
width : theme . sizes . $6 ,
90
94
padding : `${ theme . space . $1 } ${ theme . space . $1 } ` ,
91
- '&:hover, :focus' : { color : vars . accentDark } ,
95
+ '&:hover' : { color : vars . accentDark } ,
96
+ '&:focus' : opts . hoverAsFocus ? { backgroundColor : vars . accentDark } : undefined ,
92
97
'&:active' : { color : vars . accentDarker } ,
93
98
} ,
94
99
link : {
@@ -99,7 +104,8 @@ const { applyVariants, filterProps } = createVariants(theme => {
99
104
textTransform : 'none' ,
100
105
padding : 0 ,
101
106
color : vars . accent ,
102
- '&:hover, :focus' : { textDecoration : 'underline' } ,
107
+ '&:hover' : { textDecoration : 'underline' } ,
108
+ '&:focus' : opts . hoverAsFocus ? { textDecoration : 'underline' } : undefined ,
103
109
'&:active' : { color : vars . accentDark } ,
104
110
} ,
105
111
roundWrapper : { padding : 0 , margin : 0 , height : 'unset' , width : 'unset' , minHeight : 'unset' } ,
@@ -126,6 +132,7 @@ type OwnProps = PrimitiveProps<'button'> & {
126
132
loadingText ?: string ;
127
133
isDisabled ?: boolean ;
128
134
isActive ?: boolean ;
135
+ hoverAsFocus ?: boolean ;
129
136
} ;
130
137
type ButtonProps = OwnProps & StyleVariants < typeof applyVariants > ;
131
138
0 commit comments