@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
34 lines • 1.17 kB
JavaScript
import { css } from '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;
};
export const contentAlignment = (alignmentX, alignmentY, direction = 'row') => {
const realAlignmentX = replaceAlignment(alignmentX);
const realAlignmentY = replaceAlignment(alignmentY);
if (direction === 'column' || direction === 'col') {
return css `
display: flex;
flex-direction: column;
${realAlignmentY !== null
? `justify-content: ${realAlignmentY};`
: ''}
${realAlignmentX !== null ? `align-items: ${realAlignmentX};` : ''}
`;
}
return css `
display: flex;
flex-direction: row;
${realAlignmentX !== null ? `justify-content: ${realAlignmentX};` : ''}
${realAlignmentY !== null ? `align-items: ${realAlignmentY};` : ''}
`;
};
//# sourceMappingURL=contentAlignment.js.map