|
| 1 | +// Type definitions for styled-media-query 2.1.1 |
| 2 | +// Project: https://github.com/morajabi/styled-media-query |
| 3 | +// Definitions by: François Best <https://github.com/franky47> |
| 4 | +// Requires @types/styled-components definitions ^4.1 |
| 5 | +// TypeScript version: 3.3.3 |
| 6 | + |
| 7 | +import { |
| 8 | + ThemedStyledProps, |
| 9 | + InterpolationValue, |
| 10 | + FlattenInterpolation |
| 11 | +} from 'styled-components' |
| 12 | + |
| 13 | +type InterpolationFunction<Props, Theme> = ( |
| 14 | + props: ThemedStyledProps<Props, Theme> |
| 15 | +) => InterpolationValue | FlattenInterpolation<ThemedStyledProps<Props, Theme>> |
| 16 | + |
| 17 | +type GeneratorFunction<Props, Theme> = ( |
| 18 | + strings: TemplateStringsArray, |
| 19 | + ...interpolations: ( |
| 20 | + | InterpolationValue |
| 21 | + | InterpolationFunction<Props, Theme> |
| 22 | + | FlattenInterpolation<ThemedStyledProps<Props, Theme>>)[] |
| 23 | +) => any |
| 24 | + |
| 25 | +// -- |
| 26 | + |
| 27 | +export interface MediaGenerator<Breakpoints, Theme> { |
| 28 | + lessThan: <Props>( |
| 29 | + breakpoint: keyof Breakpoints |
| 30 | + ) => GeneratorFunction<Props, Theme> |
| 31 | + greaterThan: <Props>( |
| 32 | + breakpoint: keyof Breakpoints |
| 33 | + ) => GeneratorFunction<Props, Theme> |
| 34 | + between: <Props>( |
| 35 | + fist: keyof Breakpoints, |
| 36 | + second: keyof Breakpoints |
| 37 | + ) => GeneratorFunction<Props, Theme> |
| 38 | +} |
| 39 | + |
| 40 | +// -- |
| 41 | + |
| 42 | +export interface DefaultBreakpoints { |
| 43 | + huge: string |
| 44 | + large: string |
| 45 | + medium: string |
| 46 | + small: string |
| 47 | +} |
| 48 | + |
| 49 | +export const defaultBreakpoints: DefaultBreakpoints |
| 50 | + |
| 51 | +// -- |
| 52 | + |
| 53 | +export function generateMedia<Breakpoints = DefaultBreakpoints, Theme = any>( |
| 54 | + breakpoints?: Breakpoints |
| 55 | +): MediaGenerator<Breakpoints, Theme> |
| 56 | + |
| 57 | +// -- |
| 58 | + |
| 59 | +declare const media: MediaGenerator<DefaultBreakpoints, any> |
| 60 | + |
| 61 | +export default media |
| 62 | + |
| 63 | +// Convertors -- |
| 64 | + |
| 65 | +export function pxToEm<B>(breakpoints: B, ratio?: number): B |
| 66 | +export function pxToRem<B>(breakpoints: B, ratio?: number): B |
0 commit comments