Skip to content

Commit 4a69b20

Browse files
committed
completed filtering logic
1 parent e609431 commit 4a69b20

File tree

7 files changed

+210
-111
lines changed

7 files changed

+210
-111
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ const ratioToColor = useCallback((advertised: number, download: number) => {
8383
}, []);
8484
```
8585

86+
#### Clustering
87+
88+
The markers are clustered using the `react-google-maps` library. The `MarkerClusterer` component groups the markers based on the zoom level of the map.
89+
8690
### Filtering
8791

8892
Dropdown to filter results by ISP.
@@ -94,9 +98,7 @@ for:
9498

9599
- ISP
96100
- Advertised speed
97-
- Reported speed
98-
99-
Speed measured and reported using Speedtest.net API.
101+
- Reported speed (download and upload)
100102

101103
## Hero section
102104

app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Grid from "@/components/wrapper/Grid";
55
export default function Home() {
66
return (
77
<main className="flex flex-col items-center">
8-
{/* <GlobeDemo />
8+
<GlobeDemo />
99
<div
1010
className="h-screen w-full py-5 flex items-center"
1111
style={{
@@ -14,7 +14,7 @@ export default function Home() {
1414
}}
1515
>
1616
<Grid />
17-
</div> */}
17+
</div>
1818
<div className="h-screen py-5" id="dashboard">
1919
<Dashboard />
2020
</div>

components/ui/search.tsx

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { useState, useEffect } from "react";
3+
import { useState, useRef, useEffect } from "react";
44
import { DropdownMenuCheckboxItemProps } from "@radix-ui/react-dropdown-menu";
55

66
import { Button } from "@/components/ui/button";
@@ -13,7 +13,38 @@ import {
1313

1414
type Checked = DropdownMenuCheckboxItemProps["checked"];
1515

16-
const allSuggestions = ["Bell", "Link3", "Amber IT Ltd."];
16+
const allSuggestions = [
17+
"Bell",
18+
"Match Net",
19+
"Link3 Technologies Ltd.",
20+
"Aamra Networks Limited",
21+
"ADN Telecom Limited",
22+
"Agni Systems Limited",
23+
"Amber IT Limited",
24+
"Bangladesh Internet Exchange Limited (BIEL)",
25+
"BDCom Online Limited",
26+
"Brac Net Limited",
27+
"Carnival Internet",
28+
"Dhakacom Limited",
29+
"Dhaka Fiber Net Limited",
30+
"Fiber@Home Limited",
31+
"Infolink Communications Ltd.",
32+
"Kloud Technologies Ltd.",
33+
"Mango Teleservices Ltd.",
34+
"MetroNet Bangladesh Limited",
35+
"National IT Limited",
36+
"Nexus Telecom Limited",
37+
"Ollo Broadband",
38+
"Ranks ITT Limited",
39+
"Samonline Limited",
40+
"Sheba Phone (Pvt.) Ltd.",
41+
"Skytel Communications Ltd.",
42+
"Summit Communications Ltd.",
43+
"Thakral Information Systems Pvt. Ltd.",
44+
"Triangle Services Ltd.",
45+
"Unique Infoway Limited",
46+
"Wintel Limited",
47+
];
1748

1849
interface SearchBarProps {
1950
onSelectionChange: (selected: string[]) => void;
@@ -23,7 +54,22 @@ export default function SearchBar({ onSelectionChange }: SearchBarProps) {
2354
const [checkedItems, setCheckedItems] = useState<{
2455
[key: string]: Checked;
2556
}>({});
57+
const [buttonWidth, setButtonWidth] = useState(0);
58+
const buttonRef = useRef<HTMLButtonElement>(null);
2659

60+
const updateButtonWidth = () => {
61+
if (buttonRef.current) {
62+
setButtonWidth(buttonRef.current.offsetWidth);
63+
}
64+
};
65+
66+
useEffect(() => {
67+
updateButtonWidth();
68+
window.addEventListener("resize", updateButtonWidth);
69+
return () => {
70+
window.removeEventListener("resize", updateButtonWidth);
71+
};
72+
}, []);
2773
useEffect(() => {
2874
const updatedSelectedNames = Object.keys(checkedItems).filter(
2975
(key) => checkedItems[key]
@@ -41,9 +87,15 @@ export default function SearchBar({ onSelectionChange }: SearchBarProps) {
4187
return (
4288
<DropdownMenu>
4389
<DropdownMenuTrigger asChild>
44-
<Button variant="default">Filter by ISP</Button>
90+
<Button
91+
ref={buttonRef}
92+
variant="default"
93+
className="w-full hover:bg-neutral-700 bg-neutral-800 font-semibold rounded-lg"
94+
>
95+
Filter by ISP
96+
</Button>
4597
</DropdownMenuTrigger>
46-
<DropdownMenuContent className="w-56">
98+
<DropdownMenuContent className="my-1 max-h-80 overflow-scroll" style={{ width: buttonWidth }}>
4799
{allSuggestions.map((suggestion) => (
48100
<DropdownMenuCheckboxItem
49101
key={suggestion}

components/ui/test.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,14 @@ function SpeedPointForm({ onSuccess }: { onSuccess: () => void }) {
183183
variant="ghost"
184184
className="bg-gray-900 hover:bg-gray-800 text-slate-200 hover:text-slate-200 font-medium"
185185
>
186-
{loading ? <>
187-
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
188-
<span className="animate-pulse">Adding</span>
189-
</> : "Add speed point"}
186+
{loading ? (
187+
<>
188+
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
189+
<span className="animate-pulse">Adding</span>
190+
</>
191+
) : (
192+
"Add speed point"
193+
)}
190194
</Button>
191195

192196
<div className="text-gray-300 text-sm">
@@ -216,8 +220,13 @@ function SpeedPointForm({ onSuccess }: { onSuccess: () => void }) {
216220
);
217221
}
218222

219-
export function TestForm({open, setOpen}: {open: boolean, setOpen: (open: boolean) => void}) {
220-
223+
export function TestForm({
224+
open,
225+
setOpen,
226+
}: {
227+
open: boolean;
228+
setOpen: (open: boolean) => void;
229+
}) {
221230
const handleSuccess = () => {
222231
setOpen(false);
223232
};
@@ -227,9 +236,9 @@ export function TestForm({open, setOpen}: {open: boolean, setOpen: (open: boolea
227236
<DialogTrigger asChild>
228237
<Button
229238
variant="ghost"
230-
className="bg-zinc-700 hover:bg-zinc-600 text-white hover:text-zinc-50 font-medium"
239+
className="font-semibold animate-shimmer items-center justify-center rounded-lg border border-slate-800 bg-[linear-gradient(110deg,#000103,45%,#1e2631,55%,#000103)] bg-[length:200%_100%] px-6 text-slate-400 transition-colors focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 focus:ring-offset-slate-50 hover:text-white"
231240
>
232-
Report speed
241+
Report your speed
233242
</Button>
234243
</DialogTrigger>
235244
<DialogContent className=" bg-white rounded-md">

package-lock.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"clsx": "^2.1.1",
2222
"crypto": "^1.0.1",
2323
"firebase": "^10.13.1",
24+
"framer-motion": "^11.5.4",
2425
"lucide-react": "^0.441.0",
2526
"next": "14.2.11",
2627
"react": "^18",

0 commit comments

Comments
 (0)