UNPKG

@dialpad/dialtone

Version:

Dialpad's Dialtone design system monorepo

69 lines (68 loc) 2.35 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const stack_constants = require("./stack_constants.cjs"); function _isDefaultDirection(direction) { return direction === stack_constants.DT_STACK_DIRECTION.default; } function _getValidDirection(direction) { if (directionPropType(direction) === "string") { return !_isDefaultDirection(direction) ? stack_constants.DT_STACK_DIRECTION[direction] : null; } else if (directionPropType(direction) === "object") { const { default: defaultStyle } = direction; return !_isDefaultDirection(defaultStyle) ? stack_constants.DT_STACK_DIRECTION[defaultStyle] : null; } else { return null; } } function _getValidGap(gap) { if (typeof gap === "string") { return gap; } else if (typeof gap === "object") { return gap.default; } else { return null; } } function directionPropType(value) { return typeof value; } function getDefaultDirectionClass(direction) { return _getValidDirection(direction) ? `d-stack--${stack_constants.DT_STACK_DIRECTION[_getValidDirection(direction)]}` : null; } function getResposiveDirectionClasses(direction) { if (directionPropType(direction) === "object") { return [ ...stack_constants.DT_STACK_RESPONSIVE_BREAKPOINTS.map((breakpoint) => { return direction[breakpoint] ? `d-stack--${breakpoint}-${direction[breakpoint]}` : null; }) ]; } else { return []; } } function getResposiveGapClasses(gap) { if (typeof gap === "object") { return [ ...stack_constants.DT_STACK_RESPONSIVE_BREAKPOINTS.map((breakpoint) => { return stack_constants.DT_STACK_GAP.includes(gap[breakpoint]) ? `d-stack--${breakpoint}-gap-${gap[breakpoint]}` : null; }) ]; } else { return []; } } function getResponsiveClasses(direction, gap) { return [ ...getResposiveDirectionClasses(direction), ...getResposiveGapClasses(gap) ]; } function getDefaultGapClass(gap) { const validGap = _getValidGap(gap); return stack_constants.DT_STACK_GAP.includes(validGap) ? `d-stack--gap-${validGap}` : null; } exports.directionPropType = directionPropType; exports.getDefaultDirectionClass = getDefaultDirectionClass; exports.getDefaultGapClass = getDefaultGapClass; exports.getResponsiveClasses = getResponsiveClasses; //# sourceMappingURL=utils.cjs.map