Skip to content

Commit 23fdfa0

Browse files
committed
fix: min width for button and code clean up
1 parent 6cdd169 commit 23fdfa0

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed

src/Shared/Components/Button/constants.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { ProgressingProps } from '@Common/Types'
33
import { ButtonProps } from './types'
44

55
export const BUTTON_SIZE_TO_CLASS_NAME_MAP: Record<ButtonProps['size'], string> = {
6-
[ComponentSizeType.xs]: 'px-9 py-1 fs-12 lh-20 fw-6 dc__gap-6',
7-
[ComponentSizeType.small]: 'px-9 py-3 fs-12 lh-20 fw-6 dc__gap-6',
8-
[ComponentSizeType.medium]: 'px-11 py-5 fs-13 lh-20 fw-6 dc__gap-8',
9-
[ComponentSizeType.large]: 'px-13 py-7 fs-13 lh-20 fw-6 dc__gap-10',
10-
[ComponentSizeType.xl]: 'px-15 py-9 fs-14 lh-20 fw-6 dc__gap-12',
6+
[ComponentSizeType.xs]: 'px-9 py-1 fs-12 lh-20 fw-6 dc__gap-6 mw-48',
7+
[ComponentSizeType.small]: 'px-9 py-3 fs-12 lh-20 fw-6 dc__gap-8 mw-48',
8+
[ComponentSizeType.medium]: 'px-11 py-5 fs-13 lh-20 fw-6 dc__gap-8 mw-48',
9+
[ComponentSizeType.large]: 'px-13 py-7 fs-13 lh-20 fw-6 dc__gap-10 mw-64',
10+
[ComponentSizeType.xl]: 'px-15 py-9 fs-14 lh-20 fw-6 dc__gap-12 mw-64',
1111
} as const
1212

1313
export const ICON_BUTTON_SIZE_TO_CLASS_NAME_MAP: Record<ButtonProps['size'], string> = {
@@ -18,31 +18,15 @@ export const ICON_BUTTON_SIZE_TO_CLASS_NAME_MAP: Record<ButtonProps['size'], str
1818
[ComponentSizeType.xl]: 'p-7',
1919
} as const
2020

21-
export const BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP: Record<ButtonProps['size'], string> = {
22-
[ComponentSizeType.xs]: 'icon-dim-12',
23-
[ComponentSizeType.small]: 'icon-dim-12',
24-
[ComponentSizeType.medium]: 'icon-dim-16',
25-
[ComponentSizeType.large]: 'icon-dim-16',
26-
[ComponentSizeType.xl]: 'icon-dim-20',
27-
} as const
28-
29-
export const ICON_BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP: Record<ButtonProps['size'], string> = {
30-
[ComponentSizeType.xs]: 'icon-dim-16',
31-
[ComponentSizeType.small]: 'icon-dim-16',
32-
[ComponentSizeType.medium]: 'icon-dim-16',
33-
[ComponentSizeType.large]: 'icon-dim-20',
34-
[ComponentSizeType.xl]: 'icon-dim-24',
35-
} as const
36-
37-
export const BUTTON_SIZE_TO_LOADER_SIZE_MAP: Record<ButtonProps['size'], ProgressingProps['size']> = {
21+
export const BUTTON_SIZE_TO_ICON_SIZE_MAP: Record<ButtonProps['size'], ProgressingProps['size']> = {
3822
[ComponentSizeType.xs]: 12,
39-
[ComponentSizeType.small]: 12,
23+
[ComponentSizeType.small]: 16,
4024
[ComponentSizeType.medium]: 16,
4125
[ComponentSizeType.large]: 16,
4226
[ComponentSizeType.xl]: 20,
4327
} as const
4428

45-
export const ICON_BUTTON_SIZE_TO_LOADER_SIZE_MAP: Record<ButtonProps['size'], ProgressingProps['size']> = {
29+
export const ICON_BUTTON_SIZE_TO_ICON_SIZE_MAP: Record<ButtonProps['size'], ProgressingProps['size']> = {
4630
[ComponentSizeType.xs]: 16,
4731
[ComponentSizeType.small]: 16,
4832
[ComponentSizeType.medium]: 16,

src/Shared/Components/Button/utils.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
import {
22
BUTTON_SIZE_TO_CLASS_NAME_MAP,
3-
BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP,
4-
BUTTON_SIZE_TO_LOADER_SIZE_MAP,
3+
BUTTON_SIZE_TO_ICON_SIZE_MAP,
54
ICON_BUTTON_SIZE_TO_CLASS_NAME_MAP,
6-
ICON_BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP,
7-
ICON_BUTTON_SIZE_TO_LOADER_SIZE_MAP,
5+
ICON_BUTTON_SIZE_TO_ICON_SIZE_MAP,
86
} from './constants'
97
import { ButtonProps } from './types'
108

119
export const getButtonIconClassName = ({ size, icon }: Pick<ButtonProps, 'size' | 'icon'>) => {
12-
if (icon) {
13-
return ICON_BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP[size]
14-
}
10+
const iconSize = icon ? ICON_BUTTON_SIZE_TO_ICON_SIZE_MAP[size] : BUTTON_SIZE_TO_ICON_SIZE_MAP[size]
1511

16-
return BUTTON_SIZE_TO_ICON_CLASS_NAME_MAP[size]
12+
return `icon-dim-${iconSize}`
1713
}
1814

1915
export const getButtonLoaderSize = ({ size, icon }: Pick<ButtonProps, 'size' | 'icon'>) => {
2016
if (icon) {
21-
return ICON_BUTTON_SIZE_TO_LOADER_SIZE_MAP[size]
17+
return ICON_BUTTON_SIZE_TO_ICON_SIZE_MAP[size]
2218
}
2319

24-
return BUTTON_SIZE_TO_LOADER_SIZE_MAP[size]
20+
return BUTTON_SIZE_TO_ICON_SIZE_MAP[size]
2521
}
2622

2723
export const getButtonDerivedClass = ({
@@ -31,4 +27,4 @@ export const getButtonDerivedClass = ({
3127
isLoading,
3228
icon,
3329
}: Pick<ButtonProps, 'variant' | 'size' | 'style' | 'isLoading' | 'icon'>) =>
34-
`button button__${variant}--${style} ${icon ? ICON_BUTTON_SIZE_TO_CLASS_NAME_MAP[size] : `${BUTTON_SIZE_TO_CLASS_NAME_MAP[size]} mw-64`} ${isLoading ? 'button--loading' : ''}`
30+
`button button__${variant}--${style} ${icon ? ICON_BUTTON_SIZE_TO_CLASS_NAME_MAP[size] : BUTTON_SIZE_TO_CLASS_NAME_MAP[size]} ${isLoading ? 'button--loading' : ''}`

0 commit comments

Comments
 (0)