@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.
412 lines • 11.9 kB
JavaScript
import { QUERIES } from "../../utils/mediaQuery/consts";
export let SIZES = /*#__PURE__*/function (SIZES) {
SIZES["NONE"] = "none";
SIZES["XXXSMALL"] = "XXXSmall";
SIZES["XXSMALL"] = "XXSmall";
SIZES["XSMALL"] = "XSmall";
SIZES["SMALL"] = "small";
SIZES["MEDIUM"] = "medium";
SIZES["LARGE"] = "large";
SIZES["XLARGE"] = "XLarge";
SIZES["XXLARGE"] = "XXLarge";
SIZES["XXXLARGE"] = "XXXLarge";
return SIZES;
}({});
export const marginClasses = {
[]: "m-0",
[]: "m-xxxs",
[]: "m-xxs",
[]: "m-xs",
[]: "m-sm",
[]: "m-md",
[]: "m-lg",
[]: "m-xl",
[]: "m-xxl",
[]: "m-xxxl",
[]: {
[]: "ld:m-0",
[]: "ld:m-xxxs",
[]: "ld:m-xxs",
[]: "ld:m-xs",
[]: "ld:m-sm",
[]: "ld:m-md",
[]: "ld:m-lg",
[]: "ld:m-xl",
[]: "ld:m-xxl",
[]: "ld:m-xxxl"
},
[]: {
[]: "de:m-0",
[]: "de:m-xxxs",
[]: "de:m-xxs",
[]: "de:m-xs",
[]: "de:m-sm",
[]: "de:m-md",
[]: "de:m-lg",
[]: "de:m-xl",
[]: "de:m-xxl",
[]: "de:m-xxxl"
},
[]: {
[]: "tb:m-0",
[]: "tb:m-xxxs",
[]: "tb:m-xxs",
[]: "tb:m-xs",
[]: "tb:m-sm",
[]: "tb:m-md",
[]: "tb:m-lg",
[]: "tb:m-xl",
[]: "tb:m-xxl",
[]: "tb:m-xxxl"
},
[]: {
[]: "lm:m-0",
[]: "lm:m-xxxs",
[]: "lm:m-xxs",
[]: "lm:m-xs",
[]: "lm:m-sm",
[]: "lm:m-md",
[]: "lm:m-lg",
[]: "lm:m-xl",
[]: "lm:m-xxl",
[]: "lm:m-xxxl"
},
[]: {
[]: "mm:m-0",
[]: "mm:m-xxxs",
[]: "mm:m-xxs",
[]: "mm:m-xs",
[]: "mm:m-sm",
[]: "mm:m-md",
[]: "mm:m-lg",
[]: "mm:m-xl",
[]: "mm:m-xxl",
[]: "mm:m-xxxl"
}
};
export const marginTopClasses = {
[]: "mt-0",
[]: "mt-xxxs",
[]: "mt-xxs",
[]: "mt-xs",
[]: "mt-sm",
[]: "mt-md",
[]: "mt-lg",
[]: "mt-xl",
[]: "mt-xxl",
[]: "mt-xxxl",
[]: {
[]: "ld:mt-0",
[]: "ld:mt-xxxs",
[]: "ld:mt-xxs",
[]: "ld:mt-xs",
[]: "ld:mt-sm",
[]: "ld:mt-md",
[]: "ld:mt-lg",
[]: "ld:mt-xl",
[]: "ld:mt-xxl",
[]: "ld:mt-xxxl"
},
[]: {
[]: "de:mt-0",
[]: "de:mt-xxxs",
[]: "de:mt-xxs",
[]: "de:mt-xs",
[]: "de:mt-sm",
[]: "de:mt-md",
[]: "de:mt-lg",
[]: "de:mt-xl",
[]: "de:mt-xxl",
[]: "de:mt-xxxl"
},
[]: {
[]: "tb:mt-0",
[]: "tb:mt-xxxs",
[]: "tb:mt-xxs",
[]: "tb:mt-xs",
[]: "tb:mt-sm",
[]: "tb:mt-md",
[]: "tb:mt-lg",
[]: "tb:mt-xl",
[]: "tb:mt-xxl",
[]: "tb:mt-xxxl"
},
[]: {
[]: "lm:mt-0",
[]: "lm:mt-xxxs",
[]: "lm:mt-xxs",
[]: "lm:mt-xs",
[]: "lm:mt-sm",
[]: "lm:mt-md",
[]: "lm:mt-lg",
[]: "lm:mt-xl",
[]: "lm:mt-xxl",
[]: "lm:mt-xxxl"
},
[]: {
[]: "mm:mt-0",
[]: "mm:mt-xxxs",
[]: "mm:mt-xxs",
[]: "mm:mt-xs",
[]: "mm:mt-sm",
[]: "mm:mt-md",
[]: "mm:mt-lg",
[]: "mm:mt-xl",
[]: "mm:mt-xxl",
[]: "mm:mt-xxxl"
}
};
export const marginRightClasses = {
[]: "mr-0",
[]: "mr-xxxs",
[]: "mr-xxs",
[]: "mr-xs",
[]: "mr-sm",
[]: "mr-md",
[]: "mr-lg",
[]: "mr-xl",
[]: "mr-xxl",
[]: "mr-xxxl",
[]: {
[]: "ld:mr-0",
[]: "ld:mr-xxxs",
[]: "ld:mr-xxs",
[]: "ld:mr-xs",
[]: "ld:mr-sm",
[]: "ld:mr-md",
[]: "ld:mr-lg",
[]: "ld:mr-xl",
[]: "ld:mr-xxl",
[]: "ld:mr-xxxl"
},
[]: {
[]: "de:mr-0",
[]: "de:mr-xxxs",
[]: "de:mr-xxs",
[]: "de:mr-xs",
[]: "de:mr-sm",
[]: "de:mr-md",
[]: "de:mr-lg",
[]: "de:mr-xl",
[]: "de:mr-xxl",
[]: "de:mr-xxxl"
},
[]: {
[]: "tb:mr-0",
[]: "tb:mr-xxxs",
[]: "tb:mr-xxs",
[]: "tb:mr-xs",
[]: "tb:mr-sm",
[]: "tb:mr-md",
[]: "tb:mr-lg",
[]: "tb:mr-xl",
[]: "tb:mr-xxl",
[]: "tb:mr-xxxl"
},
[]: {
[]: "lm:mr-0",
[]: "lm:mr-xxxs",
[]: "lm:mr-xxs",
[]: "lm:mr-xs",
[]: "lm:mr-sm",
[]: "lm:mr-md",
[]: "lm:mr-lg",
[]: "lm:mr-xl",
[]: "lm:mr-xxl",
[]: "lm:mr-xxxl"
},
[]: {
[]: "mm:mr-0",
[]: "mm:mr-xxxs",
[]: "mm:mr-xxs",
[]: "mm:mr-xs",
[]: "mm:mr-sm",
[]: "mm:mr-md",
[]: "mm:mr-lg",
[]: "mm:mr-xl",
[]: "mm:mr-xxl",
[]: "mm:mr-xxxl"
}
};
export const marginBottomClasses = {
[]: "mb-0",
[]: "mb-xxxs",
[]: "mb-xxs",
[]: "mb-xs",
[]: "mb-sm",
[]: "mb-md",
[]: "mb-lg",
[]: "mb-xl",
[]: "mb-xxl",
[]: "mb-xxxl",
[]: {
[]: "ld:mb-0",
[]: "ld:mb-xxxs",
[]: "ld:mb-xxs",
[]: "ld:mb-xs",
[]: "ld:mb-sm",
[]: "ld:mb-md",
[]: "ld:mb-lg",
[]: "ld:mb-xl",
[]: "ld:mb-xxl",
[]: "ld:mb-xxxl"
},
[]: {
[]: "de:mb-0",
[]: "de:mb-xxxs",
[]: "de:mb-xxs",
[]: "de:mb-xs",
[]: "de:mb-sm",
[]: "de:mb-md",
[]: "de:mb-lg",
[]: "de:mb-xl",
[]: "de:mb-xxl",
[]: "de:mb-xxxl"
},
[]: {
[]: "tb:mb-0",
[]: "tb:mb-xxxs",
[]: "tb:mb-xxs",
[]: "tb:mb-xs",
[]: "tb:mb-sm",
[]: "tb:mb-md",
[]: "tb:mb-lg",
[]: "tb:mb-xl",
[]: "tb:mb-xxl",
[]: "tb:mb-xxxl"
},
[]: {
[]: "lm:mb-0",
[]: "lm:mb-xxxs",
[]: "lm:mb-xxs",
[]: "lm:mb-xs",
[]: "lm:mb-sm",
[]: "lm:mb-md",
[]: "lm:mb-lg",
[]: "lm:mb-xl",
[]: "lm:mb-xxl",
[]: "lm:mb-xxxl"
},
[]: {
[]: "mm:mb-0",
[]: "mm:mb-xxxs",
[]: "mm:mb-xxs",
[]: "mm:mb-xs",
[]: "mm:mb-sm",
[]: "mm:mb-md",
[]: "mm:mb-lg",
[]: "mm:mb-xl",
[]: "mm:mb-xxl",
[]: "mm:mb-xxxl"
}
};
export const marginLeftClasses = {
[]: "ml-0",
[]: "ml-xxxs",
[]: "ml-xxs",
[]: "ml-xs",
[]: "ml-sm",
[]: "ml-md",
[]: "ml-lg",
[]: "ml-xl",
[]: "ml-xxl",
[]: "ml-xxxl",
[]: {
[]: "ld:ml-0",
[]: "ld:ml-xxxs",
[]: "ld:ml-xxs",
[]: "ld:ml-xs",
[]: "ld:ml-sm",
[]: "ld:ml-md",
[]: "ld:ml-lg",
[]: "ld:ml-xl",
[]: "ld:ml-xxl",
[]: "ld:ml-xxxl"
},
[]: {
[]: "de:ml-0",
[]: "de:ml-xxxs",
[]: "de:ml-xxs",
[]: "de:ml-xs",
[]: "de:ml-sm",
[]: "de:ml-md",
[]: "de:ml-lg",
[]: "de:ml-xl",
[]: "de:ml-xxl",
[]: "de:ml-xxxl"
},
[]: {
[]: "tb:ml-0",
[]: "tb:ml-xxxs",
[]: "tb:ml-xxs",
[]: "tb:ml-xs",
[]: "tb:ml-sm",
[]: "tb:ml-md",
[]: "tb:ml-lg",
[]: "tb:ml-xl",
[]: "tb:ml-xxl",
[]: "tb:ml-xxxl"
},
[]: {
[]: "lm:ml-0",
[]: "lm:ml-xxxs",
[]: "lm:ml-xxs",
[]: "lm:ml-xs",
[]: "lm:ml-sm",
[]: "lm:ml-md",
[]: "lm:ml-lg",
[]: "lm:ml-xl",
[]: "lm:ml-xxl",
[]: "lm:ml-xxxl"
},
[]: {
[]: "mm:ml-0",
[]: "mm:ml-xxxs",
[]: "mm:ml-xxs",
[]: "mm:ml-xs",
[]: "mm:ml-sm",
[]: "mm:ml-md",
[]: "mm:ml-lg",
[]: "mm:ml-xl",
[]: "mm:ml-xxl",
[]: "mm:ml-xxxl"
}
};
const getMarginValue = margin => typeof margin === "number" ? `${margin}px` : margin;
export const getMargin = margin => {
if (typeof margin === "number" || typeof margin === "string") return {
vars: {
"--text-margin": getMarginValue(margin)
},
classes: ["m-[var(--text-margin)]"]
};
const {
top,
bottom,
left,
right
} = margin || {};
const cssVar = {};
const classes = ["m-0"];
if (top) {
classes.push("mt-[var(--text-margin-top)]");
cssVar["--text-margin-top"] = getMarginValue(top);
}
if (bottom) {
classes.push("mb-[var(--text-margin-bottom)]");
cssVar["--text-margin-bottom"] = getMarginValue(bottom);
}
if (left) {
classes.push("ml-[var(--text-margin-left)]");
cssVar["--text-margin-left"] = getMarginValue(left);
}
if (right) {
classes.push("mr-[var(--text-margin-right)]");
cssVar["--text-margin-right"] = getMarginValue(right);
}
return {
vars: cssVar,
classes
};
};
export default getMargin;