UNPKG

@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

31 lines 1.01 kB
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; }; export 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}` : ''} `; }; //# sourceMappingURL=align.js.map