Skip to content

Commit c60a02e

Browse files
committed
extend native element attributes, remove redundant prop declarations
1 parent a8aba44 commit c60a02e

8 files changed

Lines changed: 33 additions & 16 deletions

File tree

src/button.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import getSxColor from './utils/get-sx-color'
77
const hasCustomHover = (comp: unknown): comp is { hover: ThemeUIStyleObject } =>
88
comp != null && typeof comp === 'object' && 'hover' in comp
99

10-
export interface ButtonProps extends Omit<BoxProps, 'prefix'> {
10+
export interface ButtonProps
11+
extends Omit<BoxProps, 'prefix'>,
12+
Omit<
13+
React.ButtonHTMLAttributes<HTMLButtonElement>,
14+
keyof BoxProps | 'prefix'
15+
> {
1116
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
1217
align?:
1318
| 'baseline'

src/callout.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import { Box, ThemeUIStyleObject } from 'theme-ui'
33
import { Arrow } from '@carbonplan/icons'
44
import Link from './link'
55

6-
export interface CalloutProps extends React.AnchorHTMLAttributes<HTMLElement> {
6+
export interface CalloutProps
7+
extends React.AnchorHTMLAttributes<HTMLElement>,
8+
Omit<
9+
React.ButtonHTMLAttributes<HTMLButtonElement>,
10+
keyof React.AnchorHTMLAttributes<HTMLElement>
11+
> {
712
label: ReactNode
813
children: ReactNode
914
inverted?: boolean
10-
color?: string
11-
href?: string
1215
internal?: boolean
1316
sx?: ThemeUIStyleObject
1417
}

src/colorbar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export interface ColorbarProps extends FlexProps {
2929
discrete?: boolean
3030
horizontal?: boolean
3131
bottom?: boolean
32-
sx?: ThemeUIStyleObject
3332
sxClim?: ThemeUIStyleObject
3433
}
3534
const styles = {

src/colors.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { ReactNode } from 'react'
2-
import { Box, BoxProps, ThemeUIStyleObject } from 'theme-ui'
2+
import { Box, BoxProps } from 'theme-ui'
33

44
interface InlineColorProps extends BoxProps {
5-
sx?: ThemeUIStyleObject
65
color: string
76
children: ReactNode
87
}

src/input.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import React, { forwardRef } from 'react'
2-
import { Input as ThemedInput, ThemeUIStyleObject } from 'theme-ui'
2+
import { Input as ThemedInput } from 'theme-ui'
33
import getSizeStyles from './utils/get-size-styles'
44

55
export interface InputProps
66
extends Omit<React.ComponentPropsWithRef<typeof ThemedInput>, 'size'> {
77
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
88
inverted?: boolean
9-
sx?: ThemeUIStyleObject
109
}
1110

1211
const Input = (

src/select.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import React, { ReactNode, useRef } from 'react'
1+
import React, { useRef } from 'react'
22
import { Box, BoxProps, ThemeUIStyleObject } from 'theme-ui'
33
import { Arrow } from '@carbonplan/icons'
44
import getSizeStyles from './utils/get-size-styles'
55
import getSxColor from './utils/get-sx-color'
66

7-
export interface SelectProps extends Omit<BoxProps, 'onChange'> {
7+
export interface SelectProps
8+
extends Omit<BoxProps, 'onChange'>,
9+
Omit<
10+
React.SelectHTMLAttributes<HTMLSelectElement>,
11+
keyof BoxProps | 'onChange' | 'size'
12+
> {
813
size?: 'xs' | 'sm' | 'md'
914
sxSelect?: ThemeUIStyleObject
1015
onChange?: React.ChangeEventHandler<HTMLSelectElement>
11-
children: ReactNode
1216
}
1317

1418
const Select = ({

src/tag.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import React from 'react'
22
import { Box, BoxProps } from 'theme-ui'
33
import getSxColor from './utils/get-sx-color'
44

5-
export interface TagProps extends BoxProps {
5+
export interface TagProps
6+
extends BoxProps,
7+
Omit<
8+
React.ButtonHTMLAttributes<HTMLButtonElement>,
9+
keyof BoxProps | 'value'
10+
> {
611
label: BoxProps['aria-label']
712
value?: boolean
813
}

src/toggle.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ import { Box, BoxProps } from 'theme-ui'
33
import { transparentize } from '@theme-ui/color'
44
import getSxColor from './utils/get-sx-color'
55

6-
export interface ToggleProps extends Omit<BoxProps, 'value'> {
6+
export interface ToggleProps
7+
extends Omit<BoxProps, 'value'>,
8+
Omit<
9+
React.ButtonHTMLAttributes<HTMLButtonElement>,
10+
keyof BoxProps | 'value'
11+
> {
712
value?: boolean
8-
onClick?: React.MouseEventHandler<HTMLElement>
9-
disabled?: boolean
1013
}
1114

1215
const Toggle = (

0 commit comments

Comments
 (0)