-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* style(frontend): 🔥 remove unused files, restructure folders, style satellite selector * small fix * prettier * eslint and prettier
- Loading branch information
Lukas Thrane
authored and
GitHub
committed
Apr 9, 2024
1 parent
02638c2
commit f0c3c6d
Showing
20 changed files
with
108 additions
and
639 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import React, { useState } from "react"; | ||
| import { motion } from "framer-motion"; | ||
| import { cn } from "@/lib/utils"; | ||
|
|
||
| type DropdownProps = { | ||
| satelliteNames: string[]; | ||
| selectedSatellite: string; | ||
| // eslint-disable-next-line no-unused-vars | ||
| setSelectedSatellite: (satellite: string) => void; | ||
| }; | ||
|
|
||
| export default function SatDropdown({ | ||
| satelliteNames, | ||
| selectedSatellite, | ||
| setSelectedSatellite, | ||
| }: DropdownProps) { | ||
| const [isOpen, setIsOpen] = useState<boolean>(false); | ||
|
|
||
| const toggleDropdown = () => setIsOpen(!isOpen); | ||
|
|
||
| const handleSelect = (satellite: string) => { | ||
| setSelectedSatellite(satellite); | ||
| setIsOpen(false); | ||
| }; | ||
|
|
||
| // Animation variants for the dropdown content | ||
| const variants = { | ||
| open: { opacity: 1, height: "auto", maxHeight: "300px" }, | ||
| collapsed: { opacity: 0, height: 0 }, | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="w-full"> | ||
| <button | ||
| className="block w-full cursor-pointer bg-black p-4 text-left text-xl font-bold tracking-wide" | ||
| onClick={toggleDropdown} | ||
| > | ||
| {selectedSatellite || "Select a Satellite"} | ||
| </button> | ||
| {isOpen && <hr />} | ||
| <motion.div | ||
| className={cn("overflow-hidden", isOpen && "overflow-y-scroll")} | ||
| initial="collapsed" | ||
| animate={isOpen ? "open" : "collapsed"} | ||
| variants={variants} | ||
| transition={{ duration: 0.5 }} | ||
| > | ||
| {satelliteNames.map((satellite) => ( | ||
| <div | ||
| key={satellite} | ||
| className="cursor-pointer p-2 text-white hover:bg-gray-700" | ||
| onClick={() => handleSelect(satellite)} | ||
| > | ||
| {satellite !== selectedSatellite | ||
| ? satellite | ||
| : `${satellite} (Selected)`} | ||
| </div> | ||
| ))} | ||
| </motion.div> | ||
| </div> | ||
| ); | ||
| } |
32 changes: 32 additions & 0 deletions
32
frontend/src/components/homeComponents/SatelliteSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| "use client"; | ||
| import React from "react"; | ||
| import { useSatelliteStore } from "@/lib/store"; | ||
| import SatDropdown from "@/components/homeComponents/SatDropdown"; | ||
|
|
||
| export default function SatelliteSelector() { | ||
| const satelliteNames = useSatelliteStore((state) => state.satelliteNames); | ||
| const selectedSatellite = useSatelliteStore( | ||
| (state) => state.selectedSatellite, | ||
| ); | ||
| const setSelectedSatellite = useSatelliteStore( | ||
| (state) => state.setSelectedSatellite, | ||
| ); | ||
| const fetchAndSetSatelliteData = useSatelliteStore( | ||
| (state) => state.fetchAndSetSatelliteData, | ||
| ); | ||
|
|
||
| // Fetch data for each satellite and set it in the store | ||
| for (const satellite of satelliteNames) { | ||
| fetchAndSetSatelliteData(satellite); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="m-0 w-full p-0"> | ||
| <SatDropdown | ||
| satelliteNames={satelliteNames} | ||
| selectedSatellite={selectedSatellite} | ||
| setSelectedSatellite={setSelectedSatellite} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.