made with esnextbin
made with esnextbin
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
| var Ora = require('ora'), | |
| spinners = require('cli-spinners'); | |
| var spinner = new Ora({ | |
| text: '' | |
| }); | |
| var index = 0; | |
| var types = Object.keys(spinners); |
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
| // - yes, this is the entire implementation | |
| // - no, it doesn't actually depend on preact | |
| export class Provider { | |
| getChildContext () { | |
| let { children, ...context } = this.props; | |
| return context; | |
| } | |
| render ({ children }) { | |
| return children && children[0] || null | |
| } |
Simple, unobtrusive add-on to support String refs in Preact, without needing to pull in preact-compat.
Calling linkRef(componentInstance, refName) returns a "ref proxy" function, which sets this.refs[refName] when called.
import { h, Component } from 'preact';
import linkRef from './linked-ref';
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 { h } from 'preact'; | |
| export default function cloneElement(vnode, props, ...children) { | |
| return h( | |
| vnode.nodeName, | |
| extend(extend({}, vnode.attributes || {}), props), | |
| children.length ? children : vnode.children | |
| ); | |
| } |
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 fireEvent(element, type) { | |
| let e = document.createEvent('Event'); | |
| e.initEvent(type); | |
| element.dispatchEvent(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
| import { Component } from 'preact'; | |
| import { bind } from 'decko'; | |
| class MarkdownEditor extends Component { | |
| constructor() { | |
| super() | |
| this.state = { text: '' }; | |
| } | |
| @bind | |
| onEdit(text) { |
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
| var document = global.document = createDocument(); | |
| export default document; | |
| function createDocument() { | |
| const NODE_TYPES = { | |
| ELEMENT_NODE: 1, | |
| ATTRIBUTE_NODE: 2, | |
| TEXT_NODE: 3, | |
| CDATA_SECTION_NODE: 4, | |
| ENTITY_REFERENCE_NODE: 5, |
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 emitter from 'emitter'; | |
| export let { on, off, emit } = emitter(); |