Last active
February 12, 2022 09:43
-
-
Save OleksandrDanylchenko/5e4a181225675bcb41e74ab82b0045b4 to your computer and use it in GitHub Desktop.
Emotion CSS Flexbox Mixin
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
export const flexbox = (options: { | |
display?: string; | |
direction?: string; | |
placeContent?: string; | |
placeItems?: string; | |
wrap?: string; | |
shrink?: string; | |
grow?: string; | |
alignContent?: string; | |
justifyContent?: string; | |
alignItems?: string; | |
justifyItems?: string; | |
gap?: string; | |
}) => css` | |
display: ${options.display || 'flex'}; | |
flex-direction: ${options.direction || 'row'}; | |
${options.placeContent | |
? css` | |
place-content: ${options.placeContent}; | |
` | |
: css` | |
align-content: ${options.alignContent}; | |
justify-content: ${options.justifyContent}; | |
`} | |
${options.placeItems | |
? css` | |
place-items: ${options.placeContent}; | |
` | |
: css` | |
align-items: ${options.alignItems}; | |
justify-items: ${options.justifyItems}; | |
`} | |
flex-wrap: ${options.wrap || 'nowrap'}; | |
flex-shrink: ${options.shrink}; | |
flex-grow: ${options.grow}; | |
gap: ${options.gap}; | |
`; |
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 { Property } from 'csstype'; | |
export const flexbox = (options: { | |
display?: Property.Display; | |
direction?: Property.FlexDirection; | |
placeContent?: Property.PlaceContent; | |
placeItems?: Property.PlaceItems; | |
wrap?: Property.FlexWrap; | |
shrink?: Property.FlexShrink; | |
grow?: Property.FlexGrow; | |
alignContent?: Property.AlignContent; | |
justifyContent?: Property.JustifyContent; | |
alignItems?: Property.AlignItems; | |
justifyItems?: Property.JustifyItems; | |
gap?: Property.Gap; | |
}) => css` | |
display: ${options.display || 'flex'}; | |
flex-direction: ${options.direction || 'row'}; | |
${options.placeContent | |
? css` | |
place-content: ${options.placeContent}; | |
` | |
: css` | |
align-content: ${options.alignContent}; | |
justify-content: ${options.justifyContent}; | |
`} | |
${options.placeItems | |
? css` | |
place-items: ${options.placeContent}; | |
` | |
: css` | |
align-items: ${options.alignItems}; | |
justify-items: ${options.justifyItems}; | |
`} | |
flex-wrap: ${options.wrap || 'nowrap'}; | |
flex-shrink: ${options.shrink}; | |
flex-grow: ${options.grow}; | |
gap: ${options.gap}; | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment