UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

64 lines (63 loc) 1.56 kB
import { isNumber } from "es-toolkit/compat"; //#region src/base-ui/ActionIcon/utils.ts const actionIconOutdent = { large: 10, middle: 8, small: 5 }; const toCss = (value) => isNumber(value) ? `${value}px` : value; const calcSize = (iconSize) => { let blockSize; let borderRadius; if (isNumber(iconSize)) { const blockSize = iconSize * 1.8; return { blockSize, borderRadius: Math.floor(blockSize / 6) }; } switch (iconSize) { case "large": blockSize = 44; borderRadius = 8; break; case "middle": blockSize = 36; borderRadius = 6; break; case "small": blockSize = 24; borderRadius = 4; break; default: if (iconSize) { blockSize = iconSize?.blockSize || 36; borderRadius = iconSize?.borderRadius || 6; } else { blockSize = "1.8em"; borderRadius = "0.3em"; } } return { blockSize, borderRadius }; }; const calcOutdent = (iconSize) => { if (isNumber(iconSize)) return `${iconSize * .4}px`; switch (iconSize) { case "large": return `${actionIconOutdent.large}px`; case "middle": return `${actionIconOutdent.middle}px`; case "small": return `${actionIconOutdent.small}px`; default: if (iconSize) { const { blockSize } = calcSize(iconSize); const glyph = iconSize.size ?? 24; if (isNumber(blockSize) && isNumber(glyph)) return `${Math.max(0, (blockSize - glyph) / 2)}px`; return `calc((${toCss(blockSize)} - ${toCss(glyph)}) / 2)`; } return "0.4em"; } }; //#endregion export { actionIconOutdent, calcOutdent, calcSize }; //# sourceMappingURL=utils.mjs.map