Skip to content

Commit 52c53ec

Browse files
committed
Add more types
1 parent 2e1fcca commit 52c53ec

File tree

8 files changed

+101
-77
lines changed

8 files changed

+101
-77
lines changed

src/colors.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/colors.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React, { ReactNode } from 'react'
2+
import { Box, BoxProps, ThemeUIStyleObject } from 'theme-ui'
3+
4+
interface InlineColorProps extends BoxProps {
5+
sx: ThemeUIStyleObject
6+
color: string
7+
children: ReactNode
8+
}
9+
const InlineColor = ({ sx, color, children, ...props }: InlineColorProps) => {
10+
return (
11+
<Box
12+
as='span'
13+
sx={{ display: 'inline-block', color: color, ...sx }}
14+
{...props}
15+
>
16+
{children}
17+
</Box>
18+
)
19+
}
20+
21+
type ColorProps = Omit<InlineColorProps, 'color'>
22+
23+
export const Primary = (props: ColorProps) => {
24+
return <InlineColor color='primary' {...props} />
25+
}
26+
27+
export const Secondary = (props: ColorProps) => {
28+
return <InlineColor color='secondary' {...props} />
29+
}
30+
31+
export const Background = (props: ColorProps) => {
32+
return <InlineColor color='background' {...props} />
33+
}
34+
35+
export const Red = (props: ColorProps) => {
36+
return <InlineColor color='red' {...props} />
37+
}
38+
39+
export const Orange = (props: ColorProps) => {
40+
return <InlineColor color='orange' {...props} />
41+
}
42+
43+
export const Yellow = (props: ColorProps) => {
44+
return <InlineColor color='yellow' {...props} />
45+
}
46+
47+
export const Green = (props: ColorProps) => {
48+
return <InlineColor color='green' {...props} />
49+
}
50+
51+
export const Teal = (props: ColorProps) => {
52+
return <InlineColor color='teal' {...props} />
53+
}
54+
55+
export const Blue = (props: ColorProps) => {
56+
return <InlineColor color='blue' {...props} />
57+
}
58+
59+
export const Purple = (props: ColorProps) => {
60+
return <InlineColor color='purple' {...props} />
61+
}
62+
63+
export const Pink = (props: ColorProps) => {
64+
return <InlineColor color='pink' {...props} />
65+
}
66+
67+
export const Grey = (props: ColorProps) => {
68+
return <InlineColor color='grey' {...props} />
69+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import { Box } from 'theme-ui'
3+
// @ts-ignore
34
import { PoopSad } from '@carbonplan/emoji'
45
import Layout from './layout'
56
import Row from './row'

src/expander.js renamed to src/expander.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import React from 'react'
2-
import { Box, IconButton } from 'theme-ui'
2+
import { IconButton, IconButtonProps } from 'theme-ui'
33

4-
const Expander = ({ value, id, onClick, sx }) => {
4+
export interface ExpanderProps {
5+
value: IconButtonProps['aria-checked']
6+
id: IconButtonProps['id']
7+
onClick: IconButtonProps['onClick']
8+
sx: IconButtonProps['sx']
9+
}
10+
const Expander = ({ value, id, onClick, sx }: ExpanderProps) => {
511
return (
612
<IconButton
713
onClick={onClick}

src/fade-in.js renamed to src/fade-in.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { Box } from 'theme-ui'
2+
import { Box, BoxProps } from 'theme-ui'
33
import { keyframes } from '@emotion/react'
44

55
const fade = keyframes({
@@ -11,7 +11,17 @@ const fade = keyframes({
1111
},
1212
})
1313

14-
const FadeIn = ({ duration = 300, delay = 0, children, ...delegated }) => {
14+
export interface FadeInProps extends BoxProps {
15+
duration?: number
16+
delay?: number
17+
}
18+
19+
const FadeIn = ({
20+
duration = 300,
21+
delay = 0,
22+
children,
23+
...delegated
24+
}: FadeInProps) => {
1525
return (
1626
<Box
1727
{...delegated}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import React from 'react'
2-
import Caption from './caption'
2+
import Caption, { CaptionProps } from './caption'
33

4-
const FigureCaption = ({ as = 'figcaption', number, children }) => {
4+
const FigureCaption = ({
5+
as = 'figcaption',
6+
number,
7+
children,
8+
}: CaptionProps) => {
59
return (
610
<Caption as={as} number={number} label='figure'>
711
{children}

src/figure.js renamed to src/figure.tsx

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

44
import Group from './group'
55

6-
const Figure = ({ as = 'figure', children, sx }) => {
6+
const Figure = ({ as = 'figure', children, sx }: BoxProps) => {
77
return (
88
<Box
99
as={as}

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ export { default as Button, ButtonProps } from './button'
66
export { default as Callout, CalloutProps } from './callout'
77
export { default as Caption, CaptionProps } from './caption'
88
export { default as Colorbar, ColorbarProps } from './colorbar'
9-
export { default as Colors } from './colors'
9+
export * as Colors from './colors'
1010
export { default as Column, ColumnProps } from './column'
1111
export { default as Custom404 } from './custom-404'
1212
export { default as Dimmer, DimmerProps } from './dimmer'
13-
export { default as Expander } from './expander'
14-
export { default as FadeIn } from './fade-in'
13+
export { default as Expander, ExpanderProps } from './expander'
14+
export { default as FadeIn, FadeInProps } from './fade-in'
1515
export { default as Figure } from './figure'
1616
export { default as FigureCaption } from './figure-caption'
1717
export { default as Filter } from './filter'

0 commit comments

Comments
 (0)