Completely updated React, fixed #11, (hopefully)
This commit is contained in:
44
goTorrentWebUI/node_modules/material-ui/styles/createBreakpoints.js.flow
generated
vendored
44
goTorrentWebUI/node_modules/material-ui/styles/createBreakpoints.js.flow
generated
vendored
@@ -1,16 +1,14 @@
|
||||
// @flow
|
||||
|
||||
export type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
||||
|
||||
// Sorted ASC by size. That's important.
|
||||
// It can't be configured as it's used statically for propTypes.
|
||||
export const keys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
||||
|
||||
// Keep in mind that @media is inclusive by the CSS specification.
|
||||
export default function createBreakpoints(breakpoints: Object) {
|
||||
export default function createBreakpoints(breakpoints) {
|
||||
const {
|
||||
// The breakpoint **start** at this value.
|
||||
// For instance with the first breakpoint xs: [xs, sm[.
|
||||
values = {
|
||||
xs: 360,
|
||||
xs: 0,
|
||||
sm: 600,
|
||||
md: 960,
|
||||
lg: 1280,
|
||||
@@ -22,35 +20,37 @@ export default function createBreakpoints(breakpoints: Object) {
|
||||
} = breakpoints;
|
||||
|
||||
function up(key) {
|
||||
let value;
|
||||
// min-width of xs starts at 0
|
||||
if (key === 'xs') {
|
||||
value = 0;
|
||||
} else {
|
||||
value = values[key] || key;
|
||||
}
|
||||
const value = typeof values[key] === 'number' ? values[key] : key;
|
||||
return `@media (min-width:${value}${unit})`;
|
||||
}
|
||||
|
||||
function down(key) {
|
||||
const value = values[key] || key;
|
||||
const endIndex = keys.indexOf(key) + 1;
|
||||
const upperbound = values[keys[endIndex]];
|
||||
|
||||
if (endIndex === keys.length) {
|
||||
// xl down applies to all sizes
|
||||
return up('xs');
|
||||
}
|
||||
|
||||
const value = typeof upperbound === 'number' && endIndex > 0 ? upperbound : key;
|
||||
return `@media (max-width:${value - step / 100}${unit})`;
|
||||
}
|
||||
|
||||
function between(start, end) {
|
||||
const startIndex = keys.indexOf(start);
|
||||
const endIndex = keys.indexOf(end);
|
||||
const endIndex = keys.indexOf(end) + 1;
|
||||
|
||||
if (endIndex === keys.length) {
|
||||
return up(start);
|
||||
}
|
||||
|
||||
return (
|
||||
`@media (min-width:${values[keys[startIndex]]}${unit}) and ` +
|
||||
`(max-width:${values[keys[endIndex + 1]] - step / 100}${unit})`
|
||||
`@media (min-width:${values[start]}${unit}) and ` +
|
||||
`(max-width:${values[keys[endIndex]] - step / 100}${unit})`
|
||||
);
|
||||
}
|
||||
|
||||
function only(key) {
|
||||
const keyIndex = keys.indexOf(key);
|
||||
if (keyIndex === keys.length - 1) {
|
||||
return up(key);
|
||||
}
|
||||
return between(key, key);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user