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

✨Feat(#313): 스테디 상세 페이지에 연락수단 클립보드 기능 추가 #314

Merged
merged 4 commits into from
Dec 2, 2023
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
9 changes: 8 additions & 1 deletion src/app/(steady)/steady/detail/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import promoteSteady from "@/services/steady/promoteSteady";
import type { SteadyDetailsType } from "@/services/types";
import getMyProfile from "@/services/user/getMyProfile";
import Button, { buttonSize } from "@/components/_common/Button";
import ContactTag from "@/components/_common/ContactTag";
import Dropdown from "@/components/_common/Dropdown";
import Icon from "@/components/_common/Icon";
import { AlertModal, InfoModal, UserModal } from "@/components/_common/Modal";
Expand Down Expand Up @@ -407,7 +408,7 @@ const SteadyDetailPage = ({ params }: { params: { id: string } }) => {
</div>
</div>
</div>
<div className="flex w-full max-lg:flex-col max-lg:gap-10 xl:flex-row">
<div className="grid w-full items-center max-sm:grid-cols-1 max-sm:gap-10 sm:grid-cols-1 sm:gap-10 md:grid-cols-2 md:gap-10 lg:grid-cols-2 lg:gap-25 xl:grid-cols-4">
Comment on lines -410 to +411
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 배치할 요소가 많아지면 영역을 더 나눠서 flex로 배치하는 것 보다 이렇게 grid를 쓰는 것도 좋은 것 같습니다..!

<div className="flex w-full">
<div className="flex w-225 items-center gap-10">
<div className={steadyDetailTagItems}>진행 방식</div>
Expand Down Expand Up @@ -436,6 +437,12 @@ const SteadyDetailPage = ({ params }: { params: { id: string } }) => {
</div>
</div>
</div>
<div className="flex w-full">
<div className="flex w-225 items-center gap-10">
<div className={steadyDetailTagItems}>연락 수단</div>
<ContactTag contactUrl={steadyDetailsData.contact} />
</div>
</div>
</div>
<div className="flex w-full gap-10 max-lg:mt-10">
<div className={steadyDetailTagItems}>기술 스택</div>
Expand Down
35 changes: 3 additions & 32 deletions src/app/(user-menu)/mysteady/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { Fragment } from "react";
import InfiniteScroll from "react-infinite-scroller";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { useToast } from "@/components/ui/use-toast";
import { cn } from "@/lib/utils";
import { CopyIcon } from "@radix-ui/react-icons";
import { Badge, Separator } from "@radix-ui/themes";
import { Separator } from "@radix-ui/themes";
import { format } from "date-fns";
import type { MySteadyContentType } from "@/services/types";
import Button, { buttonSize } from "@/components/_common/Button";
import ContactTag from "@/components/_common/ContactTag";
import Dropdown from "@/components/_common/Dropdown";
import Icon from "@/components/_common/Icon";
import { AlertModal } from "@/components/_common/Modal";
Expand Down Expand Up @@ -40,7 +39,6 @@ const MySteadyPage = () => {
direction: "desc",
});
const ref = useScrollTo<HTMLDivElement>({ top: 0 }, [search]);
const { toast } = useToast();

const renderIcon = (steady: MySteadyContentType) => {
if (search === "finished") {
Expand Down Expand Up @@ -109,22 +107,6 @@ const MySteadyPage = () => {
}
};

const handleCopyClipBoard = async (text: string) => {
try {
await navigator.clipboard.writeText(text);
toast({
description: "연락 수단 복사 성공!",
variant: "green",
});
} catch (error) {
toast({
description: "연락 수단 복사 실패!",
variant: "red",
});
console.error("복사에 실패했습니다.");
}
};

return (
<div className="flex flex-col max-sm:w-400 sm:w-500 md:w-600 lg:w-800 xl:w-1000">
<div className="flex items-center justify-between">
Expand Down Expand Up @@ -174,18 +156,7 @@ const MySteadyPage = () => {
</div>
</Link>
<div className="flex items-center justify-center gap-20">
<Badge
color={"indigo"}
size={"2"}
>
<button
className="flex items-center gap-10"
onClick={() => handleCopyClipBoard(steady.contact)}
>
<div>연락 수단</div>
<CopyIcon />
</button>
</Badge>
<ContactTag contactUrl={steady.contact} />
<div className="text-bold max-w-fit text-15 text-st-gray-100 max-sm:hidden">
{steady.isLeader ? "생성일: " : "참여일: "}
{format(new Date(steady.joinedAt), "yyyy.MM.dd")}
Expand Down
24 changes: 24 additions & 0 deletions src/components/_common/ContactTag/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { CopyIcon } from "@radix-ui/react-icons";
import { Badge } from "@radix-ui/themes";
import useCopySteadyContact from "@/hooks/useCopySteadyContact";

const ContactTag = ({ contactUrl }: { contactUrl: string }) => {
const { copySteadyContact } = useCopySteadyContact();

return (
<Badge
color={"indigo"}
size={"2"}
>
<button
className="flex items-center gap-10"
onClick={() => copySteadyContact(contactUrl)}
>
<div>연락 수단</div>
<CopyIcon />
</button>
</Badge>
);
};

export default ContactTag;
25 changes: 25 additions & 0 deletions src/hooks/useCopySteadyContact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useToast } from "@/components/ui/use-toast";

const useCopySteadyContact = () => {
const { toast } = useToast();

const copySteadyContact = async (text: string) => {
try {
await navigator.clipboard.writeText(text);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍

toast({
description: "연락 수단 복사 성공!",
variant: "green",
});
} catch (error) {
toast({
description: "연락 수단 복사 실패!",
variant: "red",
});
console.error("복사에 실패했습니다.");
}
};

return { copySteadyContact };
};

export default useCopySteadyContact;
Loading