Skip to content

Commit

Permalink
feat: shorten label in search (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 authored Dec 29, 2023
1 parent 9963d04 commit 5a32f05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 34 deletions.
12 changes: 10 additions & 2 deletions components/DropdownComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export const DropdownComponentHero = (props: DropdownComponentProps) => {
className="block h-full w-full appearance-none overflow-ellipsis rounded-xl border-4 border-black px-4 pr-12 text-lg opacity-40 focus:border-primary focus:opacity-80 md:pr-16 md:text-2xl"
>
{data.map((item) => (
<option key={item}>{item}</option>
<option key={item} value={item}>
{item.includes("University of California")
? "UC " + item.split(", ")[1]
: item}
</option>
))}
</select>
<div className="absolute right-2 top-5 h-8 w-8 text-2xl opacity-25 md:right-5 md:top-5 md:text-3xl xl:top-6">
Expand Down Expand Up @@ -56,7 +60,11 @@ export const DropdownComponentSearch = (props: DropdownComponentProps) => {
className="block h-full w-full appearance-none overflow-ellipsis rounded-xl border-4 border-black px-4 pr-12 text-lg opacity-40 outline-none focus:border-primary focus:opacity-80 md:pr-16 md:text-2xl"
>
{data.map((item) => (
<option key={item}>{item}</option>
<option key={item} value={item}>
{item.includes("University of California")
? "UC " + item.split(", ")[1]
: item}
</option>
))}
</select>
<div className="absolute right-2 top-[14px] h-8 w-8 text-2xl opacity-25 md:right-5 md:top-[18px] md:text-3xl">
Expand Down
35 changes: 3 additions & 32 deletions components/hero/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,14 @@ import React, { ChangeEvent, FormEvent, useState } from "react";
import { FaChevronDown, FaSearch } from "react-icons/fa";
import { useRouter } from "next/navigation";
import { analyticsEnum, logAnalytics } from "@/lib/analytics";
import { DropdownComponentHero } from "../DropdownComponent";

interface DropdownComponentProps {
defaultValue: string;
data: string[];
onChange: (value: string) => void;
}

const DropdownComponent = (props: DropdownComponentProps) => {
const { defaultValue, data, onChange } = props;

const [value, setValue] = useState(defaultValue);

const handleChange = (e: ChangeEvent<HTMLSelectElement>) => {
onChange(e.target.value);
setValue(e.target.value);
};

return (
<div className="flex place-content-center">
<div className="relative h-16 w-72 md:h-16 md:w-96 xl:h-20 xl:w-[600px]">
<select
value={value}
onChange={handleChange}
className="block h-full w-full appearance-none overflow-ellipsis rounded-xl border-4 border-black px-4 pr-12 text-lg opacity-40 outline-none focus:border-primary focus:opacity-80 md:pr-16 md:text-2xl"
>
{data.map((item) => (
<option key={item}>{item}</option>
))}
</select>
<div className="absolute right-2 top-5 h-8 w-8 text-2xl opacity-25 md:right-5 md:top-5 md:text-3xl xl:top-6">
<FaChevronDown />
</div>
</div>
</div>
);
};

const Hero = () => {
const router = useRouter();

Expand Down Expand Up @@ -101,12 +72,12 @@ const Hero = () => {

<form action="submit" onSubmit={handleSubmit}>
<div className="mt-6 flex flex-col gap-2 md:mt-12 xl:mt-16 xl:gap-4">
<DropdownComponent
<DropdownComponentHero
defaultValue={university}
data={Object.keys(UNIVERSITY_GE)}
onChange={setUniversity}
/>
<DropdownComponent
<DropdownComponentHero
defaultValue={ge}
data={UNIVERSITY_GE[university]}
onChange={setGE}
Expand Down

0 comments on commit 5a32f05

Please sign in to comment.