wix-style-react: initial types (#38307)

This commit is contained in:
Gilad Segal
2019-09-24 16:24:09 -07:00
committed by Ben Lichtman
parent 47a5bb8cfc
commit f62ebf1af3
8 changed files with 140 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import * as React from 'react';
export interface ButtonProps {
as?: any;
className?: string;
skin?: ButtonSkin;
priority?: ButtonPriority;
size?: ButtonSize;
onClick?: React.MouseEventHandler<HTMLElement>;
fullWidth?: boolean;
suffixIcon?: React.ReactElement;
prefixIcon?: React.ReactElement;
disabled?: boolean;
dataHook?: string;
}
export default class Button extends React.Component<ButtonProps> {}
export type ButtonSkin =
| 'standard'
| 'inverted'
| 'destructive'
| 'premium'
| 'dark'
| 'light'
| 'transparent'
| 'premium-light';
export type ButtonPriority = 'primary' | 'secondary';
export type ButtonSize = 'tiny' | 'small' | 'medium' | 'large';
+27
View File
@@ -0,0 +1,27 @@
import * as React from 'react';
export interface TextProps {
showTooltip?: boolean;
ellipsed?: boolean;
tagName?: string;
className?: string;
size?: TextSize;
secondary?: boolean;
skin?: TextSkin;
light?: boolean;
weight?: TextWeight;
}
declare const Text: React.SFC<TextProps>;
export default Text;
export type TextSize = 'tiny' | 'small' | 'medium';
export type TextSkin =
| 'standard'
| 'error'
| 'success'
| 'premium'
| 'disabled';
export type TextWeight = 'thin' | 'normal' | 'bold';
+8
View File
@@ -0,0 +1,8 @@
// Type definitions for wix-style-react 6.17
// Project: https://github.com/wix/wix-style-react
// Definitions by: Gilad Segal <https://github.com/giladsegal>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped`;
// TypeScript Version: 3.5
export { default as Button, ButtonProps } from './Button';
export { default as Text, TextProps } from './Text';
@@ -0,0 +1,24 @@
import * as React from 'react';
import Button from 'wix-style-react/Button';
function ButtonWithMandatoryProps() {
return <Button />;
}
function ButtonWithAllProps() {
return (
<Button
as="button"
className="cls"
dataHook="hook"
disabled
fullWidth
onClick={e => undefined}
prefixIcon={<span />}
suffixIcon={<span />}
priority="primary"
size="medium"
skin="dark"
/>
);
}
+22
View File
@@ -0,0 +1,22 @@
import * as React from 'react';
import Text from 'wix-style-react/Text';
function TextWithMandatoryProps() {
return <Text />;
}
function TextWithAllProps() {
return (
<Text
className="cssssss"
size="tiny"
ellipsed
light
secondary
showTooltip
skin="standard"
tagName="marquee"
weight="thin"
/>
);
}
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"wix-style-react-tests.ts",
"Text.d.ts",
"test/Text-tests.tsx",
"Button.d.ts",
"test/Button-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,3 @@
// verify that all imports work
import { Button, Text } from 'wix-style-react';