@up-group/react-controls
Version:
We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get
100 lines • 2.85 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var types_1 = require("./types");
var rootRem = 16;
var remFromPX = function (px) { return (px / rootRem); };
function calculateFlexWrap(wrap, reverse) {
if (wrap && reverse) {
return 'wrap-reverse';
}
else if (wrap && !reverse) {
return 'wrap';
}
else {
return 'nowrap';
}
}
exports.calculateFlexWrap = calculateFlexWrap;
function sizeToString(size, smallSize) {
if (smallSize === void 0) { smallSize = false; }
var returnVal;
if (typeof size === 'string') {
returnVal = remFromPX(types_1.SIZE_MAP[size]) + "rem";
}
else if (typeof size === 'object') {
var horizontal = size.horizontal || 'none';
var vertical = size.vertical || 'none';
returnVal = remFromPX(types_1.SIZE_MAP[vertical]) + "rem " + remFromPX(types_1.SIZE_MAP[horizontal]) + "rem";
}
else {
returnVal = "0rem";
}
return returnVal;
}
exports.sizeToString = sizeToString;
function stringBoxStyle(size) {
if (size === 'full') {
return {
width: '100vw',
height: '100vh',
};
}
else if (size === 'auto') {
return {
width: 'auto',
height: 'auto',
};
}
else {
return {
width: size ? remFromPX(types_1.BOX_SIZE_MAP[size]) + "rem" : '',
height: size ? remFromPX(types_1.BOX_SIZE_MAP[size]) + "rem" : '',
};
}
}
function objectBoxStyle(size) {
var width = 'auto';
var height = 'auto';
if (size.vertical) {
height = size.vertical === 'full'
? '100vh'
: remFromPX(types_1.BOX_SIZE_MAP[size.vertical]) + "rem";
}
if (size.horizontal) {
width = size.horizontal === 'full'
? '100%'
: remFromPX(types_1.BOX_SIZE_MAP[size.horizontal]) + "rem";
}
return {
width: width,
height: height,
};
}
function boxSizeToStyle(size) {
if (typeof size === 'string') {
return stringBoxStyle(size);
}
else if (typeof size === 'object') {
return objectBoxStyle(size);
}
else {
return { width: 'auto', height: 'auto' };
}
}
exports.boxSizeToStyle = boxSizeToStyle;
function calculateFullStyle(full, postFix) {
if (typeof full === 'object') {
if (postFix === 'vw') {
return full.horizontal ? "100%" : 'auto';
}
else {
return full.vertical ? "100%" : 'auto';
}
}
else if (typeof full === 'boolean') {
return full ? "100%" : 'auto';
}
return 'auto';
}
exports.calculateFullStyle = calculateFullStyle;
//# sourceMappingURL=styleUtils.js.map
;