fix: simplify window.matchMedia (#1359)

There is really no reason to call window.matchMedia instead of just matchMedia.
This commit is contained in:
Nolan Lawson 2019-07-23 20:33:40 -07:00 committed by GitHub
parent 6c58052684
commit 467eb85209
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 8 deletions

View file

@ -149,7 +149,8 @@
"DOMParser",
"CSS",
"customElements",
"AbortController"
"AbortController",
"matchMedia"
],
"ignore": [
"dist",

View file

@ -7,9 +7,9 @@ export function resizeObservers (store) {
const recalculateIsMobileSize = () => {
store.set({
isMobileSize: window.matchMedia('(max-width: 767px)').matches, // e.g. iPhone Plus
isSmallMobileSize: window.matchMedia('(max-width: 479px)').matches, // e.g. Galaxy S5
isTinyMobileSize: window.matchMedia('(max-width: 320px)').matches // e.g. iPhone 4
isMobileSize: matchMedia('(max-width: 767px)').matches, // e.g. iPhone Plus
isSmallMobileSize: matchMedia('(max-width: 479px)').matches, // e.g. Galaxy S5
isTinyMobileSize: matchMedia('(max-width: 320px)').matches // e.g. iPhone 4
})
}

View file

@ -35,7 +35,7 @@ const persistedState = {
pushSubscriptions: {},
reduceMotion:
!process.browser ||
window.matchMedia('(prefers-reduced-motion: reduce)').matches,
matchMedia('(prefers-reduced-motion: reduce)').matches,
underlineLinks: false
}

View file

@ -1,8 +1,8 @@
// should be kept in sync with global.scss
export function getMainTopMargin () {
if (window.matchMedia('(max-width: 767px)').matches) {
if (matchMedia('(max-width: 767px)').matches) {
return 62
} else if (window.matchMedia('(max-width: 991px').matches) {
} else if (matchMedia('(max-width: 991px').matches) {
return 52
} else {
return 42

View file

@ -1,4 +1,4 @@
const prefersDarkTheme = process.browser && window.matchMedia('(prefers-color-scheme: dark)').matches
const prefersDarkTheme = process.browser && matchMedia('(prefers-color-scheme: dark)').matches
const meta = process.browser && document.getElementById('theThemeColor')
export const INLINE_THEME = 'default' // theme that does not require external CSS