Skip to content

Commit 95faa76

Browse files
committed
refactor: rename SwitchProps to DTSwitchProps for consistency across Switch component
1 parent 5ff39fc commit 95faa76

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

src/Shared/Components/Switch/Switch.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getUniqueId } from '@Shared/Helpers'
77

88
import { Icon } from '../Icon'
99
import { INDETERMINATE_ICON_WIDTH_MAP, LOADING_COLOR_MAP } from './constants'
10-
import { SwitchProps } from './types'
10+
import { DTSwitchProps } from './types'
1111
import {
1212
getSwitchContainerClass,
1313
getSwitchIconColor,
@@ -32,7 +32,7 @@ const Switch = ({
3232
size = ComponentSizeType.medium,
3333
name,
3434
onChange,
35-
}: SwitchProps) => {
35+
}: DTSwitchProps) => {
3636
const inputId = useRef(getUniqueId())
3737

3838
const getAriaCheckedValue = (): AriaAttributes['aria-checked'] => {
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { ComponentSizeType } from '@Shared/constants'
22
import { IconBaseColorType } from '@Shared/types'
33

4-
import { SwitchProps } from './types'
4+
import { DTSwitchProps } from './types'
55

6-
export const SWITCH_VARIANTS: Readonly<Record<SwitchProps['variant'], null>> = {
6+
export const SWITCH_VARIANTS: Readonly<Record<DTSwitchProps['variant'], null>> = {
77
theme: null,
88
positive: null,
99
}
1010

11-
export const SWITCH_SHAPES: Readonly<Record<SwitchProps['shape'], null>> = {
11+
export const SWITCH_SHAPES: Readonly<Record<DTSwitchProps['shape'], null>> = {
1212
rounded: null,
1313
square: null,
1414
}
1515

16-
export const ROUNDED_SWITCH_SIZE_MAP: Readonly<Record<SwitchProps['size'], string>> = {
16+
export const ROUNDED_SWITCH_SIZE_MAP: Readonly<Record<DTSwitchProps['size'], string>> = {
1717
[ComponentSizeType.medium]: 'w-32',
1818
[ComponentSizeType.small]: 'w-24',
1919
}
@@ -23,17 +23,17 @@ export const SQUARE_SWITCH_SIZE_MAP: typeof ROUNDED_SWITCH_SIZE_MAP = {
2323
[ComponentSizeType.small]: 'w-24',
2424
}
2525

26-
export const SWITCH_HEIGHT_MAP: Readonly<Record<SwitchProps['size'], string>> = {
26+
export const SWITCH_HEIGHT_MAP: Readonly<Record<DTSwitchProps['size'], string>> = {
2727
[ComponentSizeType.medium]: 'h-24',
2828
[ComponentSizeType.small]: 'h-20',
2929
}
3030

31-
export const LOADING_COLOR_MAP: Record<SwitchProps['variant'], IconBaseColorType> = {
31+
export const LOADING_COLOR_MAP: Record<DTSwitchProps['variant'], IconBaseColorType> = {
3232
theme: 'B500',
3333
positive: 'G500',
3434
}
3535

36-
export const ROUNDED_SWITCH_TRACK_COLOR_MAP: Record<SwitchProps['variant'], string> = {
36+
export const ROUNDED_SWITCH_TRACK_COLOR_MAP: Record<DTSwitchProps['variant'], string> = {
3737
theme: 'bcb-5',
3838
positive: 'bcg-5',
3939
}
@@ -43,22 +43,22 @@ export const SQUARE_SWITCH_TRACK_COLOR_MAP: typeof ROUNDED_SWITCH_TRACK_COLOR_MA
4343
positive: 'bcg-3',
4444
}
4545

46-
export const ROUNDED_SWITCH_THUMB_SIZE_MAP: Record<SwitchProps['size'], string> = {
46+
export const ROUNDED_SWITCH_THUMB_SIZE_MAP: Record<DTSwitchProps['size'], string> = {
4747
[ComponentSizeType.medium]: 'icon-dim-16',
4848
[ComponentSizeType.small]: 'icon-dim-12',
4949
}
5050

51-
export const INDETERMINATE_ICON_WIDTH_MAP: Record<SwitchProps['size'], string> = {
51+
export const INDETERMINATE_ICON_WIDTH_MAP: Record<DTSwitchProps['size'], string> = {
5252
[ComponentSizeType.medium]: 'w-12',
5353
[ComponentSizeType.small]: 'w-10',
5454
}
5555

56-
export const SWITCH_THUMB_PADDING_MAP: Record<SwitchProps['size'], string> = {
56+
export const SWITCH_THUMB_PADDING_MAP: Record<DTSwitchProps['size'], string> = {
5757
[ComponentSizeType.medium]: 'p-3',
5858
[ComponentSizeType.small]: 'p-1',
5959
}
6060

61-
export const THUMB_OUTER_PADDING_MAP: Record<SwitchProps['shape'], string> = {
61+
export const THUMB_OUTER_PADDING_MAP: Record<DTSwitchProps['shape'], string> = {
6262
rounded: 'p-2',
6363
square: 'p-1',
6464
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { SWITCH_SHAPES, SWITCH_VARIANTS } from './constants'
2-
export { default as Switch } from './Switch.component'
3-
export type { SwitchProps } from './types'
2+
export { default as DTSwitch } from './Switch.component'
3+
export type { DTSwitchProps } from './types'

src/Shared/Components/Switch/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type SwitchShapeProps =
6363
/**
6464
* Represents the properties for the `Switch` component.
6565
*/
66-
export type SwitchProps = {
66+
export type DTSwitchProps = {
6767
/**
6868
* The ARIA label for the switch, used for accessibility purposes.
6969
*/

src/Shared/Components/Switch/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ import {
1010
SWITCH_THUMB_PADDING_MAP,
1111
THUMB_OUTER_PADDING_MAP,
1212
} from './constants'
13-
import { SwitchProps } from './types'
13+
import { DTSwitchProps } from './types'
1414

15-
export const getSwitchContainerClass = ({ shape, size }: Required<Pick<SwitchProps, 'shape' | 'size'>>): string =>
15+
export const getSwitchContainerClass = ({ shape, size }: Required<Pick<DTSwitchProps, 'shape' | 'size'>>): string =>
1616
`${SWITCH_HEIGHT_MAP[size]} ${shape === 'rounded' ? ROUNDED_SWITCH_SIZE_MAP[size] : SQUARE_SWITCH_SIZE_MAP[size]}`
1717

1818
export const getSwitchTrackColor = ({
1919
shape,
2020
variant,
2121
isChecked,
2222
isLoading,
23-
}: Required<Pick<SwitchProps, 'shape' | 'variant' | 'isChecked' | 'isLoading'>>): string => {
23+
}: Required<Pick<DTSwitchProps, 'shape' | 'variant' | 'isChecked' | 'isLoading'>>): string => {
2424
if (isLoading) {
2525
return 'dc__transparent--unstyled'
2626
}
@@ -36,7 +36,7 @@ export const getSwitchThumbClass = ({
3636
shape,
3737
size,
3838
showIndeterminateIcon,
39-
}: Pick<SwitchProps, 'shape' | 'size'> & { showIndeterminateIcon: boolean }) => {
39+
}: Pick<DTSwitchProps, 'shape' | 'size'> & { showIndeterminateIcon: boolean }) => {
4040
if (showIndeterminateIcon) {
4141
return 'w-100 h-100 flex'
4242
}
@@ -48,7 +48,7 @@ export const getSwitchIconColor = ({
4848
iconColor,
4949
isChecked,
5050
variant,
51-
}: Pick<SwitchProps, 'iconColor' | 'isChecked' | 'variant'>): IconBaseColorType => {
51+
}: Pick<DTSwitchProps, 'iconColor' | 'isChecked' | 'variant'>): IconBaseColorType => {
5252
if (!isChecked) {
5353
return 'N200'
5454
}
@@ -59,15 +59,15 @@ export const getSwitchIconColor = ({
5959
export const getThumbPosition = ({
6060
isLoading,
6161
isChecked,
62-
}: Pick<SwitchProps, 'isLoading' | 'isChecked'>): 'left' | 'right' | 'center' => {
62+
}: Pick<DTSwitchProps, 'isLoading' | 'isChecked'>): 'left' | 'right' | 'center' => {
6363
if (isLoading) {
6464
return 'center'
6565
}
6666

6767
return isChecked ? 'right' : 'left'
6868
}
6969

70-
export const getThumbPadding = ({ shape, isLoading }: Pick<SwitchProps, 'shape' | 'isLoading'>): string => {
70+
export const getThumbPadding = ({ shape, isLoading }: Pick<DTSwitchProps, 'shape' | 'isLoading'>): string => {
7171
if (isLoading) {
7272
return ''
7373
}

0 commit comments

Comments
 (0)