try out csjs and props passed to plugins

This commit is contained in:
Artur Paikin 2016-09-06 09:52:59 -04:00
parent ac2f4190ed
commit ffee6ea9fc
2 changed files with 36 additions and 2 deletions

View file

@ -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",

View file

@ -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`<h1>this is strange 1</h1>`
this.strange = html`<h1 class="${styles.title}">this is strange 1</h1>`
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`<h2>this is strange 2</h2>`
return html`
@ -42,6 +67,11 @@ export default class Dummy extends Plugin {
setTimeout(function () {
firstInput.focus()
}, 10)
setTimeout(() => {
this.core.emit('informer', 'Hello! Im 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)