1
1
import React , { useState , useRef } from 'react' ;
2
2
import { createUseStyles } from 'react-jss' ;
3
3
4
+ /**
5
+ * Button component that is styled using react-jss.
6
+ * It supports various states like hover, active, and disabled,
7
+ * and can be configured with custom styles, titles, and callbacks.
8
+ *
9
+ * @param {Object } props - The props for the Button component.
10
+ */
11
+
4
12
function Button ( props ) {
5
13
6
14
const {
7
- className = "" ,
8
- style = { } ,
9
- onDone = ( ) => { } ,
10
- title = "" ,
11
- disabled = false ,
12
- disableOnClick = false ,
15
+ className = "" , // may or may not be passed. Should be applied to the outer most tag, after local classNames
16
+ style = { } , // may or may not be passed, Should be applied to the outer most tag
17
+ onDone = ( ) => { } , // a function that is called when the button is clicked. - if it exists
18
+ title = "" , // text to display on hover
19
+ disabled = false ,
20
+ disableOnClick = false , // if true, the button gets disabled after click and stays disabled - prevents resubmission
13
21
children
14
22
} = props ;
15
23
@@ -97,6 +105,7 @@ function TextButton(props) {
97
105
return < Button { ...props } className = "textButton" /> ;
98
106
}
99
107
108
+
100
109
const commonButtonStyles = {
101
110
width : 'auto' ,
102
111
height : 'auto' ,
@@ -107,11 +116,6 @@ const commonButtonStyles = {
107
116
fontSize : '1rem' ,
108
117
lineHeight : '1.5rem' ,
109
118
textAlign : 'center' ,
110
- transition : 'all 100ms ease-out' ,
111
-
112
- '&:hover, &.hover' : {
113
- textDecoration : 'underline' ,
114
- }
115
119
}
116
120
117
121
const buttonStyles = createUseStyles ( theme => ( {
@@ -137,6 +141,12 @@ const buttonStyles = createUseStyles(theme => ({
137
141
border : '0.125rem solid #5D5D5C' ,
138
142
textDecoration : 'none' ,
139
143
transition : 'none' ,
144
+ } ,
145
+
146
+ '&:hover, &.hover' : {
147
+ textDecoration : 'underline' ,
148
+ backgroundColor : '#FFFFFF' ,
149
+ borderColor : '#06335C'
140
150
}
141
151
} ,
142
152
@@ -155,6 +165,12 @@ const buttonStyles = createUseStyles(theme => ({
155
165
156
166
'&:focus' : {
157
167
} ,
168
+
169
+ '&:hover, &.hover' : {
170
+ textDecoration : 'underline' ,
171
+ backgroundColor : '#FFFFFF' ,
172
+ borderColor : '#FFC315'
173
+ }
158
174
} ,
159
175
160
176
primaryButton : {
@@ -178,6 +194,12 @@ const buttonStyles = createUseStyles(theme => ({
178
194
border : '0.0625rem solid #EBEBEB' ,
179
195
textDecoration : 'none' ,
180
196
transition : 'none' ,
197
+ } ,
198
+
199
+ '&:hover, &.hover' : {
200
+ textDecoration : 'underline' ,
201
+ backgroundColor : '#06335C' ,
202
+ borderColor : '#06335C'
181
203
}
182
204
} ,
183
205
@@ -192,6 +214,12 @@ const buttonStyles = createUseStyles(theme => ({
192
214
'&:active' : {
193
215
color : '#1A1A1A' ,
194
216
textDecoration : 'none' ,
217
+ } ,
218
+
219
+ '&:hover, &.hover' : {
220
+ textDecoration : 'underline' ,
221
+ backgroundColor : 'transparent' ,
222
+ borderColor : 'none'
195
223
}
196
224
}
197
225
} ) )
0 commit comments