piral-core
Advanced tools
Comparing version 0.9.0-pre.746 to 0.9.0-pre.751
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = require("react"); | ||
const react_router_dom_1 = require("react-router-dom"); | ||
const PiralRoutes_1 = require("./PiralRoutes"); | ||
const components_1 = require("./components"); | ||
const hooks_1 = require("../hooks"); | ||
const components_1 = require("./components"); | ||
const NotFound = props => React.createElement(components_1.PiralError, Object.assign({ type: "not_found" }, props)); | ||
@@ -13,2 +14,3 @@ const PiralContent = () => { | ||
}; | ||
const Router = typeof window === 'undefined' ? props => React.createElement(react_router_dom_1.StaticRouter, Object.assign({ location: "/" }, props)) : components_1.PiralRouter; | ||
const PiralProvider = ({ children }) => { | ||
@@ -19,3 +21,3 @@ const provider = hooks_1.useGlobalState(m => m.provider) || React.createElement(React.Fragment, null); | ||
exports.PiralView = ({ children }) => (React.createElement(PiralProvider, null, | ||
React.createElement(components_1.PiralRouter, null, | ||
React.createElement(Router, null, | ||
React.createElement(PiralContent, null), | ||
@@ -22,0 +24,0 @@ children))); |
@@ -5,4 +5,5 @@ "use strict"; | ||
exports.defaultBreakpoints = ['(min-width: 991px)', '(min-width: 481px)', '(max-width: 480px)']; | ||
const mm = typeof window === 'undefined' ? () => ({ matches: [] }) : (q) => window.matchMedia(q); | ||
function getCurrentLayout(breakpoints, layouts, defaultLayout) { | ||
const query = breakpoints.findIndex(q => matchMedia(q).matches); | ||
const query = breakpoints.findIndex(q => mm(q).matches); | ||
const layout = layouts[query]; | ||
@@ -9,0 +10,0 @@ return layout !== undefined ? layout : defaultLayout; |
{ | ||
"name": "piral-core", | ||
"version": "0.9.0-pre.746", | ||
"version": "0.9.0-pre.751", | ||
"description": "The core library for creating a Piral instance.", | ||
@@ -55,3 +55,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "d79bf9b30d1f80473bbd6cb8225cbb1156ecb7d7" | ||
"gitHead": "461d07d5b5d1f7a3d9512b933f065ea100762889" | ||
} |
@@ -7,6 +7,8 @@ import { LayoutTypes, LayoutBreakpoints } from '../types'; | ||
const mm = typeof window === 'undefined' ? () => ({ matches: [] }) : (q: string) => window.matchMedia(q); | ||
export function getCurrentLayout<T>(breakpoints: Array<string>, layouts: Array<T>, defaultLayout: T) { | ||
const query = breakpoints.findIndex(q => matchMedia(q).matches); | ||
const query = breakpoints.findIndex(q => mm(q).matches); | ||
const layout = layouts[query]; | ||
return layout !== undefined ? layout : defaultLayout; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
287606
6592