Created
June 19, 2020 20:21
-
-
Save rwboyer/8a5e9b8dca51c38945a961ed889a5d27 to your computer and use it in GitHub Desktop.
Tailwindcss babel macro browser vs. SSR vs build
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, cx } from '@emotion/css' | |
import tw from '@tailwindcssinjs/macro' | |
const styles = { | |
link: css(tw` | |
text-sm | |
block | |
pb-4 | |
font-semibold | |
text-sm | |
sm:text-base | |
border-b-2 | |
focus:outline-none | |
focus:text-gray-900 | |
whitespace-no-wrap | |
` | |
) | |
} | |
const ActiveLink = ({ children, href, className }) => { | |
const router = useRouter(); | |
const activeStyles = css(tw`text-gray-900 border-gray-800`) | |
const inactiveStyles = css(tw`text-gray-600 hover:text-gray-700 border-transparent`) | |
return ( | |
<Link href={href} scroll={false}> | |
<a | |
className = {cx(styles.link, | |
className, | |
router.pathname === href ? activeStyles : inactiveStyles)} | |
> | |
{children} | |
</a> | |
</Link> | |
); | |
}; | |
const HMenuLayout = ({ children }) => { | |
const itemMargin = css(tw`ml-8`) | |
return ( | |
<div className={css(tw`sticky w-full top-0 shadow bg-white md:bg-opacity-75 px-8 pt-4 leading-none`)}> | |
<h1 className={css(tw`w-full text-2xl text-gray-900 font-semibold`)}>Account Settings</h1> | |
<div | |
className={cx('scrollbar-none', css(tw`w-full mt-6 flex overflow-x-auto`))} | |
style={{ boxShadow: "inset 0 0px 0 #edf2f7"}} | |
> | |
<ActiveLink href="/"> | |
Basic Information | |
</ActiveLink> | |
<ActiveLink href="/buttons" className={itemMargin}> | |
Profile | |
</ActiveLink> | |
<ActiveLink href="/account-settings/team-settings" className={itemMargin}> | |
Team Settings | |
</ActiveLink> | |
<ActiveLink href="/account-settings/billing" className={itemMargin}> | |
Billing | |
</ActiveLink> | |
<ActiveLink href="/account-settings/notifications" className={itemMargin}> | |
Notifications | |
</ActiveLink> | |
<ActiveLink href="/account-settings/security" className={itemMargin}> | |
Security | |
</ActiveLink> | |
</div> | |
<div>{children}</div> | |
</div> | |
); | |
}; | |
export default HMenuLayout; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment