1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-06-13 19:55:26 -04:00

type-safe stitches util for fancy link underline color

This commit is contained in:
2022-07-31 11:24:44 -04:00
parent 43d4b2ea46
commit 1c53376988
3 changed files with 26 additions and 18 deletions
+6 -6
View File
@@ -1,6 +1,6 @@
import NextLink from "next/link";
import objStr from "obj-str";
import { styled, theme } from "../../lib/styles/stitches.config";
import { styled, theme, stitchesConfig } from "../../lib/styles/stitches.config";
import { baseUrl } from "../../lib/config";
import type { ComponentProps } from "react";
@@ -14,20 +14,20 @@ const StyledLink = styled(NextLink, {
true: {
// sets psuedo linear-gradient() for the underline's color; see stitches config for the weird calculation behind
// the local `$$underlineColor` variable.
setUnderlineVars: {},
...stitchesConfig.utils.setUnderlineColor({ color: "$colors$linkUnderline" }),
backgroundImage: `linear-gradient($$underlineColor, $$underlineColor)`,
backgroundImage: "linear-gradient($$underlineColor, $$underlineColor)",
backgroundPosition: "0% 100%",
backgroundRepeat: "no-repeat",
backgroundSize: `0% ${theme.borderWidths.underline}`,
paddingBottom: "0.2rem",
backgroundSize: "0% 2px",
paddingBottom: "3px",
"@media (prefers-reduced-motion: no-preference)": {
transition: `background-size ${theme.transitions.linkHover}`,
},
"&:hover, &:focus-visible": {
backgroundSize: `100% ${theme.borderWidths.underline}`,
backgroundSize: "100% 2px",
},
},
false: {},