From ffee6ea9fcd30f7cff37c27481d7f60a0f50f2af Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 6 Sep 2016 09:52:59 -0400 Subject: [PATCH] try out csjs and props passed to plugins --- package.json | 2 ++ src/plugins/Dummy.js | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2def04d8e..d3326cb24 100644 --- a/package.json +++ b/package.json @@ -70,9 +70,11 @@ "watchify": "3.7.0" }, "dependencies": { + "csjs": "1.0.6", "deep-freeze-strict": "1.1.1", "drag-drop": "2.11.0", "es6-promise": "3.2.1", + "insert-css": "1.0.0", "mime-types": "2.1.11", "namespace-emitter": "1.0.0", "pretty-bytes": "3.0.1", diff --git a/src/plugins/Dummy.js b/src/plugins/Dummy.js index c113c0997..6b4f79378 100644 --- a/src/plugins/Dummy.js +++ b/src/plugins/Dummy.js @@ -1,16 +1,26 @@ import Plugin from './Plugin' +import csjs from 'csjs' +import insertCss from 'insert-css' import html from '../core/html' +const styles = csjs` + .title { + font-size: 30px; + color: blue; + } +` + /** * Dummy * */ export default class Dummy extends Plugin { - constructor (core, opts) { + constructor (core, opts, props) { super(core, opts) this.type = 'acquirer' this.id = 'Dummy' this.title = 'Mr. Plugin' + this.props = props // set default options const defaultOptions = {} @@ -18,11 +28,26 @@ export default class Dummy extends Plugin { // merge default options with the ones set by user this.opts = Object.assign({}, defaultOptions, opts) - this.strange = html`

this is strange 1

` + this.strange = html`

this is strange 1

` this.render = this.render.bind(this) this.install = this.install.bind(this) } + addFakeFileJustToTest () { + const blob = new Blob( + ['data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNTAiLz4KPC9zdmc+Cg=='], + {type: 'image/svg+xml'} + ) + const file = { + source: 'acceptance-test', + name: 'test-file', + type: 'image/svg+xml', + data: blob + } + this.props.log('Adding fake file blob') + this.props.addFile(file) + } + render () { const bla = html`

this is strange 2

` return html` @@ -42,6 +67,11 @@ export default class Dummy extends Plugin { setTimeout(function () { firstInput.focus() }, 10) + + setTimeout(() => { + this.core.emit('informer', 'Hello! I’m a test Informer message', 'info', 4500) + this.addFakeFileJustToTest() + }, 1000) } install () { @@ -51,6 +81,8 @@ export default class Dummy extends Plugin { // bus.emit('informer', 'hello', 'info', 5000) // }, 1000) + insertCss(csjs.getCss(styles)) + const target = this.opts.target const plugin = this this.target = this.mount(target, plugin)