@@ -3,19 +3,36 @@ import styled from 'styled-components';
3
3
import { Link } from 'react-router-dom' ;
4
4
import { remSize , prop } from '../theme' ;
5
5
6
- enum Kinds {
7
- primary = 'primary' ,
8
- secondary = 'secondary'
6
+ /**
7
+ * Enum for the visual style of a Button.
8
+ *
9
+ * These values transpile to lowercase strings (`'primary' | 'secondary'`)
10
+ * that map directly to keys in the `Button` object in `theme.js` for styling.
11
+ */
12
+ export enum ButtonKinds {
13
+ PRIMARY = 'primary' ,
14
+ SECONDARY = 'secondary'
9
15
}
10
-
11
- enum Displays {
12
- block = 'block' ,
13
- inline = 'inline'
16
+ /**
17
+ * Enum for the display type of a Button.
18
+ *
19
+ * These values transpile to lowercase strings (`'block' | 'inline'`)
20
+ * and map to display styles in the `Button` object in `theme.js`.
21
+ */
22
+ export enum ButtonDisplays {
23
+ BLOCK = 'block' ,
24
+ INLINE = 'inline'
14
25
}
15
-
16
- enum ButtonTypes {
17
- button = 'button' ,
18
- submit = 'submit'
26
+ /**
27
+ * Enum for the native HTML button type.
28
+ *
29
+ * These values transpile to lowercase strings (`'button' | 'submit'`)
30
+ * and correspond to the `type` attribute on a native <button>.
31
+ * They can also be used in `theme.js` if needed for button-specific styles.
32
+ */
33
+ export enum ButtonTypes {
34
+ BUTTON = 'button' ,
35
+ SUBMIT = 'submit'
19
36
}
20
37
21
38
export interface ButtonProps extends React . HTMLAttributes < HTMLElement > {
@@ -31,7 +48,7 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLElement> {
31
48
/**
32
49
* The display type of the button—inline or block
33
50
*/
34
- display ?: Displays ;
51
+ display ?: ButtonDisplays ;
35
52
/**
36
53
* SVG icon to place after child content
37
54
*/
@@ -47,7 +64,7 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLElement> {
47
64
/**
48
65
* The kind of button - determines how it appears visually
49
66
*/
50
- kind ?: Kinds ;
67
+ kind ?: ButtonKinds ;
51
68
/**
52
69
* Specifying an href will use an <a> to link to the URL
53
70
*/
@@ -78,8 +95,8 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLElement> {
78
95
}
79
96
80
97
interface StyledButtonProps extends ButtonProps {
81
- kind : Kinds ;
82
- display : Displays ;
98
+ kind : ButtonKinds ;
99
+ display : ButtonDisplays ;
83
100
}
84
101
85
102
// The '&&&' will increase the specificity of the
@@ -89,7 +106,7 @@ const StyledButton = styled.button<StyledButtonProps>`
89
106
&&& {
90
107
font-weight: bold;
91
108
display: ${ ( { display } ) =>
92
- display === Displays . inline ? 'inline-flex' : 'flex' } ;
109
+ display === ButtonDisplays . INLINE ? 'inline-flex' : 'flex' } ;
93
110
justify-content: center;
94
111
align-items: center;
95
112
@@ -183,15 +200,15 @@ const StyledInlineButton = styled.button`
183
200
*/
184
201
export const Button = ( {
185
202
children = null ,
186
- display = Displays . block ,
203
+ display = ButtonDisplays . BLOCK ,
187
204
href,
188
- kind = Kinds . primary ,
205
+ kind = ButtonKinds . PRIMARY ,
189
206
iconBefore = null ,
190
207
iconAfter = null ,
191
208
iconOnly = false ,
192
209
'aria-label' : ariaLabel ,
193
210
to,
194
- type = ButtonTypes . button ,
211
+ type = ButtonTypes . BUTTON ,
195
212
...props
196
213
} : ButtonProps ) => {
197
214
const hasChildren = React . Children . count ( children ) > 0 ;
@@ -251,6 +268,3 @@ export const Button = ({
251
268
</ StyledComponent >
252
269
) ;
253
270
} ;
254
-
255
- Button . kinds = Kinds ;
256
- Button . displays = Displays ;
0 commit comments