Skip to content

Commit 6505075

Browse files
committed
🏷️ Move React type definitions to type files
1 parent f2a146e commit 6505075

File tree

21 files changed

+59
-61
lines changed

21 files changed

+59
-61
lines changed

src/components/Alert/Alert.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import type { AlertProps } from './alert'
2+
import type { ReactAlertProps } from './alert'
33
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
44

55
import info from '../../icons/info.svg?raw'
@@ -16,13 +16,6 @@ const iconMap = {
1616
alert
1717
}
1818

19-
type ReactAlertProps = {
20-
Element?: keyof JSX.IntrinsicElements
21-
TitleTag?: keyof JSX.IntrinsicElements
22-
children: React.ReactNode
23-
icon?: string
24-
} & AlertProps
25-
2619
const Alert = ({
2720
Element = 'section',
2821
title,

src/components/Alert/alert.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ export type AlertProps = {
1010
| 'alert'
1111
| null
1212
}
13+
14+
export type ReactAlertProps = {
15+
Element?: keyof JSX.IntrinsicElements
16+
TitleTag?: keyof JSX.IntrinsicElements
17+
children: React.ReactNode
18+
} & Omit<AlertProps, 'titleTag' | 'element'>

src/components/Badge/Badge.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import React from 'react'
2-
import type { BadgeProps } from './badge'
2+
import type { ReactBadgeProps } from './badge'
33
import './badge.scss'
44

5-
type ReactBadgeProps = {
6-
children: React.ReactNode
7-
} & BadgeProps
8-
95
const Badge = ({ theme, onClick, children, ...rest }: ReactBadgeProps) => {
106
const classes = [
117
'w-badge',

src/components/Badge/badge.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ export type BadgeProps = {
99
| null
1010
onClick?: () => any
1111
}
12+
13+
export type ReactBadgeProps = {
14+
children: React.ReactNode
15+
} & BadgeProps

src/components/Button/Button.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import React from 'react'
2-
import type { ButtonProps } from './button'
2+
import type { ReactButtonProps } from './button'
33
import './button.scss'
44

5-
type ReactButtonProps = {
6-
children: React.ReactNode
7-
} & ButtonProps
8-
95
const Button = ({
106
theme,
117
bold,

src/components/Button/button.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ export type ButtonProps = {
1212
onClick?: () => any
1313
[key: string]: any
1414
}
15+
16+
export type ReactButtonProps = {
17+
children: React.ReactNode
18+
} & ButtonProps

src/components/Card/Card.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import React from 'react'
2-
import type { CardProps } from './card'
2+
import type { ReactCardProps } from './card'
33
import './card.scss'
44

5-
type ReactCardProps = {
6-
Element?: keyof JSX.IntrinsicElements
7-
TitleTag?: keyof JSX.IntrinsicElements
8-
children: React.ReactNode
9-
} & CardProps
10-
115
const Card = ({
126
Element = 'section',
137
title,

src/components/Card/card.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ export type CardProps = {
77
secondary?: boolean
88
[key: string]: any
99
}
10+
11+
export type ReactCardProps = {
12+
Element?: keyof JSX.IntrinsicElements
13+
TitleTag?: keyof JSX.IntrinsicElements
14+
children: React.ReactNode
15+
} & Omit<CardProps, 'titleTag' | 'element'>

src/components/Checkbox/Checkbox.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import React from 'react'
2-
import type { CheckboxProps } from './checkbox'
2+
import type { ReactCheckboxProps } from './checkbox'
33
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
44

55
import check from '../../icons/check.svg?raw'
66

77
import './checkbox.scss'
88

9-
type ReactCheckboxProps = {
10-
onClick?: (key: any) => any
11-
} & CheckboxProps
12-
139
const Checkbox = ({
1410
checked,
1511
label,

src/components/Checkbox/checkbox.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ export type CheckboxProps = {
66
boxed?: boolean
77
color?: string
88
}
9+
10+
export type ReactCheckboxProps = {
11+
onClick?: (key: any) => any
12+
} & CheckboxProps
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import React from 'react'
22
import type { ConditionalWrapperProps } from './conditionalwrapper'
33

4-
type ExtendedConditionalWrapperProps = {
5-
condition: ConditionalWrapperProps['condition']
4+
type ReactConditionalWrapperProps = {
65
wrapper: (_: React.ReactNode) => any
76
children: React.ReactNode
8-
};
7+
} & ConditionalWrapperProps
98

10-
const ConditionalWrapper = ({ condition, wrapper, children }: ExtendedConditionalWrapperProps) =>
9+
const ConditionalWrapper = ({ condition, wrapper, children }: ReactConditionalWrapperProps) =>
1110
condition ? wrapper(children) : children
1211

1312
export default ConditionalWrapper

src/components/Radio/Radio.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import React from 'react'
2-
import type { RadioProps } from './radio'
2+
import type { ReactRadioProps } from './radio'
33

44
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
55

66
import './radio.scss'
77

8-
type ReactRadioProps = {
9-
onChange?: (key: any) => any
10-
} & RadioProps
11-
128
const Radio = ({
139
name,
1410
items,

src/components/Radio/radio.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ export type RadioProps = {
1111
inline?: boolean
1212
className?: string
1313
}
14+
15+
export type ReactRadioProps = {
16+
onChange?: (key: any) => any
17+
} & RadioProps

src/components/Switch/Switch.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import React from 'react'
2-
import type { SwitchProps } from './switch'
2+
import type { ReactSwitchProps } from './switch'
33
import './switch.scss'
44

5-
type ReactSwitchProps = {
6-
onClick?: (key: any) => any
7-
} & SwitchProps
8-
95
const Switch = ({
106
label,
117
toggled,

src/components/Switch/switch.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ export type SwitchProps = {
99
disabled?: boolean
1010
className?: string
1111
}
12+
13+
export type ReactSwitchProps = {
14+
onClick?: (key: any) => any
15+
} & SwitchProps

src/components/Tabs/Tabs.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import React, { useState, useRef } from 'react'
2-
import type { TabsProps } from './tabs'
2+
import type { ReactTabsProps } from './tabs'
33

44
import './tabs.scss'
55

6-
type ReactTabsProps = {
7-
children: React.ReactNode
8-
} & TabsProps
9-
106
const Tabs = ({
117
items,
128
theme,
@@ -40,7 +36,7 @@ const Tabs = ({
4036
setActive(tab)
4137
}
4238

43-
const isActive = (item: TabsProps['items'][0]) => {
39+
const isActive = (item: ReactTabsProps['items'][0]) => {
4440
if (!active) {
4541
return item.active ? 'active' : undefined
4642
}

src/components/Tabs/tabs.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ export type TabsProps = {
1010
even?: boolean
1111
className?: string
1212
}
13+
14+
export type ReactTabsProps = {
15+
children: React.ReactNode
16+
} & TabsProps

src/components/Timeline/Timeline.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import React from 'react'
2-
import type { TimelineProps } from './timeline'
2+
import type { ReactTimelineProps } from './timeline'
33

44
import './timeline.scss'
55

6-
type ReactTimelineProps = {
7-
children: React.ReactNode
8-
} & TimelineProps
9-
106
const Timeline = ({
117
theme,
128
counter,

src/components/Timeline/timeline.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ export type TimelineProps = {
5555
| 'upper-roman'
5656
| null
5757
}
58+
59+
export type ReactTimelineProps = {
60+
children: React.ReactNode
61+
} & TimelineProps

src/components/Toast/Toast.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import React from 'react'
2-
import type { ToastProps } from './toast'
2+
import type { ReactToastProps } from './toast'
33
import Alert from '../Alert/Alert.tsx'
44

55
import './toast.scss'
66

7-
type ReactToastProps = {
8-
children: React.ReactNode
9-
icon?: string
10-
} & ToastProps
11-
127
const Toast = ({
138
icon,
149
position,

src/components/Toast/toast.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ export type ToastProps = {
44
position?: string
55
[key: string]: any
66
} & AlertProps
7+
8+
export type ReactToastProps = {
9+
children: React.ReactNode
10+
icon?: string
11+
} & ToastProps

0 commit comments

Comments
 (0)