1
1
/* app/ui/moremenu.tsx */
2
2
'use client' ;
3
3
4
+ import type { Dispatch , SetStateAction } from 'react' ;
4
5
import { useState } from 'react' ;
5
6
import IconLink from './iconlink' ;
6
- import { profileLinks } from './profile-links' ;
7
+ import SortSelect from './sort-select' ; // Import SortSelect
7
8
8
- export default function MoreMenu ( ) {
9
+ // Types matching those in Header/Page
10
+ type SortOption = 'alpha' | 'alpha-desc' | 'published-date-desc' | 'published-date-asc' ;
11
+ interface ProfileLink {
12
+ href : string ;
13
+ label : string ;
14
+ svg : string ;
15
+ }
16
+
17
+ interface MoreMenuProps {
18
+ profileLinks : ProfileLink [ ] ;
19
+ sort : SortOption ;
20
+ setSort : Dispatch < SetStateAction < SortOption > > ;
21
+ query : string ;
22
+ setQuery : Dispatch < SetStateAction < string > > ;
23
+ }
24
+
25
+ export default function MoreMenu ( { profileLinks, sort, setSort, query, setQuery } : MoreMenuProps ) {
9
26
const [ open , setOpen ] = useState ( false ) ;
10
27
11
28
return (
12
29
< div className = "relative flex-shrink-0" >
13
30
< button
14
31
onClick = { ( ) => setOpen ( ! open ) }
15
- aria-label = "Open links "
16
- className = "sm:hidden p-2 rounded-md bg-neutral-800/70 hover:bg-neutral-800 focus:outline-none focus:ring-2 focus:ring-amber-500"
32
+ aria-label = "Open menu "
33
+ className = "p-2 rounded-md bg-neutral-800/70 hover:bg-neutral-800 focus:outline-none focus:ring-2 focus:ring-amber-500 lg:hidden "
17
34
>
18
35
< svg viewBox = "0 0 24 24" className = "w-4 h-4 fill-neutral-300" >
19
36
< circle cx = "5" cy = "12" r = "2" />
@@ -23,12 +40,32 @@ export default function MoreMenu() {
23
40
</ button >
24
41
25
42
{ open && (
26
- < div className = "absolute right-0 mt-2 w-40 rounded-md bg-neutral-900 shadow-lg ring-1 ring-neutral-700/60" >
27
- < nav className = "flex flex-col divide-y divide-neutral-700/60" >
28
- { profileLinks . map ( ( l ) => (
29
- < IconLink key = { l . label } { ...l } />
30
- ) ) }
31
- </ nav >
43
+ < div className = "absolute right-0 mt-2 w-56 rounded-md bg-neutral-900 shadow-lg ring-1 ring-neutral-700/60 z-50" >
44
+ < div className = "flex flex-col p-2 gap-2 divide-y divide-neutral-700/60" >
45
+
46
+ { /* Search Input - Shown below sm */ }
47
+ < div className = "sm:hidden px-2 pt-1 pb-2" >
48
+ < input
49
+ value = { query }
50
+ onChange = { ( e ) => setQuery ( e . target . value ) }
51
+ placeholder = "Search…"
52
+ className = "w-full rounded-md bg-neutral-800 px-3 py-1.5 text-sm placeholder:text-neutral-500 focus:outline-none focus:ring-2 focus:ring-amber-500"
53
+ />
54
+ </ div >
55
+
56
+ { /* Sort Select - Shown below md */ }
57
+ < div className = "md:hidden px-2 pt-2 pb-1" >
58
+ < label className = "block text-xs text-neutral-400 mb-1" > Sort by:</ label >
59
+ < SortSelect value = { sort } onChange = { setSort } />
60
+ </ div >
61
+
62
+ { /* Profile Links - Shown below lg */ }
63
+ < nav className = "lg:hidden flex flex-col pt-2" >
64
+ { profileLinks . map ( ( l ) => (
65
+ < IconLink key = { l . label } { ...l } menuMode = { true } />
66
+ ) ) }
67
+ </ nav >
68
+ </ div >
32
69
</ div >
33
70
) }
34
71
</ div >
0 commit comments