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

home画面のタグ表示 #45

Closed
wants to merge 1 commit into from
Closed
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
31 changes: 23 additions & 8 deletions client/src/app/user/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -20,6 +20,11 @@ export default function Home() {
const [tags, setTags] = useState<TagType[]>([]);
const [selectedTags, setSelectedTags] = useState<TagType[]>([]);
const isFirstRender = useRef(true);
const [searchQueryTag, setSearchQueryTag] = useState("");

const filteredTags = tags?.filter(tag =>
tag.name.toLowerCase().includes(searchQueryTag.toLowerCase())
);

useEffect(() => {
if (isFirstRender.current) {
Expand Down Expand Up @@ -82,13 +87,23 @@ export default function Home() {

<div className="bg-[#FFFFFF1A] p-4 rounded-md mb-6">
<h1 className="text-xl font-bold text-[#FFFFFFD0] mb-2">タグで絞り込む</h1>
<div className="flex flex-wrap gap-2">
{tags?.map(tag => (
<CardTag key={tag.name} variant={tag.color} onClick={() => handleTagClick(tag)}>
{tag.name}
</CardTag>
))}
</div>
<Input
type="text"
placeholder="タグ名で検索..."
value={searchQueryTag}
onChange={(e) => setSearchQueryTag(e.target.value)}
className="mb-4"
/>
<ScrollArea className="w-full whitespace-nowrap rounded-md gap-1">
<div className="flex w-max space-x-4 p-4">
{filteredTags?.map(tag => (
<CardTag key={tag.name} variant={tag.color} onClick={() => handleTagClick(tag)}>
{tag.name}
</CardTag>
))}
</div>
<ScrollBar orientation="horizontal" />
</ScrollArea>
</div>

<ScrollArea className={styles.communityContainer}>
Expand Down
35 changes: 27 additions & 8 deletions client/src/features/home/community/components/SearchTags.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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 (
<div className={style.container}>
<h1 className={style.title}>タグで絞り込む</h1>
<div className={style.tags}>
{tags?.map(tag => (
<CardTag key={tag.name} variant={tag.color} onClick={() => handleTagClick(tag)}>
{tag.name}
</CardTag>
))}
</div>
<Input
type="text"
placeholder="タグ名で検索..."
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
className="mb-4"
/>
<ScrollArea className="w-full whitespace-nowrap rounded-md border gap-1">
<div className="flex w-max space-x-4 p-4">
{filteredTags?.map(tag => (
<CardTag key={tag.name} variant={tag.color} onClick={() => handleTagClick(tag)}>
{tag.name}
</CardTag>
))}
</div>
<ScrollBar orientation="horizontal" />
</ScrollArea>
</div>
);
}
}
37 changes: 20 additions & 17 deletions client/src/features/home/community/styles/search-tags.module.scss
Original file line number Diff line number Diff line change
@@ -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;
}
.tagsContainer {
display: inline-flex;
gap: 0.5rem;
}
Loading