@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.
22 lines • 837 B
JavaScript
import { css } from "styled-components";
export const firstToUpper = str => str.charAt(0).toUpperCase() + str.slice(1);
export const defaultFocus = ({
theme
}) => css(["outline:2px solid ", ";"], theme.orbit.paletteBlueNormal);
const setValue = value => {
if (value == null) return null;
return typeof value === "number" && value !== 0 ? `${value}px` : String(value);
};
export const spacingUtility = (spacing, prop = "margin") => {
if (!spacing) return null;
if (typeof spacing === "string" || typeof spacing === "number") {
return css(["", ":", ";"], prop, setValue(spacing));
}
const {
top,
right,
bottom,
left
} = spacing;
return css(["", "-top:", ";", "-right:", ";", "-bottom:", ";", "-left:", ";"], prop, setValue(top), prop, setValue(right), prop, setValue(bottom), prop, setValue(left));
};