@@ -3,19 +3,36 @@ import styled from 'styled-components';
33import { Link } from 'react-router-dom' ;
44import { remSize , prop } from '../theme' ;
55
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'
915}
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'
1425}
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'
1936}
2037
2138export interface ButtonProps extends React . HTMLAttributes < HTMLElement > {
@@ -31,7 +48,7 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLElement> {
3148 /**
3249 * The display type of the button—inline or block
3350 */
34- display ?: Displays ;
51+ display ?: ButtonDisplays ;
3552 /**
3653 * SVG icon to place after child content
3754 */
@@ -47,7 +64,7 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLElement> {
4764 /**
4865 * The kind of button - determines how it appears visually
4966 */
50- kind ?: Kinds ;
67+ kind ?: ButtonKinds ;
5168 /**
5269 * Specifying an href will use an <a> to link to the URL
5370 */
@@ -78,8 +95,8 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLElement> {
7895}
7996
8097interface StyledButtonProps extends ButtonProps {
81- kind : Kinds ;
82- display : Displays ;
98+ kind : ButtonKinds ;
99+ display : ButtonDisplays ;
83100}
84101
85102// The '&&&' will increase the specificity of the
@@ -89,7 +106,7 @@ const StyledButton = styled.button<StyledButtonProps>`
89106 &&& {
90107 font-weight: bold;
91108 display: ${ ( { display } ) =>
92- display === Displays . inline ? 'inline-flex' : 'flex' } ;
109+ display === ButtonDisplays . INLINE ? 'inline-flex' : 'flex' } ;
93110 justify-content: center;
94111 align-items: center;
95112
@@ -183,15 +200,15 @@ const StyledInlineButton = styled.button`
183200 */
184201export const Button = ( {
185202 children = null ,
186- display = Displays . block ,
203+ display = ButtonDisplays . BLOCK ,
187204 href,
188- kind = Kinds . primary ,
205+ kind = ButtonKinds . PRIMARY ,
189206 iconBefore = null ,
190207 iconAfter = null ,
191208 iconOnly = false ,
192209 'aria-label' : ariaLabel ,
193210 to,
194- type = ButtonTypes . button ,
211+ type = ButtonTypes . BUTTON ,
195212 ...props
196213} : ButtonProps ) => {
197214 const hasChildren = React . Children . count ( children ) > 0 ;
@@ -251,6 +268,3 @@ export const Button = ({
251268 </ StyledComponent >
252269 ) ;
253270} ;
254-
255- Button . kinds = Kinds ;
256- Button . displays = Displays ;
0 commit comments