Last active
May 3, 2022 01:57
-
-
Save valtism/76589d26505517444f6a2afe7704f24d to your computer and use it in GitHub Desktop.
Comparing EmotionCSS to TailwindCSS
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
// Emotion | |
const Label = styled.div<Pick<BreadcrumbProps, "isActive">>( | |
({ theme, isActive }) => [ | |
{ | |
...theme.typography.DetailLargeM, | |
...theme.typography.noWrap, | |
color: theme.colors.contentTertiary, | |
}, | |
isActive && { | |
color: theme.colors.contentPrimary, | |
"&:hover": { | |
textDecoration: "underline", | |
}, | |
}, | |
], | |
); | |
export const Breadcrumb: React.VFC<BreadcrumbProps> = ({ | |
label, | |
isActive, | |
}) => { | |
return ( | |
<Label isActive={isActive}> | |
{label} | |
</Label> | |
); | |
}; | |
// --- | |
// Tailwind | |
function Label({ isActive, children }) { | |
return ( | |
<div | |
className={clsx( | |
"text-detail-large-m whitespace-nowrap text-content-tertiary", | |
isActive && "text-content-primary hover:underline", | |
)} | |
> | |
{children} | |
</div> | |
); | |
} | |
export const Breadcrumb: React.VFC<BreadcrumbProps> = ({ | |
label, | |
isActive, | |
}) => { | |
return ( | |
<Label isActive={isActive}> | |
{label} | |
</Label> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A nice thing here is that you don't have to import anything like
styled
. We are importingclsx
however for the conditional formatting.