diff --git a/client/src/app/user/home/page.tsx b/client/src/app/user/home/page.tsx index 2a20346c..e72241dd 100644 --- a/client/src/app/user/home/page.tsx +++ b/client/src/app/user/home/page.tsx @@ -3,7 +3,7 @@ import CardTag from "@/components/tags/card-tag"; import { getTags } from "@/components/tags/hooks/get-tags"; import { Input } from "@/components/ui/input"; -import { ScrollArea } from "@/components/ui/scroll-area"; +import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { Community } from "@/features/account/types/community"; import { CommunityCard } from "@/features/home/user/components/CommunityCard"; import { GetCommunities } from "@/features/home/user/hooks/gets-communities"; @@ -20,6 +20,11 @@ export default function Home() { const [tags, setTags] = useState([]); const [selectedTags, setSelectedTags] = useState([]); const isFirstRender = useRef(true); + const [searchQueryTag, setSearchQueryTag] = useState(""); + + const filteredTags = tags?.filter(tag => + tag.name.toLowerCase().includes(searchQueryTag.toLowerCase()) + ); useEffect(() => { if (isFirstRender.current) { @@ -82,13 +87,23 @@ export default function Home() {

タグで絞り込む

-
- {tags?.map(tag => ( - handleTagClick(tag)}> - {tag.name} - - ))} -
+ setSearchQueryTag(e.target.value)} + className="mb-4" + /> + +
+ {filteredTags?.map(tag => ( + handleTagClick(tag)}> + {tag.name} + + ))} +
+ +
diff --git a/client/src/features/home/community/components/SearchTags.tsx b/client/src/features/home/community/components/SearchTags.tsx index 0a4ac2ae..aeee38dd 100644 --- a/client/src/features/home/community/components/SearchTags.tsx +++ b/client/src/features/home/community/components/SearchTags.tsx @@ -1,5 +1,8 @@ import CardTag from "@/components/tags/card-tag"; import { TagType } from "@/features/tags/types/tag"; +import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; +import { Input } from "@/components/ui/input"; +import { useState } from "react"; import style from "../styles/search-tags.module.scss"; type SearchTagsProps = { @@ -8,16 +11,32 @@ type SearchTagsProps = { }; export function SearchTags({ tags, handleTagClick }: SearchTagsProps) { + const [searchQuery, setSearchQuery] = useState(""); + + const filteredTags = tags?.filter(tag => + tag.name.toLowerCase().includes(searchQuery.toLowerCase()) + ); + return (

タグで絞り込む

-
- {tags?.map(tag => ( - handleTagClick(tag)}> - {tag.name} - - ))} -
+ setSearchQuery(e.target.value)} + className="mb-4" + /> + +
+ {filteredTags?.map(tag => ( + handleTagClick(tag)}> + {tag.name} + + ))} +
+ +
); -} +} \ No newline at end of file diff --git a/client/src/features/home/community/styles/search-tags.module.scss b/client/src/features/home/community/styles/search-tags.module.scss index f49494b2..3b0f9480 100644 --- a/client/src/features/home/community/styles/search-tags.module.scss +++ b/client/src/features/home/community/styles/search-tags.module.scss @@ -1,22 +1,25 @@ @use "@/styles/theme"; - .container { - background-color: theme.$theme-community-sub; - padding: 1rem; - border-radius: 0.5rem; - margin: 1rem 0; - } + background-color: theme.$theme-community-sub; + padding: 1rem; + border-radius: 0.5rem; + margin: 1rem 0; +} + +.title { + font-size: 1.25rem; + font-weight: bold; + color: black; + margin-bottom: 0.5rem; +} - .title { - font-size: 1.25rem; - font-weight: bold; - color: black; - margin-bottom: 0.5rem; - } +.tags { + overflow-x: auto; + white-space: nowrap; +} - .tags { - display: flex; - flex-wrap: wrap; - gap: 0.5rem; - } \ No newline at end of file +.tagsContainer { + display: inline-flex; + gap: 0.5rem; +} \ No newline at end of file