Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: shorten label in search #33

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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