UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

17 lines (13 loc) 684 B
import { ALIGNS, POSITIONS, RTL_POSITIONS } from "../consts"; import switchPreferredPosition from "./switchPreferredPosition"; const sortPositionsAndAligns = (preferredPosition, theme) => { const positionsObject = theme.rtl ? RTL_POSITIONS : POSITIONS; const positions = Object.keys(positionsObject).map(k => positionsObject[k]); const aligns = Object.keys(ALIGNS).map(k => ALIGNS[k]); if (preferredPosition) { const realPreferredPosition = switchPreferredPosition(theme, preferredPosition); return [[realPreferredPosition, ...positions.filter(p => p !== realPreferredPosition)], aligns]; } return [positions, aligns]; }; export default sortPositionsAndAligns;