diff --git a/frontend/src/components/SearchBox/SearchBox.jsx b/frontend/src/components/SearchBox/SearchBox.jsx new file mode 100644 index 0000000..3a191a3 --- /dev/null +++ b/frontend/src/components/SearchBox/SearchBox.jsx @@ -0,0 +1,28 @@ +import React, { useState } from "react"; +import { LuSearch } from "react-icons/lu"; +import styles from "./SearchBox.module.css"; + +const SearchBox = ({ onSearch }) => { + const [query, setQuery] = useState(""); + const handleInputChange = (e) => { + setQuery(e.target.value); + onSearch(e.target.value); + }; + + return ( +
+
+ + +
+
+ ); +}; + +export default SearchBox; diff --git a/frontend/src/components/SearchBox/SearchBox.module.css b/frontend/src/components/SearchBox/SearchBox.module.css new file mode 100644 index 0000000..45189cf --- /dev/null +++ b/frontend/src/components/SearchBox/SearchBox.module.css @@ -0,0 +1,84 @@ +.searchBoxWrapper { + position: relative; + display: flex; + align-items: center; +} + +.group { + display: flex; + line-height: 28px; + align-items: center; + position: relative; + max-width: 190px; +} + +.searchIcon { + cursor: pointer; + position: absolute; + left: 1rem; + width: 1rem; + height: 1rem; +} + +.input { + width: 100%; + height: 40px; + line-height: 28px; + padding: 0 1rem; + padding-left: 2.5rem; + border: 1px solid var(--input-border-color); + border-radius: 8px; + outline: none; + color: var(--text-color); + background: transparent; + border-radius: 12px; + font-family: Poppins; + font-size: 14px; + font-weight: 400; + opacity: 1; + letter-spacing: 0.5px; + transition: border-color 0.3s ease; +} + +.input::placeholder { + color: #9e9ea7; + opacity: 1; + font-family: Poppins; + font-size: 14px; + font-weight: 400; + line-height: 24px; + text-align: left; +} + +.input:focus { + outline: none; + border-color: #2d79f3; +} + +.inputField:hover { + border-color: #2d79f3; +} + +.input:focus-within { + border: 1px solid #2d79f3; +} + +/* .visible { + display: block; + width: calc(100% - 20px); +} */ + +@media (max-width: 800px) { + /* .input { + display: none; + } */ + + /* .visible { + display: block; + width: calc(100% - 20px); + } */ + + .searchIcon { + display: block; + } +} diff --git a/frontend/src/pages/Explore/Explore.jsx b/frontend/src/pages/Explore/Explore.jsx index 0008d93..7a39e03 100644 --- a/frontend/src/pages/Explore/Explore.jsx +++ b/frontend/src/pages/Explore/Explore.jsx @@ -7,12 +7,15 @@ import { calculateColumns, getLeftoverGridClass, splitCardsIntoMainAndLeftover, + SearchBox, cardData, formatName, } from "./imports"; const Explore = () => { const [columns, setColumns] = useState(3); + const [searchQuery, setSearchQuery] = useState(""); + const [filteredCards, setFilteredCards] = useState(cardData); useEffect(() => { const handleResize = () => { @@ -25,8 +28,18 @@ const Explore = () => { return () => window.removeEventListener("resize", handleResize); }, []); + useEffect(() => { + const filtered = cardData.filter( + (card) => + card.name.toLowerCase().includes(searchQuery.toLowerCase()) || + card.title.toLowerCase().includes(searchQuery.toLowerCase()) || + card.company.toLowerCase().includes(searchQuery.toLowerCase()) + ); + setFilteredCards(filtered); + }, [searchQuery]); + const { mainGridCards, leftoverCards } = splitCardsIntoMainAndLeftover( - cardData, + filteredCards, columns ); @@ -34,8 +47,11 @@ const Explore = () => { <>
-

Explore

- +
+

Explore

+ +
+
{mainGridCards.map((card, index) => ( diff --git a/frontend/src/pages/Explore/Explore.module.css b/frontend/src/pages/Explore/Explore.module.css index 112ec37..8bdf2e6 100644 --- a/frontend/src/pages/Explore/Explore.module.css +++ b/frontend/src/pages/Explore/Explore.module.css @@ -12,18 +12,24 @@ .mainText { display: flex; align-items: center; + justify-content: space-between; margin-bottom: 20px; width: 100%; max-width: 1200px; } -.mainText h1 { +.leftContainer { + display: flex; + align-items: center; +} + +.leftContainer h1 { margin: 0; margin-right: 10px; } .arrowIcon { - font-size: 2rem; + font-size: 1.8rem; vertical-align: middle; } @@ -50,11 +56,21 @@ margin-top: 15px; } -/* Media query for screens up to 800px */ @media (max-width: 800px) { .gridContainer { grid-template-columns: 1fr; } + + .leftContainer h1 { + margin: 0; + margin-right: 10px; + font-size: 24px; + } + + .arrowIcon { + font-size: 1rem; + vertical-align: middle; + } } @media (min-width: 801px) and (max-width: 1024px) { diff --git a/frontend/src/pages/Explore/imports/index.js b/frontend/src/pages/Explore/imports/index.js index 650b6b3..77ea801 100644 --- a/frontend/src/pages/Explore/imports/index.js +++ b/frontend/src/pages/Explore/imports/index.js @@ -15,3 +15,4 @@ export { } from "../gridHelper"; export { default as cardData } from "../cardData"; +export { default as SearchBox } from "../../../components/SearchBox/SearchBox";