@@ -24,6 +24,11 @@ import { FilterDropdown } from "./FilterDropdown";
24
24
import { listSourceMetadata } from "@/lib/sources" ;
25
25
import { SourceIcon } from "@/components/SourceIcon" ;
26
26
import { TagFilter } from "./TagFilter" ;
27
+ import { Calendar } from "@/components/ui/calendar" ;
28
+ import { Popover , PopoverTrigger } from "@/components/ui/popover" ;
29
+ import { PopoverContent } from "@radix-ui/react-popover" ;
30
+ import { CalendarIcon } from "lucide-react" ;
31
+ import { buildDateString , getTimeAgoString } from "@/lib/dateUtils" ;
27
32
28
33
const SectionTitle = ( { children } : { children : string } ) => (
29
34
< div className = "font-bold text-xs mt-2 flex" > { children } </ div >
@@ -106,10 +111,39 @@ export function SourceSelector({
106
111
< FiFilter className = "my-auto ml-2" size = "16" />
107
112
</ div >
108
113
109
- < SectionTitle > Time Range</ SectionTitle >
110
- < div className = "mt-2" >
111
- < DateRangeSelector value = { timeRange } onValueChange = { setTimeRange } />
112
- </ div >
114
+ < Popover >
115
+ < PopoverTrigger asChild >
116
+ < div className = "cursor-pointer" >
117
+ < SectionTitle > Time Range</ SectionTitle >
118
+ < p className = "text-sm text-default mt-2" >
119
+ { getTimeAgoString ( timeRange ?. from ! ) || "Select a time range" }
120
+ </ p >
121
+ </ div >
122
+ </ PopoverTrigger >
123
+ < PopoverContent
124
+ className = "bg-background border-border border rounded-md z-[200] p-0"
125
+ align = "start"
126
+ >
127
+ < Calendar
128
+ mode = "range"
129
+ selected = {
130
+ timeRange
131
+ ? { from : new Date ( timeRange . from ) , to : new Date ( timeRange . to ) }
132
+ : undefined
133
+ }
134
+ onSelect = { ( daterange ) => {
135
+ const initialDate = daterange ?. from || new Date ( ) ;
136
+ const endDate = daterange ?. to || new Date ( ) ;
137
+ setTimeRange ( {
138
+ from : initialDate ,
139
+ to : endDate ,
140
+ selectValue : timeRange ?. selectValue || "" ,
141
+ } ) ;
142
+ } }
143
+ className = "rounded-md "
144
+ />
145
+ </ PopoverContent >
146
+ </ Popover >
113
147
114
148
{ availableTags . length > 0 && (
115
149
< >
@@ -424,14 +458,57 @@ export function HorizontalSourceSelector({
424
458
425
459
return (
426
460
< div className = "flex flex-nowrap space-x-2" >
427
- < div className = "max-w-24" >
428
- < DateRangeSelector
429
- isHorizontal
430
- value = { timeRange }
431
- onValueChange = { setTimeRange }
432
- className = "bg-background-search-filter"
433
- />
434
- </ div >
461
+ < Popover >
462
+ < PopoverTrigger asChild >
463
+ < div
464
+ className = { `
465
+ border
466
+ max-w-36
467
+ border-border
468
+ rounded-lg
469
+ bg-background
470
+ max-h-96
471
+ overflow-y-scroll
472
+ overscroll-contain
473
+ px-3
474
+ text-sm
475
+ py-1.5
476
+ select-none
477
+ cursor-pointer
478
+ w-fit
479
+ gap-x-1
480
+ hover:bg-hover
481
+ bg-hover-light
482
+ flex
483
+ items-center
484
+ bg-background-search-filter
485
+ ` }
486
+ >
487
+ < CalendarIcon className = "h-4 w-4" />
488
+
489
+ { timeRange ?. from ? getTimeAgoString ( timeRange . from ) : "Since" }
490
+ </ div >
491
+ </ PopoverTrigger >
492
+ < PopoverContent
493
+ className = "bg-background border-border border rounded-md z-[200] p-0"
494
+ align = "start"
495
+ >
496
+ < Calendar
497
+ mode = "single"
498
+ selected = { timeRange ? new Date ( timeRange . from ) : undefined }
499
+ onSelect = { ( date ) => {
500
+ const selectedDate = date || new Date ( ) ;
501
+ const today = new Date ( ) ;
502
+ setTimeRange ( {
503
+ from : selectedDate > today ? today : selectedDate ,
504
+ to : today ,
505
+ selectValue : timeRange ?. selectValue || "" ,
506
+ } ) ;
507
+ } }
508
+ className = "rounded-md "
509
+ />
510
+ </ PopoverContent >
511
+ </ Popover >
435
512
436
513
{ existingSources . length > 0 && (
437
514
< FilterDropdown
0 commit comments