UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

69 lines (67 loc) • 2.45 kB
const DEFAULT_SIZE = 80; const DEFAULT_CURVE = "smooth"; const DEFAULT_BLUR_RADIUS = 28; function resolveEdge(prop, size, curve) { if (!prop) return null; if (prop === true) return { size, curve }; if (typeof prop === "number") return { size: prop, curve }; if (typeof prop === "object" && prop !== null && (prop.size != null || prop.curve != null || prop.color != null)) { return { size: prop.size ?? size, curve: prop.curve ?? curve, color: prop.color }; } return null; } function resolveEdges(props, isRTL) { const size = props.size ?? DEFAULT_SIZE; const curve = props.curve ?? "smooth"; const leftLogical = isRTL ? props.end : props.start; const rightLogical = isRTL ? props.start : props.end; const top = resolveEdge(props.top, size, curve); const bottom = resolveEdge(props.bottom, size, curve); const left = resolveEdge(leftLogical ?? props.left, size, curve); const right = resolveEdge(rightLogical ?? props.right, size, curve); const hasColor = props.color != null || top?.color != null || bottom?.color != null || left?.color != null || right?.color != null; const mode = props.mode ?? (hasColor ? "overlay" : "mask"); if (hasColor && props.mode === "mask") { console.warn("[EdgeFade] `color` is ignored when `mode=\"mask\"` is set explicitly. either remove `color` or switch to `mode=\"overlay\"`."); } if (props.mode === "blur" && (top?.color != null || bottom?.color != null || left?.color != null || right?.color != null)) { console.warn("[EdgeFade] per-edge `color` is ignored in blur mode: the frost veil uses the global `color` only."); } return { top, bottom, left, right, mode, color: props.color, blurRadius: Math.max(0, props.blurRadius ?? DEFAULT_BLUR_RADIUS), frostProgression: Math.max(.05, Math.min(1, props.frostProgression ?? 1)) }; } function resolveRadius(radius, styleRadius) { if (styleRadius != null) { console.warn("[EdgeFade] `style.borderRadius` is ignored — use the `radius` prop instead so the corner clip integrates with the fade."); } return radius; } function flattenStyle(style) { const into = {}; mergeStyle(style, into); return into; } function mergeStyle(entry, into) { if (Array.isArray(entry)) for (const inner of entry) mergeStyle(inner, into); else if (entry && typeof entry === "object") Object.assign(into, entry); } export { DEFAULT_CURVE, flattenStyle, resolveEdges, resolveRadius }; //# sourceMappingURL=normalize.mjs.map