1- import React , { useState , useRef , useEffect , useId } from "react" ;
1+ import React , { useState , useRef , useEffect } from "react" ;
22import styled , { css } from "styled-components" ;
33import { landscapeStyle } from "styles/landscapeStyle" ;
4+ import { hoverShortTransitionTiming } from "styles/commonStyles" ;
45
56import { useOpenContext } from "../MobileHeader" ;
67
@@ -28,6 +29,7 @@ const Title = styled.h1`
2829` ;
2930
3031const PoliciesButton = styled . button < { isActive : boolean ; isMobileNavbar ?: boolean } > `
32+ ${ hoverShortTransitionTiming }
3133 display: flex;
3234 align-items: center;
3335 gap: 8px;
@@ -46,10 +48,13 @@ const PoliciesButton = styled.button<{ isActive: boolean; isMobileNavbar?: boole
4648
4749 ${ landscapeStyle (
4850 ( ) => css `
49- color: ${ ( { theme } ) => theme . white } ;
5051 padding: 16px 8px;
5152 `
52- ) } ;
53+ ) }
54+
55+ @media (min-width: 900px) {
56+ color: ${ ( { isActive, theme } ) => ( isActive ? theme . white : `${ theme . white } BA` ) } ;
57+ }
5358` ;
5459
5560const ChevronIcon = styled . span < { isOpen : boolean } > `
@@ -175,17 +180,13 @@ const DocumentIcon = styled.div`
175180` ;
176181
177182interface IPolicies {
178- /** Whether the component is being used in the mobile navbar */
179183 isMobileNavbar ?: boolean ;
180184}
181185
182186const Policies : React . FC < IPolicies > = ( { isMobileNavbar } ) => {
183187 const [ isOpen , setIsOpen ] = useState ( false ) ;
184188 const dropdownRef = useRef < HTMLDivElement > ( null ) ;
185189 const { toggleIsOpen } = useOpenContext ( ) ;
186- const menuId = useId ( ) ;
187-
188- // Policy documents configuration
189190
190191 const policies = [
191192 {
@@ -210,40 +211,32 @@ const Policies: React.FC<IPolicies> = ({ isMobileNavbar }) => {
210211 } ;
211212
212213 document . addEventListener ( "mousedown" , handleClickOutside ) ;
213- return ( ) => {
214- document . removeEventListener ( "mousedown" , handleClickOutside ) ;
215- } ;
214+ return ( ) => document . removeEventListener ( "mousedown" , handleClickOutside ) ;
216215 } , [ ] ) ;
217216
218217 const handleItemClick = ( ) => {
219218 setIsOpen ( false ) ;
220219 if ( isMobileNavbar ) {
221220 toggleIsOpen ( ) ;
222221 }
223- // Let the anchor's default behavior open the link in a new tab (with rel attr).
224- } ;
225-
226- const handleToggleDropdown = ( ) => {
227- setIsOpen ( ! isOpen ) ;
228222 } ;
229223
230224 return (
231225 < Container ref = { dropdownRef } >
232226 < Title > Policies</ Title >
233227 < PoliciesButton
234228 type = "button"
235- onClick = { handleToggleDropdown }
229+ onClick = { ( ) => setIsOpen ( ! isOpen ) }
236230 isActive = { isOpen }
237231 isMobileNavbar = { isMobileNavbar }
238232 aria-haspopup = "menu"
239233 aria-expanded = { isOpen }
240- aria-controls = { menuId }
241234 >
242235 Policies
243236 < ChevronIcon isOpen = { isOpen } />
244237 </ PoliciesButton >
245238
246- < DropdownContainer id = { menuId } role = "menu" isOpen = { isOpen } >
239+ < DropdownContainer isOpen = { isOpen } >
247240 { policies . map ( ( policy ) => {
248241 const IconComponent = policy . icon ;
249242 return (
@@ -253,7 +246,6 @@ const Policies: React.FC<IPolicies> = ({ isMobileNavbar }) => {
253246 target = "_blank"
254247 rel = "noopener noreferrer"
255248 onClick = { handleItemClick }
256- role = "menuitem"
257249 >
258250 < ItemIcon >
259251 < IconComponent />
0 commit comments