Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Enhance DateSelector and CustomDateRangePicker components with visual indicators

Bill Yang690f69faa29c
diff --git a/client/src/components/DateSelector/CustomDateRangePicker.tsx b/client/src/components/DateSelector/CustomDateRangePicker.tsx
index 950915f49..ee1cda9b8 100644
--- a/client/src/components/DateSelector/CustomDateRangePicker.tsx
+++ b/client/src/components/DateSelector/CustomDateRangePicker.tsx
@@ -7,9 +7,10 @@ import { Button } from "@/components/ui/button";
import { Calendar } from "@/components/ui/calendar";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { cn } from "@/lib/utils";
+import { Check } from "lucide-react";
import { Time } from "./types";
-export function CustomDateRangePicker({ className, setTime }: { className?: string; setTime: (time: Time) => void }) {
+export function CustomDateRangePicker({ className, setTime, time }: { className?: string; setTime: (time: Time) => void; time: Time }) {
const [date, setDate] = React.useState<DateRange | undefined>();
return (
@@ -17,6 +18,9 @@ export function CustomDateRangePicker({ className, setTime }: { className?: stri
<Popover>
<PopoverTrigger asChild>
<Button id="date" variant={"ghost"} className={cn("justify-start text-left font-normal px-2")}>
+ <div className="w-4">
+ {!time.wellKnown && <Check className="w-4 h-4" />}
+ </div>
Custom Range
</Button>
</PopoverTrigger>
diff --git a/client/src/components/DateSelector/DateSelector.tsx b/client/src/components/DateSelector/DateSelector.tsx
index 287f654a8..a358686d2 100644
--- a/client/src/components/DateSelector/DateSelector.tsx
+++ b/client/src/components/DateSelector/DateSelector.tsx
@@ -7,7 +7,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
-import { Calendar } from "lucide-react";
+import { Calendar, Check } from "lucide-react";
import { DateTime } from "luxon";
import { CustomDateRangePicker } from "./CustomDateRangePicker";
import { Time } from "./types";
@@ -118,6 +118,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "today" && <Check className="w-4 h-4" />}
+ </div>
Today
</DropdownMenuItem>
<DropdownMenuItem
@@ -130,6 +133,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "last-3-days" && <Check className="w-4 h-4" />}
+ </div>
Last 3 Days
</DropdownMenuItem>
<DropdownMenuItem
@@ -142,6 +148,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "last-7-days" && <Check className="w-4 h-4" />}
+ </div>
Last 7 Days
</DropdownMenuItem>
<DropdownMenuItem
@@ -154,6 +163,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "last-14-days" && <Check className="w-4 h-4" />}
+ </div>
Last 14 Days
</DropdownMenuItem>
<DropdownMenuItem
@@ -166,6 +178,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "last-30-days" && <Check className="w-4 h-4" />}
+ </div>
Last 30 Days
</DropdownMenuItem>
<DropdownMenuItem
@@ -178,6 +193,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "last-60-days" && <Check className="w-4 h-4" />}
+ </div>
Last 60 Days
</DropdownMenuItem>
{pastMinutesEnabled && (
@@ -193,6 +211,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "last-30-minutes" && <Check className="w-4 h-4" />}
+ </div>
Last 30 Minutes
</DropdownMenuItem>
<DropdownMenuItem
@@ -205,6 +226,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "last-1-hour" && <Check className="w-4 h-4" />}
+ </div>
Last 1 Hour
</DropdownMenuItem>
<DropdownMenuItem
@@ -217,6 +241,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "last-6-hours" && <Check className="w-4 h-4" />}
+ </div>
Last 6 Hours
</DropdownMenuItem>
<DropdownMenuItem
@@ -229,6 +256,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "last-24-hours" && <Check className="w-4 h-4" />}
+ </div>
Last 24 Hours
</DropdownMenuItem>
</>
@@ -243,6 +273,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "this-week" && <Check className="w-4 h-4" />}
+ </div>
This Week
</DropdownMenuItem>
<DropdownMenuItem
@@ -254,6 +287,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "this-month" && <Check className="w-4 h-4" />}
+ </div>
This Month
</DropdownMenuItem>
<DropdownMenuItem
@@ -265,6 +301,9 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "this-year" && <Check className="w-4 h-4" />}
+ </div>
This Year
</DropdownMenuItem>
<DropdownMenuItem
@@ -275,10 +314,13 @@ export function DateSelector({
})
}
>
+ <div className="w-4">
+ {time.wellKnown === "all-time" && <Check className="w-4 h-4" />}
+ </div>
All Time
</DropdownMenuItem>
<DropdownMenuSeparator />
- <CustomDateRangePicker setTime={setTime} />
+ <CustomDateRangePicker setTime={setTime} time={time} />
</DropdownMenuContent>
</DropdownMenu>
);