@types/react-select: add theme property introduced in react-select v2.1 [WIP] (#29669)

* add theme property introduced in react-select 2.1

* fix lint errors

* added theme.tsx to tsconfig
This commit is contained in:
Murali
2018-10-12 10:06:30 -07:00
committed by Andy
parent 79f404e22b
commit 84600fa561
5 changed files with 43 additions and 2 deletions
+3 -1
View File
@@ -25,7 +25,7 @@ import {
SelectComponentsConfig,
} from './components/index';
import { StylesConfig } from './styles';
import { ThemeConfig } from './theme';
import {
ActionMeta,
ActionTypes,
@@ -193,6 +193,8 @@ export interface Props<OptionType> {
screenReaderStatus?: (obj: { count: number }) => string;
/* Style modifier methods */
styles?: StylesConfig;
/* Theme modifier method */
theme?: ThemeConfig;
/* Sets the tabIndex attribute on the input */
tabIndex?: string | null;
/* Select the currently focused option when the user presses tab */
+5
View File
@@ -1,3 +1,4 @@
import { Theme } from './types';
export const borderRadius: number;
export const colors: {
@@ -51,3 +52,7 @@ export const spacing: {
/* The amount of space between the control and menu */
menuGutter: number,
};
export const defaultTheme: Theme;
export type ThemeConfig = Theme | ((theme: Theme) => Theme);
+12
View File
@@ -98,3 +98,15 @@ export type OptionProps = PropsWithInnerRef & {
onMouseOver: MouseEventHandler,
value: any,
};
export interface ThemeSpacing {
baseUnit: number;
controlHeight: number;
menuGutter: number;
}
export interface Theme {
borderRadius: number;
colors: { [key: string]: string };
spacing: ThemeSpacing;
}
@@ -0,0 +1,21 @@
import * as React from 'react';
import { flavourOptions } from '../data';
import Select from 'react-select';
export default () => (
<Select
defaultValue={flavourOptions[2]}
options={flavourOptions}
theme={(theme) => ({
...theme,
borderRadius: 0,
colors: {
...theme.colors,
text: 'orangered',
primary25: 'hotpink',
primary: 'black',
},
})}
/>
);
+2 -1
View File
@@ -99,6 +99,7 @@
"test/examples/OnSelectResetsInput.tsx",
"test/examples/Popout.tsx",
"test/examples/StyledMulti.tsx",
"test/examples/StyledSingle.tsx"
"test/examples/StyledSingle.tsx",
"test/examples/Theme.tsx"
]
}