Skip to content
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
7 changes: 5 additions & 2 deletions client/src/components/homeSection/Hero/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { Button } from "../../ui/button/Button";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { TextField } from "../../ui/textField/TextField.tsx";
import { useMediaQuery } from "../../../hooks/useMediaQuery.tsx";

export const Hero = () => {
const navigate = useNavigate();

const isMobile = useMediaQuery("(max-width: 640px)");
const [subject, setSubject] = useState<string>("english");

const onSearch = () => {
Expand Down Expand Up @@ -40,8 +41,10 @@ export const Hero = () => {
<div className="relative flex flex-col sm:flex-row items-center justify-center gap-4 sm:gap-6 max-w-2xl lg:max-w-3xl mx-auto mb-16 sm:mb-20 lg:mb-24">
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 hidden lg:block w-[620px] h-[80px] bg-[#27222EB3] rounded-[60px] -z-10"></div>
<TextField
type="search"
autoComplete="off"
containerClassName="w-[200px] sm:w-[300px] md:w-[400px]"
placeholder="What do you want to learn?"
placeholder={isMobile ? "Search..." : "What do you want to learn?"}
variant="hero"
onValueChange={setSubject}
/>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ui/textField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const inputStyles = cva(
primary: "text-light-100 placeholder:text-dark-400",
secondary: "text-light-500 placeholder:text-light-500",
primarySmall: "text-light-100 placeholder:text-dark-400",
hero: "text-light-500 placeholder:text-light-500",
hero: "text-light-500 placeholder:text-light-500 placeholder:text-xs",
},
state: {
default: "",
Expand Down
15 changes: 15 additions & 0 deletions client/src/hooks/useMediaQuery.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useEffect, useState } from "react";

export function useMediaQuery(query: string) {
const [matches, setMatches] = useState(false);

useEffect(() => {
const m = window.matchMedia(query);
const onChange = () => setMatches(m.matches);
onChange();
m.addEventListener("change", onChange);
return () => m.removeEventListener("change", onChange);
}, [query]);

return matches;
}
Loading