@gannochenko/ui.styled-components
Version:
<!-- PROJECT SHIELDS --> <!-- *** Reference links are enclosed in brackets [ ] instead of parentheses ( ). *** See the bottom of this document for the declaration of the reference variables *** for contributors-url, forks-url, etc. This is an optional, co
38 lines • 1.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.contentAlignment = void 0;
const styled_components_1 = require("styled-components");
const replaceAlignment = (how) => {
if (how === 'start' || how === 'left' || how === 'top') {
return 'flex-start';
}
if (how === 'end' || how === 'right' || how === 'bottom') {
return 'flex-end';
}
if (how === 'middle') {
return 'center';
}
return how;
};
const contentAlignment = (alignmentX, alignmentY, direction = 'row') => {
const realAlignmentX = replaceAlignment(alignmentX);
const realAlignmentY = replaceAlignment(alignmentY);
if (direction === 'column' || direction === 'col') {
return (0, styled_components_1.css) `
display: flex;
flex-direction: column;
${realAlignmentY !== null
? `justify-content: ${realAlignmentY};`
: ''}
${realAlignmentX !== null ? `align-items: ${realAlignmentX};` : ''}
`;
}
return (0, styled_components_1.css) `
display: flex;
flex-direction: row;
${realAlignmentX !== null ? `justify-content: ${realAlignmentX};` : ''}
${realAlignmentY !== null ? `align-items: ${realAlignmentY};` : ''}
`;
};
exports.contentAlignment = contentAlignment;
//# sourceMappingURL=contentAlignment.js.map