kopia lustrzana https://github.com/nolanlawson/pinafore
17 wiersze
633 B
JavaScript
17 wiersze
633 B
JavaScript
import { switchToTheme } from '../../_utils/themeEngine.js'
|
|
|
|
const style = process.browser && document.getElementById('theGrayscaleStyle')
|
|
|
|
export function grayscaleObservers (store) {
|
|
if (!process.browser) {
|
|
return
|
|
}
|
|
|
|
store.observe('enableGrayscale', enableGrayscale => {
|
|
const { instanceThemes, currentInstance } = store.get()
|
|
const theme = instanceThemes && instanceThemes[currentInstance]
|
|
style.setAttribute('media', enableGrayscale ? 'all' : 'only x') // disable or enable the style
|
|
switchToTheme(theme, enableGrayscale)
|
|
}, { init: false }) // init:false because the inline script takes care of it
|
|
}
|