Skip to content

Instantly share code, notes, and snippets.

View develobing's full-sized avatar

Robin develobing

View GitHub Profile
@develobing
develobing / Portal.tsx
Created August 23, 2025 10:04
React Components
'use client';
import { ReactNode, useEffect, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
type PortalToProps = {
/** 예: '#modal-root', '.toast-zone' */
to: string;
children: ReactNode;
/** true면 포털 비활성화하고 현재 위치에 그냥 렌더 */
@develobing
develobing / usePullToRefresh.tsx
Last active August 10, 2025 05:33
React Hooks
import { RefObject, useEffect, useState } from 'react';
export interface PullToRefreshOptions {
/** 당겨서 새로고침이 발생할 거리(px) */
threshold?: number;
}
/**
* usePullToRefresh 훅: 스크롤 가능한 요소에서 아래로 당겨 새로고침 기능을 제공합니다.
*
@develobing
develobing / global.d.ts
Last active August 29, 2025 02:32
Types
export {};
declare global {
/* Utility Types */
type Nullable<T> = T | null | undefined;
type Optional<T> = T | undefined;
/** 값이 Y/N 으로 제한되어 있는 string */
type YN = 'Y' | 'N';
@develobing
develobing / modal.ts
Last active August 24, 2025 17:08
Vue Store
import { defineStore } from 'pinia';
import { computed, ref, watch } from 'vue';
import {
ToastOptions,
StringNumber,
BasicObject,
ModalList,
LoadingOptions,
ModalData,
DialogOptions,
We couldn’t find that file to show.
import { LeaveConfirmOptions, Nullable } from '@/types';
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { NavigationGuard } from 'vue-router';
export const useStoreNavigator = defineStore('navigator', () => {
const onBeforeLeave = ref<Nullable<NavigationGuard>>(null);
const setOnBeforeLeave = (callback: Nullable<NavigationGuard>) => {
onBeforeLeave.value = callback;
};
@develobing
develobing / useBeforeClose.ts
Last active July 15, 2025 08:41
Vue Composables
import { useStoreCommon } from '@/store/common';
import { storeToRefs } from 'pinia';
export const useBeforeClose = () => {
const storeCommon = useStoreCommon();
const { addBeforeCloseAction, removeBeforeCloseAction } = storeCommon;
const { beforeCloseActions } = storeToRefs(storeCommon);
// 브라우저 종료 큐 추가
const addQueue = (action: () => void) => {
import puppeteer from 'puppeteer';
const VIEWPORTS = [
{ width: 1080, height: 1920, name: 'mobile-portrait' },
{ width: 1920, height: 1080, name: 'desktop' },
{ width: 768, height: 1024, name: 'tablet-portrait' },
];
const url = 'http://localhost:3000'; // 여기에 PWA URL 입력