From c9d7f72173d3e142f77e1fcbda15aee6ce9afb77 Mon Sep 17 00:00:00 2001 From: Peter Barnum Date: Tue, 11 Jun 2024 19:01:18 -0600 Subject: [PATCH] maybe fix focus-visible accessibility --- next.config.js | 9 +++-- .../NavAccordion/NavAccordionItem.tsx | 16 ++++++--- .../NavAccordion/NavAccordionLink.tsx | 35 +++++++++++++------ src/components/Navbar/elements/NavLink.tsx | 4 +-- src/theme/styled/GlobalStyles.ts | 3 ++ 5 files changed, 46 insertions(+), 21 deletions(-) diff --git a/next.config.js b/next.config.js index e1b2c6da..233eea38 100644 --- a/next.config.js +++ b/next.config.js @@ -40,11 +40,14 @@ module.exports = (phase, { defaultConfig }) => { /** * @type {import('next').NextConfig} */ - return { + const config = { ...defaultConfig, reactStrictMode: true, compiler: { - styledComponents: true, + styledComponents: { + pure: true, + displayName: true, + }, }, env: { OVERRIDE_NODE_ENV: OVERRIDE_NODE_ENV || '', @@ -99,6 +102,8 @@ module.exports = (phase, { defaultConfig }) => { ].filter(Boolean); }, }; + + return config; }; function checkEnvVars(requiredVars) { diff --git a/src/components/Navbar/elements/NavAccordion/NavAccordionItem.tsx b/src/components/Navbar/elements/NavAccordion/NavAccordionItem.tsx index b5a769a5..f4f923ea 100644 --- a/src/components/Navbar/elements/NavAccordion/NavAccordionItem.tsx +++ b/src/components/Navbar/elements/NavAccordion/NavAccordionItem.tsx @@ -1,8 +1,8 @@ +import { AnimatePresence, motion } from 'framer-motion'; import { useRouter } from 'next/router'; import { ReactNode, useState } from 'react'; -import styled from 'styled-components'; -import { motion, AnimatePresence } from 'framer-motion'; import { FiChevronRight } from 'react-icons/fi'; +import styled from 'styled-components'; const NavAccordionItemStyles = styled(motion.div)` box-shadow: 0 -3px 3px rgba(25, 25, 25, 0) inset; @@ -31,8 +31,11 @@ const NavAccordionItemStyles = styled(motion.div)` display: flex; justify-content: space-between; align-items: center; - - :hover { + .accordion-item-title { + transition: all 250ms; + } + :hover .accordion-item-title, + :focus-visible .accordion-item-title { background: linear-gradient( 90deg, ${({ theme }) => theme.primary[800]} 0%, @@ -40,6 +43,9 @@ const NavAccordionItemStyles = styled(motion.div)` ${({ theme }) => theme.primary[600]} 96%, ${({ theme }) => theme.primary[800]} 100% ); + box-shadow: 0 0 3px rgba(0, 0, 0, 0.5) inset; + border-radius: 0.25rem; + padding: 0 0.5rem; } } .sub-links { @@ -80,7 +86,7 @@ export const NavAccordionItem = ({ title, children, href, link }: NavAccordionIt aria-label={title} >