Skip to content

Commit 08366bd

Browse files
committed
chore: add doc comments
1 parent e30fed2 commit 08366bd

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

src/Shared/Components/Button/Button.component.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,56 @@ import { BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP, BUTTON_SIZE_TO_LOADER_SIZE_MAP } fr
66
import { getButtonDerivedClass } from './utils'
77
import './button.scss'
88

9+
/**
10+
* Generic component for Button.
11+
* Should be used in combination of variant, size and style.
12+
*
13+
* @example Default button
14+
* ```tsx
15+
* <Button text="Hello World" />
16+
* ```
17+
*
18+
* @example Custom variant
19+
* ```tsx
20+
* <Button text="Hello World" variant={ButtonVariantType.secondary} />
21+
* ```
22+
*
23+
* @example Custom size
24+
* ```tsx
25+
* <Button text="Hello World" size={ComponentSizeType.medium} />
26+
* ```
27+
*
28+
* @example Custom style
29+
* ```tsx
30+
* <Button text="Hello World" style={ButtonStyleType.positive} />
31+
* ```
32+
*
33+
* @example Disabled state
34+
* ```tsx
35+
* <Button text="Hello World" disabled />
36+
* ```
37+
*
38+
* @example Loading state
39+
* ```tsx
40+
* <Button text="Hello World" isLoading />
41+
* ```
42+
*
43+
* @example With start icon
44+
* ```tsx
45+
* <Button text="Hello World" startIcon={<ICCube />} />
46+
* ```
47+
*
48+
* @example With end icon
49+
* ```tsx
50+
* <Button text="Hello World" endIcon={<ICCube />} />
51+
* ```
52+
*
53+
* @example With tippy
54+
* ```tsx
55+
* <Button text="Hello World" showTippy tippyContent="Tippy content" />
56+
* ```
57+
*
58+
*/
959
const Button = ({
1060
variant = ButtonVariantType.primary,
1161
size = ComponentSizeType.large,

src/Shared/Components/Button/button.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
color: $text-color;
44
border: 1px solid $border-color;
55

6+
// Only stroke icons are supposed to be used with button
67
svg,
78
svg * {
89
stroke: $text-color;
910
}
1011

1112
// Custom state for loader
13+
// Added using css to ensure using the respective text-color
1214
.loader {
1315
visibility: visible;
1416
position: absolute;
@@ -102,6 +104,7 @@
102104
}
103105
}
104106

107+
// Base styling is same for text and link button
105108
&__text,
106109
&__link {
107110
$background: transparent;
@@ -128,6 +131,7 @@
128131
}
129132
}
130133

134+
// Pseudo states for text button
131135
&__text {
132136
&--default {
133137
@include pseudo-states(var(--B100), var(--B200));
@@ -150,6 +154,7 @@
150154
}
151155
}
152156

157+
// Overrides for link button
153158
&__link {
154159

155160
&--default,
@@ -167,6 +172,7 @@
167172
}
168173
}
169174

175+
// Hide the visibility for the button child elements when loading is true
170176
&--loading>* {
171177
visibility: hidden;
172178
}

src/Shared/Components/Button/types.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,49 @@ export enum ButtonStyleType {
1818
}
1919

2020
export type ButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'styles' | 'className'> & {
21+
/**
22+
* Variant of the button
23+
*
24+
* @default 'ButtonVariantType.primary'
25+
*/
2126
variant?: ButtonVariantType
27+
/**
28+
* Size of the button
29+
*
30+
* @default 'ComponentSizeType.large'
31+
*/
2232
size?: ComponentSizeType
33+
/**
34+
* Style to be applied on the button
35+
*
36+
* @default 'ButtonStyleType.default'
37+
*/
2338
style?: ButtonStyleType
39+
/**
40+
* Text to be displayed in the button
41+
*/
2442
text: string
43+
/**
44+
* If provided, icon to be displayed at the start of the button
45+
*/
2546
startIcon?: ReactElement
47+
/**
48+
* If provided, icon to be displayed at the end of the button
49+
*/
2650
endIcon?: ReactElement
51+
/**
52+
* If true, the loading state is shown for the button with disabled
53+
*/
2754
isLoading?: boolean
2855
} & (
2956
| {
57+
/**
58+
* If true, the tippy is shown for the button
59+
*/
3060
showTippy: boolean
61+
/**
62+
* Tippy content to be shown for use cases like disabled etc
63+
*/
3164
tippyContent: TooltipProps['content']
3265
}
3366
| {

0 commit comments

Comments
 (0)