Hide external links behind hamburger button at certain sizes
This commit is contained in:
parent
e3a088a0fc
commit
a51ead0b83
@ -58,6 +58,7 @@
|
|||||||
"postcss-nested": "^5.0.5",
|
"postcss-nested": "^5.0.5",
|
||||||
"ramda": "^0.27.1",
|
"ramda": "^0.27.1",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
|
"react-cool-dimensions": "^2.0.7",
|
||||||
"react-div-100vh": "^0.7.0",
|
"react-div-100vh": "^0.7.0",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"react-helmet": "^6.1.0",
|
"react-helmet": "^6.1.0",
|
||||||
|
@ -4,7 +4,10 @@ const R = require('ramda')
|
|||||||
const resolveConfig = require('tailwindcss/resolveConfig');
|
const resolveConfig = require('tailwindcss/resolveConfig');
|
||||||
const tailwindConfig = require('../tailwind.config.js');
|
const tailwindConfig = require('../tailwind.config.js');
|
||||||
const {theme} = resolveConfig(tailwindConfig);
|
const {theme} = resolveConfig(tailwindConfig);
|
||||||
module.exports = R.map(size => parseInt(size, 10), theme.screens);
|
module.exports = R.pipe(
|
||||||
|
R.map(size => parseInt(size, 10)),
|
||||||
|
R.filter(Boolean)
|
||||||
|
)(theme.screens);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default themeBreakpoints;
|
export default themeBreakpoints;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import { Link } from "gatsby";
|
import { Link } from "gatsby";
|
||||||
|
import useDimensions from "react-cool-dimensions";
|
||||||
|
|
||||||
|
import ShowMenu from "@spectrum-icons/workflow/ShowMenu";
|
||||||
|
|
||||||
const getNavClasses = (isClient) =>
|
const getNavClasses = (isClient) =>
|
||||||
classnames(
|
classnames(
|
||||||
@ -8,18 +11,26 @@ const getNavClasses = (isClient) =>
|
|||||||
isClient ? "text-vibrant-light" : "text-gray-200"
|
isClient ? "text-vibrant-light" : "text-gray-200"
|
||||||
);
|
);
|
||||||
|
|
||||||
const Nav = ({ isClient, internalLinks, className }) => (
|
const Nav = ({ isClient, internalLinks, className }) => {
|
||||||
|
const { observe, currentBreakpoint } = useDimensions({
|
||||||
|
breakpoints: { XS: 0, LG: 670 },
|
||||||
|
updateOnBreakpointChange: true,
|
||||||
|
});
|
||||||
|
const [linksMenu, setLinksMenu] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
<nav
|
<nav
|
||||||
className={classnames(
|
className={classnames(
|
||||||
"m-2 flex justify-center font-sans",
|
"m-2 flex justify-center font-sans w-full",
|
||||||
isClient ? "text-vibrant-light" : "text-gray-200",
|
isClient ? "text-vibrant-light" : "text-gray-200",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
ref={observe}
|
||||||
style={{ zIndex: 100 }}
|
style={{ zIndex: 100 }}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={classnames(
|
className={classnames(
|
||||||
"rounded-full p-2 ]",
|
"rounded-full p-2",
|
||||||
isClient
|
isClient
|
||||||
? "bg-vibrant-dark cool-border-small-light"
|
? "bg-vibrant-dark cool-border-small-light"
|
||||||
: "border border-white"
|
: "border border-white"
|
||||||
@ -38,7 +49,28 @@ const Nav = ({ isClient, internalLinks, className }) => (
|
|||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
{internalLinks && <>|</>}
|
</ul>
|
||||||
|
{internalLinks && currentBreakpoint === "LG" && <>|</>}
|
||||||
|
{currentBreakpoint === "XS" && (
|
||||||
|
<button
|
||||||
|
className="ml-2 hover:underline inline-flex align-middle"
|
||||||
|
onClick={() => setLinksMenu(!linksMenu)}
|
||||||
|
>
|
||||||
|
<ShowMenu
|
||||||
|
UNSAFE_className="mr-2"
|
||||||
|
aria-label="show external links"
|
||||||
|
size="S"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{(currentBreakpoint === "LG" || linksMenu) && (
|
||||||
|
<ul
|
||||||
|
className={classnames(
|
||||||
|
currentBreakpoint === "LG"
|
||||||
|
? "inline-flex flex-wrap justify-center"
|
||||||
|
: "fixed bg-vibrant-dark p-2 rounded-md cool-border-small-light right-4"
|
||||||
|
)}
|
||||||
|
>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
className={getNavClasses(isClient)}
|
className={getNavClasses(isClient)}
|
||||||
@ -80,8 +112,10 @@ const Nav = ({ isClient, internalLinks, className }) => (
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default Nav;
|
export default Nav;
|
||||||
|
@ -12362,6 +12362,11 @@ rc@^1.2.7, rc@^1.2.8:
|
|||||||
minimist "^1.2.0"
|
minimist "^1.2.0"
|
||||||
strip-json-comments "~2.0.1"
|
strip-json-comments "~2.0.1"
|
||||||
|
|
||||||
|
react-cool-dimensions@^2.0.7:
|
||||||
|
version "2.0.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-cool-dimensions/-/react-cool-dimensions-2.0.7.tgz#2fe6657608f034cd7c89f149ed14e79cf1cb2d50"
|
||||||
|
integrity sha512-z1VwkAAJ5d8QybDRuYIXTE41RxGr5GYsv1bQhbOBE8cMfoZQZpcF0odL64vdgrQVzat2jayedj1GoYi80FWcbA==
|
||||||
|
|
||||||
react-dev-utils@^12.0.1:
|
react-dev-utils@^12.0.1:
|
||||||
version "12.0.1"
|
version "12.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-12.0.1.tgz#ba92edb4a1f379bd46ccd6bcd4e7bc398df33e73"
|
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-12.0.1.tgz#ba92edb4a1f379bd46ccd6bcd4e7bc398df33e73"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user