improve responsive links
This commit is contained in:
parent
a51ead0b83
commit
288216ba50
@ -3,21 +3,19 @@ import classnames from "classnames";
|
|||||||
import { Link } from "gatsby";
|
import { Link } from "gatsby";
|
||||||
import useDimensions from "react-cool-dimensions";
|
import useDimensions from "react-cool-dimensions";
|
||||||
|
|
||||||
import ShowMenu from "@spectrum-icons/workflow/ShowMenu";
|
import Menu from "@spectrum-icons/workflow/Menu";
|
||||||
|
|
||||||
const getNavClasses = (isClient) =>
|
|
||||||
classnames(
|
|
||||||
"hover:underline mx-2 md:mx-3",
|
|
||||||
isClient ? "text-vibrant-light" : "text-gray-200"
|
|
||||||
);
|
|
||||||
|
|
||||||
const Nav = ({ isClient, internalLinks, className }) => {
|
const Nav = ({ isClient, internalLinks, className }) => {
|
||||||
const { observe, currentBreakpoint } = useDimensions({
|
const { observe, currentBreakpoint } = useDimensions({
|
||||||
breakpoints: { XS: 0, LG: 670 },
|
breakpoints: { XS: 0, LG: 730 },
|
||||||
updateOnBreakpointChange: true,
|
updateOnBreakpointChange: true,
|
||||||
});
|
});
|
||||||
const [linksMenu, setLinksMenu] = useState(false);
|
const [linksMenu, setLinksMenu] = useState(false);
|
||||||
|
|
||||||
|
const navClasses = classnames(
|
||||||
|
"hover:underline mx-2 md:mx-3",
|
||||||
|
isClient ? "text-vibrant-light" : "text-gray-200"
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
className={classnames(
|
className={classnames(
|
||||||
@ -42,7 +40,7 @@ const Nav = ({ isClient, internalLinks, className }) => {
|
|||||||
<li key={href}>
|
<li key={href}>
|
||||||
<Link
|
<Link
|
||||||
activeClassName="font-bold underline"
|
activeClassName="font-bold underline"
|
||||||
className={getNavClasses(isClient)}
|
className={navClasses}
|
||||||
to={href}
|
to={href}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
@ -53,35 +51,38 @@ const Nav = ({ isClient, internalLinks, className }) => {
|
|||||||
{internalLinks && currentBreakpoint === "LG" && <>|</>}
|
{internalLinks && currentBreakpoint === "LG" && <>|</>}
|
||||||
{currentBreakpoint === "XS" && (
|
{currentBreakpoint === "XS" && (
|
||||||
<button
|
<button
|
||||||
className="ml-2 hover:underline inline-flex align-middle"
|
className="mx-2 hover:underline inline-flex align-middle"
|
||||||
onClick={() => setLinksMenu(!linksMenu)}
|
onClick={() => setLinksMenu(!linksMenu)}
|
||||||
>
|
>
|
||||||
<ShowMenu
|
<Menu
|
||||||
UNSAFE_className="mr-2"
|
UNSAFE_className="mr-1"
|
||||||
aria-label="show external links"
|
aria-label="show external links"
|
||||||
size="S"
|
size="S"
|
||||||
/>
|
/>
|
||||||
|
Links
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{(currentBreakpoint === "LG" || linksMenu) && (
|
{(currentBreakpoint === "LG" || linksMenu) && (
|
||||||
<ul
|
<ul
|
||||||
className={classnames(
|
className={classnames(
|
||||||
|
"z-30",
|
||||||
currentBreakpoint === "LG"
|
currentBreakpoint === "LG"
|
||||||
? "inline-flex flex-wrap justify-center"
|
? "inline-flex flex-wrap justify-center"
|
||||||
: "fixed bg-vibrant-dark p-2 rounded-md cool-border-small-light right-4"
|
: "absolute p-2 rounded-md mt-2",
|
||||||
|
currentBreakpoint === "XS" &&
|
||||||
|
(isClient
|
||||||
|
? "bg-vibrant-dark cool-border-small-light"
|
||||||
|
: "bg-black border border-white")
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a className={navClasses} href="https://twitter.com/chuckletmilk">
|
||||||
className={getNavClasses(isClient)}
|
|
||||||
href="https://twitter.com/chuckletmilk"
|
|
||||||
>
|
|
||||||
Twitter
|
Twitter
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
className={getNavClasses(isClient)}
|
className={navClasses}
|
||||||
href="https://www.instagram.com/asubtlebutdeliciouscoffeecake/"
|
href="https://www.instagram.com/asubtlebutdeliciouscoffeecake/"
|
||||||
>
|
>
|
||||||
Instagram
|
Instagram
|
||||||
@ -89,25 +90,19 @@ const Nav = ({ isClient, internalLinks, className }) => {
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
className={getNavClasses(isClient)}
|
className={navClasses}
|
||||||
href="https://www.youtube.com/channel/UCknR_DdytuOgzus--b2gZhg"
|
href="https://www.youtube.com/channel/UCknR_DdytuOgzus--b2gZhg"
|
||||||
>
|
>
|
||||||
YouTube
|
YouTube
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a className={navClasses} href="https://github.com/chuckdries">
|
||||||
className={getNavClasses(isClient)}
|
|
||||||
href="https://github.com/chuckdries"
|
|
||||||
>
|
|
||||||
GitHub
|
GitHub
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a className={navClasses} href="mailto:chuck@chuckdries.com">
|
||||||
className={getNavClasses(isClient)}
|
|
||||||
href="mailto:chuck@chuckdries.com"
|
|
||||||
>
|
|
||||||
chuck@chuckdries.com
|
chuck@chuckdries.com
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user