Skip to content

Instantly share code, notes, and snippets.

@kosciolek
Created May 7, 2021 13:13
Show Gist options
  • Save kosciolek/63c4e52cbfe3d883868ef4befe8c6c1d to your computer and use it in GitHub Desktop.
Save kosciolek/63c4e52cbfe3d883868ef4befe8c6c1d to your computer and use it in GitHub Desktop.
import {css} from "styled-components";
export function variant<R extends { variant?: keyof T },
T extends {
[variantName: string]: ReturnType<typeof css>;
}>(variantMap: T) {
return function ({variant: variantProp}: R) {
return variantMap[variantProp];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment