Just a basic preact-cli demo with CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (typeof window!=='undefined' && navigator.serviceWorker && navigator.serviceWorker.controller) { | |
| let reloadOnNext = false; | |
| let pushState = history.pushState; | |
| history.pushState = function(state, title, url) { | |
| pushState.call(this, state, title, url); | |
| if (reloadOnNext===true) location.reload(true); | |
| }; | |
| navigator.serviceWorker.controller.addEventListener('statechange', e => { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default (config, env, helpers) => { | |
| let extract = helpers.getPluginsByName(config, 'ExtractTextPlugin')[0]; | |
| if (extract) extract.plugin.options.allChunks = false; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let get = worker(async url => { | |
| let res = await fetch(url) | |
| //throw Error('carp') | |
| return await res.json() | |
| }) | |
| setTimeout(async () => { | |
| let obj = await get('https://api.github.com/users/developit') | |
| output.textContent = JSON.stringify(obj, 0, 2); | |
| }) |
So, you need to transpile classes to ES5 for some reason, but you need to do it in the browser.
Could we use a gross regular expression to get that done? Yes.
Should we? No, but it's far too late for that now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from 'preact'; | |
| import Snackbar from 'preact-material-components/Snackbar'; | |
| const TIMEOUT = 3; | |
| export default class Toaster extends Component { | |
| seen = []; | |
| queue = []; | |
| snackbarRef = c => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getClipboardText(e) { | |
| return Promise.resolve().then(function(){ | |
| return navigator.permissions.query({ name: 'clipboard-read' }) | |
| }).then(function(r) { | |
| return r.state=='granted' && navigator.clipboard.readText() | |
| }).catch(Object).then(function(t) { | |
| return typeof t=='string' ? t : e.clipboardData.getData('text/plain') | |
| }) | |
| } |