diff --git a/src/pages/ThemeList.tsx b/src/pages/ThemeList.tsx index d1e5714..7a8f64e 100644 --- a/src/pages/ThemeList.tsx +++ b/src/pages/ThemeList.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState, KeyboardEvent, ChangeEvent } from "react"; -import { Container } from "../styles/ThemeListStyled"; +import { Container, Select } from "../styles/ThemeListStyled"; import { useNavigate } from "react-router-dom"; import RoomTheme2 from "../components/RoomTheme2"; import Pagination from "../components/BasicPagination"; @@ -10,6 +10,7 @@ import { regions } from "../props/Regions"; const ThemeList = () => { const [inputKeyword, setInputKeyword] = useState(""); const [inputRegion, setInputRegion] = useState(""); + const [selectedRegion, setSelectedRegion] = useState(null); const [take, setTake] = useState(1); // 총 페이지 수 const [page, setPage] = useState(1); // 현재 페이지 const [themeList, setThemeList] = useState([]); @@ -47,6 +48,7 @@ const ThemeList = () => { // 지역 검색 const handleRegionClick = (name: string) => { setInputRegion(name); + setSelectedRegion(name); console.log(name); const fetchData = async () => { @@ -90,12 +92,13 @@ const ThemeList = () => {
{regions.map((region) => ( -
handleRegionClick(region.name)} + isSelected={selectedRegion === region.name} > {region.name} -
+ ))}
diff --git a/src/styles/ThemeListStyled.tsx b/src/styles/ThemeListStyled.tsx index 547a9ca..a9d83bb 100644 --- a/src/styles/ThemeListStyled.tsx +++ b/src/styles/ThemeListStyled.tsx @@ -46,7 +46,7 @@ export const Container = styled.div` display: flex; } - .category { + /* .category { margin-right: 1rem; padding: 0.5rem 1rem; border: 1px solid white; @@ -56,7 +56,7 @@ export const Container = styled.div` .category:hover { cursor: pointer; background: rgba(255, 255, 255, 0.3); - } + } */ .themeBox { width: 80vw; @@ -69,3 +69,28 @@ export const Container = styled.div` margin-top: 7vh; } `; + +export const Select = styled.div<{ isSelected: boolean }>` + margin-top: 1rem; + margin-right: 1rem; + padding: 0.5rem 1.3rem; + font-size: 1.2rem; + color: white; + border-radius: 1rem; + border: 1px solid white; + + background-color: ${(props) => (props.isSelected ? "#03ff8e18" : null)}; + color: ${(props) => (props.isSelected ? "#03ff8e" : "#fff")}; + border-color: ${(props) => (props.isSelected ? "#00ff8c" : "#fff")}; + + &:hover { + cursor: pointer; + background-color: rgba(255, 255, 255, 0.2); + border-color: #ccc; + } + + /* &:active { + background-color: rgba(255, 255, 255, 0.2); + border-color: #ccc; + } */ +`;