piral-core
Version:
The core library for creating a Piral instance.
12 lines • 629 B
JavaScript
import { isfunc } from 'piral-base';
export const defaultLayouts = ['desktop', 'tablet', 'mobile'];
export const defaultBreakpoints = ['(min-width: 991px)', '(min-width: 481px)', '(max-width: 480px)'];
const mm = typeof window === 'undefined' || !isfunc(window.matchMedia)
? () => ({ matches: undefined })
: (q) => window.matchMedia(q);
export function getCurrentLayout(breakpoints = defaultBreakpoints, layouts, defaultLayout) {
const query = breakpoints.findIndex((q) => mm(q).matches);
const layout = layouts[query];
return layout !== undefined ? layout : defaultLayout;
}
//# sourceMappingURL=media.js.map