|
| 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 | +} |
0 commit comments