Created
May 7, 2021 13:13
-
-
Save kosciolek/63c4e52cbfe3d883868ef4befe8c6c1d 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 {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