Last active
July 5, 2019 04:45
-
-
Save hnordt/752b550f7e9afb371ad4a460d50a5826 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
function Spacer({ size }) { | |
return ( | |
<span | |
className={css({ | |
display: "block", | |
width: `var(--spacing-${size})`, | |
height: `var(--spacing-${size})` | |
})} | |
aria-hidden | |
/> | |
); | |
} | |
function InBetweenSpacing({ size, children }) { | |
return Children.toArray(children).map((child, index, children) => ( | |
<Fragment key={index}> | |
{child.type === Fragment ? ( | |
<InBetweenSpacing size={size}>{child.props.children}</InBetweenSpacing> | |
) : ( | |
child | |
)} | |
{children[index + 1] && <Spacer size={size} />} | |
</Fragment> | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment