grid-styled types

This commit is contained in:
Anton Vasin
2018-02-06 14:41:42 +03:00
parent e5c1512ab6
commit 2757d317ab
5 changed files with 116 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
import * as React from "react";
import { Flex, Box } from "grid-styled";
const Layout = () => (
<Flex m={4}>
<Box px={3} py={2} />
</Flex>
);

76
types/grid-styled/index.d.ts vendored Normal file
View File

@@ -0,0 +1,76 @@
// Type definitions for grid-styled 3.0
// Project: https://github.com/jxnblk/grid-styled
// Definitions by: Anton Vasin <https://github.com/antonvasin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
export type Diff<T extends string, U extends string> = ({ [P in T]: P } &
{ [P in U]: never } & { [x: string]: never })[T];
export type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;
import { ComponentClass } from "react";
import { StyledComponentClass } from "styled-components";
export type ResponsiveProp = number | string | Array<string | number>;
export interface CommonProps {
width: ResponsiveProp;
fontSize: ResponsiveProp;
color: ResponsiveProp;
bg: ResponsiveProp;
m: ResponsiveProp;
mt: ResponsiveProp;
mr: ResponsiveProp;
mb: ResponsiveProp;
ml: ResponsiveProp;
mx: ResponsiveProp;
my: ResponsiveProp;
p: ResponsiveProp;
pt: ResponsiveProp;
pr: ResponsiveProp;
pb: ResponsiveProp;
pl: ResponsiveProp;
px: ResponsiveProp;
py: ResponsiveProp;
theme: any;
}
export interface BoxProps
extends Omit<React.HTMLProps<HTMLDivElement>, "width" | "wrap" | "is"> {
flex: ResponsiveProp;
order: ResponsiveProp;
is: string | ComponentClass<any>;
}
export interface FlexProps extends BoxProps {
wrap: ResponsiveProp | boolean;
direction: ResponsiveProp | boolean;
align: ResponsiveProp | boolean;
justify: ResponsiveProp | boolean;
column: boolean;
}
export type BoxComponent = StyledComponentClass<
Partial<CommonProps & BoxProps>,
any
>;
export type FlexComponent = StyledComponentClass<
Partial<CommonProps & FlexProps>,
any
>;
export interface Theme {
breakpoints: string[];
space: number[];
fontSizes: number[];
}
export const Box: BoxComponent;
export const Flex: FlexComponent;
export const theme: Theme;
export type DivProps = Omit<React.HTMLProps<HTMLDivElement>, "ref"> & {
innerRef: (el: HTMLDivElement) => any;
};
export const div: ComponentClass<DivProps>;

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"styled-components": "^3.1.6"
}
}

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"grid-styled-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }