UNPKG

denwa-web-shared

Version:

A shared library for Next.js App Router projects containing reusable components, hooks, schemas, and utilities.

60 lines (41 loc) 1.14 kB
--- name: shared-constants description: > Use shared library constants like TIME and THEME. Load when hardcoding time durations, milliseconds, breakpoints, or offsets. type: core library: denwa-web-shared library_version: '1.0.58' sources: - 'src/server/constants/index.ts' --- # denwa-web-shared — Use library constants ## Setup ```tsx import { TIME, THEME } from 'denwa-web-shared/server'; const timeout = TIME.milliseconds.seconds5; const offset = THEME.OFFSET[4]; ``` ## Core Patterns ### Using TIME constants for durations ```tsx import { TIME } from 'denwa-web-shared/server'; export const fetchWithTimeout = async (url: string) => { const controller = new AbortController(); setTimeout(() => controller.abort(), TIME.milliseconds.seconds5); return fetch(url, { signal: controller.signal }); }; ``` ## Common Mistakes ### MEDIUM Hardcoding time values Wrong: ```tsx setTimeout(fn, 1000); ``` Correct: ```tsx import { TIME } from 'denwa-web-shared/server'; setTimeout(fn, TIME.milliseconds.seconds1); ``` Agents hardcode milliseconds values instead of using the TIME constant. Source: maintainer interview