@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.
25 lines • 789 B
JavaScript
import { css } from "styled-components";
import { QUERIES } from "./consts";
export const TOKEN = {
mediumMobile: "widthBreakpointMediumMobile",
largeMobile: "widthBreakpointLargeMobile",
tablet: "widthBreakpointTablet",
desktop: "widthBreakpointDesktop",
largeDesktop: "widthBreakpointLargeDesktop"
};
export const getBreakpointWidth = (name, theme, pure) => {
return pure ? theme.orbit[TOKEN[name]] : `(min-width: ${theme.orbit[TOKEN[name]]}px)`;
};
const mediaQueries = Object.values(QUERIES).reduce((acc, device) => {
acc[device] = style => css(["@media ", "{", ";}"], ({
theme
}) => getBreakpointWidth(device, theme), style);
return acc;
}, {
mediumMobile: {},
largeMobile: {},
tablet: {},
desktop: {},
largeDesktop: {}
});
export default mediaQueries;