Last active
May 5, 2020 23:40
-
-
Save chaance/04ade87bb526b67c9bd94b85074be7bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export type Breakpoints = { | |
[key: string]: number; | |
}; | |
export type MediaQueries<BP extends Breakpoints, T> = { | |
[key in keyof BP]: T; | |
}; | |
export interface BoxProps<BP extends Breakpoints> | |
extends React.ComponentPropsWithRef<'div'> { | |
mediaQueries: MediaQueries<BP, string>; | |
} | |
type MyBreakpoints = { | |
smol: 0; | |
mid: 500; | |
largish: 1000; | |
}; | |
export const Box: React.FC<BoxProps<MyBreakpoints>> = (props) => { | |
const { mediaQueries } = props; | |
// ✅ | |
const { smol, mid, largish } = mediaQueries; | |
return <div />; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment