2016-12-23 13:01:24 +00:00
|
|
|
const isServer = typeof window === 'undefined'
|
|
|
|
|
|
|
|
let styletron
|
|
|
|
|
|
|
|
export default function getStyletron () {
|
2018-12-10 14:04:58 +00:00
|
|
|
if (isServer && !styletron) {
|
|
|
|
const Styletron = require('styletron-engine-atomic').Server
|
2016-12-23 13:01:24 +00:00
|
|
|
styletron = new Styletron()
|
|
|
|
} else if (!styletron) {
|
2018-12-10 14:04:58 +00:00
|
|
|
const Styletron = require('styletron-engine-atomic').Client
|
2016-12-23 13:01:24 +00:00
|
|
|
const styleElements = document.getElementsByClassName('_styletron_hydrate_')
|
|
|
|
styletron = new Styletron(styleElements)
|
|
|
|
}
|
|
|
|
return styletron
|
|
|
|
}
|
|
|
|
|
|
|
|
export function flush () {
|
|
|
|
const _styletron = styletron
|
|
|
|
styletron = null
|
|
|
|
return _styletron
|
|
|
|
}
|