@zohodesk/utils
Version:
Unified Component Library - Utils
95 lines (82 loc) • 1.97 kB
JavaScript
/* eslint-disable no-labels */
/* eslint-disable no-restricted-syntax */
import PropTypes from 'prop-types';
import { variants, colors, sizes, shapes, decorations, positions } from "../constantProps";
export const getVariantProps = (variants, exvariant) => {
let variant = [];
if (exvariant) {
variant = [...exvariant];
}
variant = [...variant, ...variants];
return {
variant: PropTypes.oneOf(variant)
};
};
export const variantProps = {
variant: PropTypes.oneOf(variants)
};
export const getColorProps = (colors, excolors) => {
let color = [];
if (excolors) {
color = [...excolors];
}
color = [...color, ...colors];
return {
color: PropTypes.oneOf(color)
};
};
export const colorProps = {
color: PropTypes.oneOf(colors)
};
export const getSizeProps = (sizes, exSizes) => {
let size = [];
if (exSizes) {
size = [...exSizes];
}
size = [...size, ...sizes];
return {
size: PropTypes.oneOf(size)
};
};
export const sizeProps = {
size: PropTypes.oneOf(sizes)
};
export const getShapeProps = (shapes, exShapes) => {
let shape = [];
if (exShapes) {
shape = [...exShapes];
}
shape = [...shape, ...shapes];
return {
shape: PropTypes.oneOf(shape)
};
};
export const shapeProps = {
shape: PropTypes.oneOf(shapes)
};
export const getDecorationProps = (decorations, exDecorations) => {
let decoration = [];
if (exDecorations) {
decoration = [...exDecorations];
}
decoration = [...decoration, ...decorations];
return {
textDecoration: PropTypes.oneOf(decoration)
};
};
export const decorationProps = {
decoration: PropTypes.oneOf(decorations)
};
export const getPositionProps = (positions, expositions) => {
let position = [];
if (expositions) {
position = [...expositions];
}
position = [...position, ...positions];
return {
position: PropTypes.oneOf(position)
};
};
export const positionProps = {
position: PropTypes.oneOf(positions)
};