UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

29 lines (28 loc) 1.13 kB
"use strict"; exports.__esModule = true; exports.spacingUtility = exports.firstToUpper = exports.defaultFocus = void 0; var _styledComponents = require("styled-components"); const firstToUpper = str => str.charAt(0).toUpperCase() + str.slice(1); exports.firstToUpper = firstToUpper; const defaultFocus = ({ theme }) => (0, _styledComponents.css)(["outline:2px solid ", ";"], theme.orbit.paletteBlueNormal); exports.defaultFocus = defaultFocus; const setValue = value => { if (value == null) return null; return typeof value === "number" && value !== 0 ? `${value}px` : String(value); }; const spacingUtility = (spacing, prop = "margin") => { if (!spacing) return null; if (typeof spacing === "string" || typeof spacing === "number") { return (0, _styledComponents.css)(["", ":", ";"], prop, setValue(spacing)); } const { top, right, bottom, left } = spacing; return (0, _styledComponents.css)(["", "-top:", ";", "-right:", ";", "-bottom:", ";", "-left:", ";"], prop, setValue(top), prop, setValue(right), prop, setValue(bottom), prop, setValue(left)); }; exports.spacingUtility = spacingUtility;