mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
support returning CSS interpolation from styled-theming ThemeValueFn (#36468)
This commit is contained in:
committed by
Benjamin Lichtman
parent
61a2f3f989
commit
cbf9df95a2
Vendored
+7
-2
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/styled-components/styled-theming#readme
|
||||
// Definitions by: Arjan Jassal <https://github.com/ArjanJ>
|
||||
// Hieu Ho <https://github.com/hieuhlc>
|
||||
// David Daniell <https://github.com/tinynumbers>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
@@ -10,8 +11,12 @@ import { FlattenInterpolation, ThemeProps, ThemedStyledProps } from "styled-comp
|
||||
declare function theme(name: string, values: theme.ThemeMap): theme.ThemeSet;
|
||||
|
||||
declare namespace theme {
|
||||
type ThemeValueFn = (props: object) => string;
|
||||
type ThemeValue = string | ThemeValueFn | FlattenInterpolation<ThemeProps<any>> | FlattenInterpolation<ThemedStyledProps<any, any>>;
|
||||
type ThemeValueResult =
|
||||
string
|
||||
| FlattenInterpolation<ThemeProps<any>>
|
||||
| FlattenInterpolation<ThemedStyledProps<any, any>>;
|
||||
type ThemeValueFn = (props: object) => ThemeValueResult;
|
||||
type ThemeValue = ThemeValueFn | ThemeValueResult;
|
||||
|
||||
interface ThemeMap {
|
||||
[key: string]: ThemeValue;
|
||||
|
||||
@@ -33,3 +33,30 @@ const cssPropsTheme = theme("mode", {
|
||||
background: white;
|
||||
`
|
||||
});
|
||||
|
||||
interface buttonProps {
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
const button = theme.variants('mode', 'type', {
|
||||
primary: {
|
||||
light: (props: buttonProps) =>
|
||||
css`
|
||||
background: ${props.hidden ? 'transparent' : 'blue'};
|
||||
`,
|
||||
dark: (props: buttonProps) =>
|
||||
css`
|
||||
background: ${props.hidden ? 'transparent' : 'black'};
|
||||
`,
|
||||
},
|
||||
secondary: {
|
||||
light: (props: buttonProps) =>
|
||||
css`
|
||||
background: ${props.hidden ? 'transparent' : 'skyblue'};
|
||||
`,
|
||||
dark: (props: buttonProps) =>
|
||||
css`
|
||||
background: ${props.hidden ? 'transparent' : 'grey'};
|
||||
`,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user