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

[#98] Feat: 복사 짤 util 함수 구현 #100

Merged
merged 6 commits into from
Mar 5, 2024

Conversation

hyeonjinan096
Copy link
Contributor

📝 작업 내용

이미지 상세 모달 api 코드는 어느정도 완료한 상태인데 ui 머지 후 진행하는게 좋을 것 같아
이미지 복사 기능 함수를 구현했습니다.

이미지를 복사하여 클립보드에 저장합니다.
navigator.clipboard.write(data)를 사용합니다.

클립보드 API에서 제공하는 데이터 형식은 text, html, png 이미지 데이터로 제한되어있습니다.
따라서 서버에 있는 jpg파일을 png로 변환하는 로직을 추가했습니다.
파일 변환은 jpg 이미지를 <canvas> 요소에 그려서 png이미지로 변환합니다.

test는 layout-with-chat> index파일에 다음과 같이 버튼을 추가해주시면 될 것 같습니다:)

import { createFileRoute } from "@tanstack/react-router";
import copyZzal from "@/utils/copyZzal";
import { debounce } from "@/utils/debounce";

const Home = () => {
  const handleCopyClick = debounce(() => {
    copyZzal(
      "https://zzalmyu-bucket.s3.ap-northeast-2.amazonaws.com/upload/keroro9073%40gmail.comtemp_image10005225818988034545.jpg",
    );
  }, 500);

  return (
    <div>
      <button onClick={handleCopyClick}>복사 test 버튼</button>
    </div>
  );
};

export const Route = createFileRoute("/_layout-with-chat/")({
  component: Home,
});

📍 기타 (선택)

MDN문서 : Clipboard: write() method
stackoverflow : how to copy an image to clipboard?
close #98

@hyeonjinan096 hyeonjinan096 added the ✨ Feature 새로운 기능 추가 label Mar 5, 2024
@hyeonjinan096 hyeonjinan096 self-assigned this Mar 5, 2024
Copy link

vercel bot commented Mar 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
zzalmyu-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2024 4:15pm

@hyeonjinan096 hyeonjinan096 changed the title [#98] 복사 짤 util 함수 구현 [#98] Feat: 복사 짤 util 함수 구현 Mar 5, 2024
src/utils/copyZzal.ts Outdated Show resolved Hide resolved
src/utils/copyZzal.ts Outdated Show resolved Hide resolved
src/utils/copyZzal.ts Outdated Show resolved Hide resolved
src/utils/copyZzal.ts Show resolved Hide resolved
src/utils/copyZzal.ts Outdated Show resolved Hide resolved
src/utils/copyZzal.ts Outdated Show resolved Hide resolved
src/utils/copyZzal.ts Outdated Show resolved Hide resolved
src/utils/copyZzal.ts Outdated Show resolved Hide resolved
src/utils/copyZzal.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Kim-Jaemin420 Kim-Jaemin420 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@choi-ik choi-ik left a comment

Choose a reason for hiding this comment

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

LGTM!!!🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 X 9억

@hyeonjinan096 hyeonjinan096 merged commit 6d5f1a3 into main Mar 5, 2024
3 checks passed
@hyeonjinan096 hyeonjinan096 deleted the #98/feature/copy-zzal-function branch March 5, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 새로운 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

짤 복사 함수 구현
4 participants