import { theme } from "../theme" ; import { ThemedStyledProps } from "styled-components" ; export type Theme = typeof theme ; export type ThemedProps < O extends { } > = ThemedStyledProps < O , Theme > ; type BSColors < Compo extends keyof Theme > = keyof Theme [ Compo ] [ "bscolors" ] ; export function getStyle < P extends Theme , N extends keyof Theme , S extends keyof P [ N ] , X extends keyof P [ N ] [ S ] > ( p , n , s , x ) ; export function getStyle < P extends Theme , N extends keyof Theme , S extends keyof P [ N ] , X extends keyof P [ N ] [ S ] , Y extends keyof P [ N ] [ S ] [ X ] > ( p , n , s , x , y ) ; export function getStyle < P extends Theme , N extends keyof Theme , S extends keyof P [ N ] , X extends keyof P [ N ] [ S ] , Y extends keyof P [ N ] [ S ] [ X ] , Z extends keyof P [ N ] [ S ] [ X ] [ Y ] > ( p , n , s , x , y , z ) ; export function getStyle < T extends Theme , N extends keyof Theme , S extends keyof Theme [ N ] , X extends keyof Theme [ N ] [ S ] , Y extends keyof Theme [ N ] [ S ] [ X ] , Z extends keyof Theme [ N ] [ S ] [ X ] [ Y ] > ( p , name , style , x , y ? , z ? ) { if ( y && z ) { return p [ name ] [ style ] [ x ] [ y ] [ z ] ; } else { return y ? p [ name ] [ style ] [ x ] [ y ] : p [ name ] [ style ] ; } } export function getColor < P extends { theme : Theme ; } , N extends keyof Theme , X extends keyof Theme [ N ] [ "bscolors" ] [ "default" ] > ( props , compo , x ) ; export function getColor < P extends { theme : Theme ; } & { [ K in BSColors < N > ] ? : boolean ; } , N extends keyof Theme , B extends keyof Theme [ N ] [ "bscolors" ] > ( props , compo , style ) { const propsArr = Object . keys ( props ) ; let bscolor = null ; const bscolors = Object . keys ( theme [ compo ] ) ; propsArr . forEach ( ( s ) => { if ( bscolors . includes ( s ) ) { bscolor = s ; } } ) ; if ( bscolor ) { return getStyle ( props . theme , compo , "bscolors" , bscolor , style ) ; } return props . theme [ compo ] [ "bscolors" ] [ "default" ] ; } export const getConcreteBreakpointSize = ( props , size ) => props . theme [ "screenSize" ] [ size ] ; export const getBreakpointSize = props => { if ( props . sm || props . expandSm ) { return getConcreteBreakpointSize ( props . theme , "sm" ) ; } else if ( props . md || props . expandMd ) { return getConcreteBreakpointSize ( props . theme , "md" ) ; } else if ( props . lg || props . expandLg ) { return getConcreteBreakpointSize ( props . theme , "lg" ) ; } else if ( props . xl || props . expandXl ) { return getConcreteBreakpointSize ( props . theme , "xl" ) ; } return "" ; } ;