Reusable components in form of Marionette views to put them into templates in a declarative manner.
Epic: https://makingwings.atlassian.net/browse/KON-6
2017-02-22
application.js.coffee
#= require k2
#= require k2/btn
#= require k2/inp
Rails - Gem
node.js - Package
entry.js
import 'k2/btn';
import 'k2/inp';
application.css.sass
@import k2/btn
@import k2/inp
template.jst.skim
== @btn {label:'Hello'}
Skim template
Handlebars template
template.hbs
{{btn label="Hello"}}
JS
new k2.btn({label: 'Hello'});
HTML
<button class="btn">
<span class="btn__label">Hello</span>
</button>
template.jst.skim
== @inp {label:'Hello', model: @model, name="field"}
template.hbs
{{inp label="Hello" model=model name="field"}}
It will bind model field and input value - when one changes, another changes respectively. Component also might trigger some methods or events as a normal view.
[ show btn.js.coffee code ]
Template helper inserts an ReplaceRegion and renders a Component view into it.
All the k2 logic is just handy conversion from options to element's tagName, className, attributes etc.
Then it could be extended to any behavior as a normal view.
class MeowButton extends k2.btn
events:
'click': 'onClick'
onClick: ->
alert('meow!')
class SaveButton extends k2.btn
events:
'click': 'onClick'
onClick: =>
@setMod({loading: true})
@model.save()
.then => @setMod({loading: false})
Button: pill, toolbar
Input: text, textarea, rte,
checkbox, radio, select
Containers: header, sidebar,
modal
List and table
Layout grid
...
Components:
- Finalize API, release 1.0
- Make documentation & demo
- Unit and visual auto-tests
- Step by step replace and cleanup old konzern
Infrastructure:
We decided to use node.js environment for building commentsble part of Journey Maps.
Repo: https://bitbucket.org/wingsforweb/smaply-comments-mode
What's new: