UNPKG

@bookbox/view-html

Version:

Bookbox view for html

28 lines (27 loc) 875 B
import { getLayoutView } from "@bookbox/core"; const defaultSize = 100; const getNormalSize = (value) => value <= 0 ? defaultSize : Math.floor(value); export function parseSize(value = 1) { if (typeof value === 'string') { if (value[value.length - 1] === '%') { const size = parseFloat(value); if (Number.isNaN(size)) { return defaultSize; } return getNormalSize(size); } return defaultSize; } return getNormalSize(value * defaultSize); } export function getCssSizeStyle(params) { const { width, height } = params; return `max-height: ${height}vh; max-width: ${width}%`; } export function getLayoutParams(props) { var _a; return { view: getLayoutView(props), position: (_a = props.position) !== null && _a !== void 0 ? _a : 'center', }; }