diff --git a/types/rebass/index.d.ts b/types/rebass/index.d.ts index a3c013a8c7..aae5915751 100644 --- a/types/rebass/index.d.ts +++ b/types/rebass/index.d.ts @@ -11,9 +11,9 @@ // TypeScript Version: 3.1 import { ResponsiveStyleValue, SystemStyleObject } from '@styled-system/css'; -import * as React from "react"; -import * as StyledComponents from "styled-components"; -import * as StyledSystem from "styled-system"; +import * as React from 'react'; +import * as StyledComponents from 'styled-components'; +import * as StyledSystem from 'styled-system'; export {}; @@ -21,10 +21,7 @@ type Omit = Pick>; export interface BaseProps extends React.RefAttributes { as?: React.ElementType; - css?: - | StyledComponents.CSSObject - | StyledComponents.FlattenSimpleInterpolation - | string; + css?: StyledComponents.CSSObject | StyledComponents.FlattenSimpleInterpolation | string; } /** @@ -32,13 +29,14 @@ export interface BaseProps extends React.RefAttributes { * such that properties that are part of the `Theme` will be transformed to * their corresponding values. Other valid CSS properties are also allowed. */ -export type SxStyleProp = SystemStyleObject | - Record< - string, - | SystemStyleObject - | ResponsiveStyleValue - | Record> - >; +export type SxStyleProp = + | SystemStyleObject + | Record< + string, + | SystemStyleObject + | ResponsiveStyleValue + | Record> + >; export interface SxProps { /** @@ -60,23 +58,16 @@ interface BoxKnownProps variant?: StyledSystem.ResponsiveValue; tx?: string; } -export interface BoxProps - extends BoxKnownProps, - Omit, keyof BoxKnownProps> {} +export interface BoxProps extends BoxKnownProps, Omit, keyof BoxKnownProps> {} export const Box: React.FunctionComponent; -interface ButtonKnownProps - extends BoxKnownProps, - StyledSystem.FontWeightProps, - StyledSystem.ButtonStyleProps {} +interface ButtonKnownProps extends BoxKnownProps, StyledSystem.FontWeightProps, StyledSystem.ButtonStyleProps {} export interface ButtonProps extends ButtonKnownProps, Omit, keyof ButtonKnownProps> {} export const Button: React.FunctionComponent; -export interface CardProps - extends BoxKnownProps, - Omit, keyof BoxKnownProps> {} +export interface CardProps extends BoxKnownProps, Omit, keyof BoxKnownProps> {} export const Card: React.FunctionComponent; interface FlexKnownProps @@ -85,21 +76,15 @@ interface FlexKnownProps StyledSystem.FlexDirectionProps, StyledSystem.AlignItemsProps, StyledSystem.JustifyContentProps {} -export interface FlexProps - extends FlexKnownProps, - Omit, keyof FlexKnownProps> {} +export interface FlexProps extends FlexKnownProps, Omit, keyof FlexKnownProps> {} export const Flex: React.FunctionComponent; -export interface ImageProps - extends BoxKnownProps, - Omit, keyof BoxKnownProps> {} +export interface ImageProps extends BoxKnownProps, Omit, keyof BoxKnownProps> {} export const Image: React.FunctionComponent; // tslint:disable-next-line no-empty-interface interface LinkKnownProps extends BoxKnownProps {} -export interface LinkProps - extends LinkKnownProps, - Omit, keyof LinkKnownProps> {} +export interface LinkProps extends LinkKnownProps, Omit, keyof LinkKnownProps> {} export const Link: React.FunctionComponent; interface TextKnownProps @@ -109,12 +94,8 @@ interface TextKnownProps StyledSystem.TextAlignProps, StyledSystem.LineHeightProps, StyledSystem.LetterSpacingProps {} -export interface TextProps - extends TextKnownProps, - Omit, keyof TextKnownProps> {} +export interface TextProps extends TextKnownProps, Omit, keyof TextKnownProps> {} export const Text: React.FunctionComponent; -export interface HeadingProps - extends TextKnownProps, - Omit, keyof TextKnownProps> {} +export interface HeadingProps extends TextKnownProps, Omit, keyof TextKnownProps> {} export const Heading: React.FunctionComponent; diff --git a/types/rebass/rebass-tests.tsx b/types/rebass/rebass-tests.tsx index 2c6cc611bd..3b4b471c87 100644 --- a/types/rebass/rebass-tests.tsx +++ b/types/rebass/rebass-tests.tsx @@ -1,7 +1,8 @@ -import * as React from "react"; -import styled, { css } from "styled-components"; -import { Box, Flex, Text, Heading, Button, Link, Image, Card, BoxProps } from "rebass"; -import "styled-components/macro"; +import * as React from 'react'; +import styled, { css } from 'styled-components'; +import { Box, Flex, Text, Heading, Button, Link, Image, Card, BoxProps } from 'rebass'; +import { Box as StyledBox } from 'rebass/styled-components'; +import 'styled-components/macro'; const CustomComponent: React.FunctionComponent = ({ children }) => { return
{children}
; @@ -12,11 +13,12 @@ const ExtendedBox = styled(Box)` `; ExtendedBox.defaultProps = { - p: 3 + p: 3, }; -const RefForwardingBox = React.forwardRef((props, ref) => - ); +const RefForwardingBox = React.forwardRef((props, ref) => ( + +)); const boxCss = css` background: purple; @@ -28,7 +30,7 @@ const CssBox = () => ; const VariantBox = () => ; export default () => ( - + Hi, I'm a heading. @@ -39,8 +41,8 @@ export default () => ( ( width={[1, 1, 1 / 2]} src="https://source.unsplash.com/random/1280x720" sx={{ - borderRadius: "1em" + borderRadius: '1em', }} /> Link - @@ -77,16 +81,21 @@ export default () => ( > String css prop - + + Styled Box + ); diff --git a/types/rebass/styled-components.d.ts b/types/rebass/styled-components.d.ts new file mode 100644 index 0000000000..ea465c2a34 --- /dev/null +++ b/types/rebass/styled-components.d.ts @@ -0,0 +1 @@ +export * from './index';