Skip to content

Instantly share code, notes, and snippets.

@hongggyelim
hongggyelim / signUpPage.tsx
Last active April 28, 2025 08:29
트러블슈팅: 제출 버튼이 아닌데 제출되는 문제
export default function Signup() {
const [part, setPart] = useState<"account" | "info">("account");
const isAccountPart = part === "account";
// 임시 핸들러
const onSubmit: SubmitHandler<User.FormValue> = (data) => {
console.log(data);
};
return (
@hongggyelim
hongggyelim / theme.css.ts
Last active April 28, 2025 08:30
디자인 시스템 색상, 폰트 토큰
import { createGlobalTheme } from "@vanilla-extract/css";
// 색상 토큰
export const ColorVar = createGlobalTheme(":root", {
white: "#fff",
transparent: "transparent",
green: "#00CD0E",
yellow: "#FFD000",
red: "#D90000",
grey: {
@hongggyelim
hongggyelim / workflow.yml
Created April 25, 2025 05:25
빌드 자동화 CI
name: workRoot CI
on:
push:
branches:
- main # main 브랜치에 푸시될 때 실행
- dev
pull_request:
branches:
- dev
@hongggyelim
hongggyelim / addform.tsx
Last active April 25, 2025 05:14
단계별 폼 데이터 처리
export default function AddFormPage() {
const router = useRouter();
// 리액트 훅폼에서 관리할 데이터 타입 지정 및 메서드 호출 (상위 컴포넌트 = useForm 사용)
const methods = useForm<SubmitFormDataType>({
mode: "onChange",
shouldUnregister: false,
defaultValues: {
isPublic: true,
hourlyWage: 0,
isNegotiableWorkDays: false,
@hongggyelim
hongggyelim / BaseInput.tsx
Last active April 25, 2025 05:10
확장성과 재사용성을 고려한 공통 Input 컴포넌트
/**
* @param name: string - 필수값
* @param type: "text" | "password" | ... - 필수값
* @param variant: "white" | "transparent";
* @param size: "w-[00px] h-[00px] lg:w-[00px] lg:h-[00px]" - 기본값: "w-[327px] h-[54px] lg:w-[640px] lg:h-[64px]"
* @param placeholder: string
* @param errormessage: string - 에러메시지 + 테두리 색상 변경
* @param feedbackMessage: string - 메시지만 띄우고 색상 변경 X
* @param disabled: boolean
@hongggyelim
hongggyelim / useMovePointByWidth.js
Created April 25, 2025 02:02
커스텀 훅 useMovePointByWidth
const useMovePointByWidth = () => {
const containerRef = useRef<HTMLDivElement | null>(null); // 기준이 될 DOM 요소
const [width, setWidth] = useState(0);
const [prevWidth, setPrevWidth] = useState(0);
const { points, setPoints } = useGraphStore();
useEffect(() => {
if (!containerRef.current) return;
@hongggyelim
hongggyelim / clipboard.js
Last active April 25, 2025 01:59
IOS safari 환경의 clipboard API 제한 대응
const [imageBlob, setImageBlob] = useState<Blob | null>(null);
const imageRef = useRef<HTMLDivElement>(null);
const image = imageRef.current;
const getImage = async (): Promise<Blob | null> => {
if (!image) return null;
try {
const canvas = await html2canvas(image, { scale: 2 });
return new Promise((resolve) => {
canvas.toBlob((blob) => {
@hongggyelim
hongggyelim / redirect.js
Created April 25, 2025 01:53
카카오톡 인앱 브라우저 - 파일 다운로드 제한 대응
useEffect(() => {
const userAgent = navigator.userAgent.toLowerCase();
const isKakaoInApp = userAgent.includes("kakaotalk");
// 카카오톡 인앱 브라우저일 경우에만 실행
if (isKakaoInApp) {
const targetUrl = "https://life-graph.vercel.app/";
window.location.replace(
`kakaotalk://web/openExternal?url=${encodeURIComponent(targetUrl)}`