npm.io
2.2.9 • Published 10 months ago

@types/styled-theming

Licence
MIT
Version
2.2.9
Deps
2
Size
5 kB
Vulns
0
Weekly
0
Stars
51.4K

Installation

npm install --save @types/styled-theming

Summary

This package contains type definitions for styled-theming (https://github.com/styled-components/styled-theming#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/styled-theming.

index.d.ts

import { FlattenInterpolation, ThemedStyledProps, ThemeProps } from "styled-components";

declare function theme(name: string, values: theme.ThemeMap): theme.ThemeSet;

declare namespace theme {
    type ThemeValueResult =
        | string
        | FlattenInterpolation<ThemeProps<any>>
        | FlattenInterpolation<ThemedStyledProps<any, any>>;
    type ThemeValueFn = (props: object) => ThemeValueResult;
    type ThemeValue = ThemeValueFn | ThemeValueResult;

    interface ThemeMap {
        [key: string]: ThemeValue;
    }

    type VariantMap<TVariant extends string> = {
        [key in TVariant]: ThemeMap;
    };

    type ThemeSet = (props: object) => string;
    type VariantSet<TProp extends string, TVariant extends string> = (props: { [key in TProp]?: TVariant }) => string;

    function variants<TProp extends string, TVariant extends string>(
        name: string,
        prop: TProp,
        values: VariantMap<TVariant>,
    ): VariantSet<TProp, TVariant>;
}

export = theme;

Additional Details

Credits

These definitions were written by Arjan Jassal, Hieu Ho, and David Daniell.