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 function durationToMinutes (durationString) { | |
| return durationString | |
| .match(/\d+\w/g) | |
| .map(u => ([parseInt(u.match(/\d+/g), 10), u.split(/\d+/g)[1]])) | |
| .map(a => { | |
| switch (a[1]) { | |
| case 'D': return a[0] * 1440; | |
| case 'H': return a[0] * 60; | |
| case 'M': return a[0]; | |
| case 'S': return a[0] / 60; |
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
| 'use latest'; | |
| import express from 'express'; | |
| import compression from 'compression'; | |
| const app = express(); | |
| if (process.env.NODE_ENV === 'production') { | |
| app.use(compression()); | |
| } |
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
| <script> | |
| /** | |
| * Component that automagically finds sibling <template> | |
| * to the instance script and uses it for rendering, with | |
| * out without the getState form the instace of the child. | |
| * | |
| * @class TemplateComponent | |
| * @extends {HTMLElement} | |
| */ | |
| class TemplateComponent extends HTMLElement { |
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
| <link rel="import" href="template-component.html"> | |
| <script> | |
| class SsrData extends TemplateComponent { | |
| constructor () { | |
| super(SsrData.is); | |
| } | |
| static get is () { | |
| return 'ssr-data'; | |
| } |
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
| class TemplateComponent extends HTMLElement { | |
| /*...*/ | |
| async getTemplate (data) { | |
| const templator = (t, d) => new Function('return `' + t + '`').call(d); | |
| async function loadTemplate () { | |
| return new Promise(resolve => { | |
| document.currentScript.ownerDocument.addEventListener('DOMContentLoaded', event => { | |
| resolve(event.target.querySelector('template')); | |
| }, 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
| class TemplateComponent extends HTMLElement { | |
| /*...*/ | |
| get path () { | |
| const query = `link[rel="import"][href*="${this._tagName}"]`; | |
| const target = document.head.querySelector(query); | |
| return target.href.split(document.location.host)[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
| class TemplateComponent extends HTMLElement { | |
| constructor (tagName) { | |
| super(); | |
| if (!tagName) { | |
| throw new Error('You did now specify a tag name. You need to call super with the tag name in you constructor.'); | |
| } | |
| this._tagName = tagName; | |
| } |
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
| class TemplateComponent extends HTMLElement { | |
| constructor (tagName) { | |
| super(); | |
| if (!tagName) { | |
| throw new Error('You did now specify a tag name. You need to call super with the tag name in you constructor.'); | |
| } | |
| this._tagName = tagName; | |
| } |
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
| class TemplateComponent extends HTMLElement { | |
| constructor (tagName) { | |
| super(); | |
| if (!tagName) { | |
| throw new Error('You did now specify a tag name. You need to call super with the tag name in you constructor.'); | |
| } | |
| this._tagName = tagName; | |
| } |
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
| <link rel="import" href="template-component.html"> | |
| <script> | |
| class HelloWorld extends TemplateComponent { | |
| constructor() { | |
| super(HelloWorld.is); | |
| } | |
| static get is() { | |
| return 'hello-world'; | |
| } |