11import { ReactNode } from 'react' ;
22import Loader from '../loader/Loader' ;
33
4- interface ButtonProps {
4+ export interface ButtonProps {
55 id ?: string ;
66 variant ?: 'primary' | 'secondary' | 'ghost' | 'destructive' ;
77 type ?: 'button' | 'submit' ;
@@ -18,7 +18,63 @@ interface ButtonProps {
1818 buttonChildrenDataCy ?: string ;
1919}
2020
21- export const Button = ( {
21+ /**
22+ * Button component
23+ *
24+ * @property {string } [id]
25+ * - Optional ID for the button element, useful for accessibility and styling.
26+ *
27+ * @property {'primary' | 'secondary' | 'ghost' | 'destructive' } [variant]
28+ * - Defines the button's style variant. Options are:
29+ * - 'primary': Standard button style with primary color.
30+ * - 'secondary': Button with border and subtle background color.
31+ * - 'ghost': Button with transparent background, suitable for icons or light use.
32+ * - 'destructive': Button for destructive actions.
33+ *
34+ * @property {'button' | 'submit' } [type]
35+ * - Specifies the type of the button. Defaults to 'button'.
36+ * - 'button': Standard button behavior.
37+ * - 'submit': Button submits a form when used inside a form element.
38+ *
39+ * @property {ReactNode } [children]
40+ * - The content inside the button, such as text or icons.
41+ * - Can be a single element or an array of elements.
42+ *
43+ * @property {string } [className]
44+ * - Custom CSS classes for additional styling of the button.
45+ *
46+ * @property {boolean } [disabled]
47+ * - Disables the button, preventing user interaction and applying a disabled style.
48+ * - Defaults to false.
49+ *
50+ * @property {(e?: unknown) => void } [onClick]
51+ * - Function called when the button is clicked. Accepts an optional event object.
52+ *
53+ * @property {(e?: unknown) => void } [onKeyDown]
54+ * - Function called when a key is pressed while the button is focused. Accepts an optional event object.
55+ *
56+ * @property {'medium' | 'default' } [size]
57+ * - Specifies the button size. Options are:
58+ * - 'default': Standard size.
59+ * - 'medium': Slightly smaller size for compact use.
60+ *
61+ * @property {boolean } [loading]
62+ * - If true, shows a loading spinner inside the button.
63+ *
64+ * @property {string } [dataTest]
65+ * - Custom data attribute used for test automation or tracking purposes.
66+ *
67+ * @property {boolean } [autofocus]
68+ * - If true, the button will be focused automatically when the page loads.
69+ *
70+ * @property {string } [buttonDataCy]
71+ * - Custom data attribute for the button element.
72+ *
73+ * @property {string } [buttonChildrenDataCy]
74+ * - Custom data attribute for the children of the button.
75+ */
76+
77+ const Button = ( {
2278 variant = 'primary' ,
2379 type = 'button' ,
2480 id,
@@ -80,3 +136,5 @@ export const Button = ({
80136 </ button >
81137 ) ;
82138} ;
139+
140+ export default Button ;
0 commit comments