Last active
October 5, 2021 12:15
-
-
Save joe-bell/a81649f9d839aee975f8cbf6599bdb8c to your computer and use it in GitHub Desktop.
Stitches: Themed Variants
This file contains hidden or 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 type * as Stitches from '@stitches/react'; | |
| import { css, config } from "./stitches.config"; | |
| type TCSS = Stitches.CSS<typeof config>; | |
| const { space } = config.theme; | |
| type TSpaceKey = keyof typeof space; | |
| const gap = (Object.keys(space) as Array<TSpaceKey>).reduce< | |
| Record<TSpaceKey, TCSS> | |
| >( | |
| (acc, cv) => ({ | |
| ...acc, | |
| [cv]: { $$stackGap: `$space$${cv}` }, | |
| }), | |
| {} as any | |
| ); | |
| /** | |
| * Stack | |
| */ | |
| export const stack = css({ | |
| display: "flex", | |
| listStyleType: "none", | |
| paddingLeft: 0, | |
| "> * + *": { | |
| marginTop: "$$stackGap", | |
| }, | |
| variants: { | |
| gap, | |
| }, | |
| defaultVariants: { | |
| gap: 4, | |
| }, | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah ha! That's what I kinda figured that
typewas. I appreciate the clarification.