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
<template> | |
<div ref="editor" class="notranslate"> | |
<div v-show="showSuggestions" ref="suggestions"> | |
<template v-if="(filteredSuggestions || []).length"> | |
<div | |
v-for="(item, index) in filteredSuggestions.slice(0, 10)" | |
:key="index" | |
:class="[$style.suggestion, navigatedSuggestionIndex === index && $style.selected]" | |
@click="selectSuggestion(item)" | |
> |
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 const EventBus = { | |
$on (eventType, callback) { | |
document.addEventListener(eventType, (ev) => callback(ev.detail)) | |
}, | |
$dispatch (eventType, data) { | |
const event = new CustomEvent(eventType, { detail: data }) | |
document.dispatchEvent(event) | |
}, | |
$off (eventType, callback) { | |
document.removeEventListener(eventType, callback) |
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 singularize(word) { | |
const endings = { | |
ves: 'fe', | |
ies: 'y', | |
i: 'us', | |
zes: 'ze', | |
ses: 's', | |
xes: 'x', | |
es: 'e', | |
s: '' |
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
The Fountain | |
Eternal Sunshine of the Spotless Mind | |
Into the Wild | |
Ex Machina | |
Okja | |
Isle of Dogs | |
JoJo Rabbit | |
The Nice Guys | |
Mad Max: Fury Road | |
I am Sam |
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
/** | |
* Usage: | |
* | |
* document.getElementById('app').serializeWithStyles() | |
* | |
* Credits go to https://stackoverflow.com/a/6310120/2803743 | |
*/ | |
Element.prototype.serializeWithStyles = (function () { | |
// Mapping between tag names and css default values lookup tables. This allows to exclude default values in the result. |
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 resizeImage(el, width, height, quality) { | |
var canvas = document.createElement('canvas') | |
canvas.width = width | |
canvas.height = height | |
var context = canvas.getContext('2d') | |
context.drawImage(el, 0, 0, width, height) | |
try { | |
return canvas.toDataURL('image/jpeg', quality) | |
} catch (e) { |
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
<template> | |
<transition-fade :duration="200"> | |
<div | |
v-if="show" | |
:class="$style.backdrop" | |
@click="$emit('close')" | |
@keydown.stop | |
@keyup.esc="handleEscape" | |
> | |
<dialog v-show="show" ref="dialog" :open="show" :class="$style.modal" tabindex="-1"> |
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
const roundingStops = [5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000] | |
export const roundToScale = (count, scale = roundingStops) => { | |
if (count === 0) return 0 | |
const nearestIdx = scale.findIndex((s) => s > count) | |
let nearest = scale[nearestIdx] | |
if (nearestIdx !== 0 && nearest / 2 > count) nearest = scale[nearestIdx - 1] || scale[0] | |
return nearest || count |
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
const prettier = require("prettier"); | |
const pluginName = "HandleChunkLoadFailurePlugin"; | |
/** | |
* This Webpack plugin calls `window._chunkHandler.handleVersionChange()` when loading a chunk fails | |
*/ | |
class HandleChunkLoadFailurePlugin { | |
constructor(options = {}) { | |
this.options = Object.assign({}, options); |
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 const strip = (html: string) => { | |
const doc = new DOMParser().parseFromString(html, 'text/html') | |
return (doc.body.textContent || '').trim() | |
} |
NewerOlder