@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
35 lines • 1.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.align = void 0;
const translateAlignment = (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 align = (y = null, x = null, direction = 'row') => {
const alignmentX = translateAlignment(x);
const alignmentY = translateAlignment(y);
if (direction === 'column' || direction === 'col') {
return `
display: flex;
flex-direction: column;
${alignmentY !== null ? `justify-content: ${alignmentY}` : ''}
${alignmentX !== null ? `align-items: ${alignmentX}` : ''}
`;
}
return `
display: flex;
flex-direction: row;
${alignmentX !== null ? `justify-content: ${alignmentX}` : ''}
${alignmentY !== null ? `align-items: ${alignmentY}` : ''}
`;
};
exports.align = align;
//# sourceMappingURL=align.js.map