Skip to content

Instantly share code, notes, and snippets.

@chaance
Last active May 5, 2020 23:40
Show Gist options
  • Save chaance/04ade87bb526b67c9bd94b85074be7bb to your computer and use it in GitHub Desktop.
Save chaance/04ade87bb526b67c9bd94b85074be7bb to your computer and use it in GitHub Desktop.
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