@@ -9,52 +9,82 @@ export function RecipientsLayout() {
9
9
< div className = "container mx-auto flex min-h-0 flex-grow flex-col px-4 pt-4 md:px-8 md:pt-8" >
10
10
< div className = "mb-8 flex items-center justify-between" >
11
11
< h1 className = "text-4xl font-bold" > Recipients</ h1 >
12
- < ButtonLink
13
- to = "/recipients/new"
14
- className = "hidden items-center gap-2 md:flex"
15
- >
12
+ < ButtonLink to = "new" className = "hidden items-center gap-2 md:flex" >
16
13
< Icon name = "Plus" > Add New Recipient</ Icon >
17
14
</ ButtonLink >
18
- < ButtonLink icon to = "/recipients/ new" className = "md:hidden" >
15
+ < ButtonLink icon to = "new" className = "md:hidden" >
19
16
< Icon name = "Plus" />
20
17
</ ButtonLink >
21
18
</ div >
22
19
23
- < div className = "bg-background-alt flex min-h-0 flex-1 flex-col md:flex-row" >
24
- < div className = "flex max-h-32 min-h-32 flex-col gap-4 overflow-auto border-b-2 py-4 pr-4 pl-1 md:max-h-none md:min-w-32 md:border-r md:border-b-0" >
25
- { recipients . map ( ( recipient ) => (
26
- < div key = { recipient . id } className = "flex items-center gap-2" >
27
- < NavLink
28
- to = { `/recipients/${ recipient . id } ` }
29
- className = { ( { isActive } ) =>
30
- clsx ( 'text-xl' , isActive ? 'underline' : '' )
31
- }
32
- >
33
- { ( { isActive } ) => (
34
- < div className = "flex items-center gap-1" >
20
+ < div className = "bg-background-alt flex min-h-0 flex-1 flex-col" >
21
+ < div className = "flex flex-col gap-4 overflow-visible border-b-2 py-4 pr-4 pl-1" >
22
+ < details
23
+ className = "relative"
24
+ onBlur = { ( e ) => {
25
+ const relatedTarget = e . relatedTarget
26
+ if ( ! e . currentTarget . contains ( relatedTarget ) ) {
27
+ e . currentTarget . removeAttribute ( 'open' )
28
+ }
29
+ } }
30
+ onKeyDown = { ( e ) => {
31
+ if ( e . key === 'Escape' ) {
32
+ e . currentTarget . removeAttribute ( 'open' )
33
+ }
34
+ } }
35
+ >
36
+ < summary className = "hover:bg-background-alt-hover cursor-pointer px-2 py-1" >
37
+ Select recipient
38
+ </ summary >
39
+ < div className = "bg-background-alt absolute top-full left-0 z-10 mt-1 max-w-full min-w-64 border p-2 shadow-lg" >
40
+ { recipients . map ( ( recipient ) => (
41
+ < div key = { recipient . id } className = "flex items-center gap-2" >
42
+ < NavLink
43
+ to = { recipient . id }
44
+ className = { ( { isActive } ) =>
45
+ clsx (
46
+ 'overflow-x-auto text-xl' ,
47
+ isActive ? 'underline' : '' ,
48
+ )
49
+ }
50
+ onClick = { ( e ) => {
51
+ e . currentTarget
52
+ . closest ( 'details' )
53
+ ?. removeAttribute ( 'open' )
54
+ } }
55
+ >
56
+ { ( { isActive } ) => (
57
+ < div className = "flex items-center gap-1" >
58
+ < Icon
59
+ name = "ArrowRight"
60
+ size = "sm"
61
+ className = { clsx (
62
+ isActive ? 'opacity-100' : 'opacity-0' ,
63
+ 'transition-opacity' ,
64
+ ) }
65
+ />
66
+ { recipient . name }
67
+ </ div >
68
+ ) }
69
+ </ NavLink >
70
+ { recipient . messages . some (
71
+ ( m ) => m . status === 'scheduled' ,
72
+ ) ? null : (
35
73
< Icon
36
- name = "ArrowRight"
37
- size = "sm"
38
- className = { clsx (
39
- isActive ? 'opacity-100' : 'opacity-0' ,
40
- 'transition-opacity' ,
41
- ) }
74
+ name = "ExclamationCircle"
75
+ className = "text-danger-foreground"
76
+ title = "no messages scheduled"
42
77
/>
43
- { recipient . name }
44
- </ div >
45
- ) }
46
- </ NavLink >
47
- { recipient . messages . some (
48
- ( m ) => m . status === 'scheduled' ,
49
- ) ? null : (
50
- < Icon
51
- name = "ExclamationCircle"
52
- className = "text-danger-foreground"
53
- title = "no messages scheduled"
54
- />
78
+ ) }
79
+ </ div >
80
+ ) ) }
81
+ { recipients . length === 0 && (
82
+ < div className = "bg-warning-background text-warning-foreground px-4 py-2 text-sm" >
83
+ No recipients found. Add one to get started.
84
+ </ div >
55
85
) }
56
86
</ div >
57
- ) ) }
87
+ </ details >
58
88
</ div >
59
89
< div className = "flex flex-1 overflow-auto" >
60
90
< Outlet />
0 commit comments