Bootstrap-like Components for Riot.js
npm install riot-bootstrapBootstrap-like Components for Riot.js
- Readable: no more cluttered class names!
- Stand-alone: independent from Bootstrap
- Modular: one file, one component
- Packaged: HTML/CSS/JavaScript are packaged into one file
- Use onclick event handler on , instead of onpush
- onselect event handler on now passes an event object instead of a selected string.
- cognitom.github.io/riot-bootstrap
In short, use the tags as just like HTML: , , ...etc.
``html`
- load riot.js
- load normalize.css
- load riot-bootstrap (this library)
- then, riot.mount('*')
`html`
- load riot.js
- load normalize.css
- load riot-bootstrap (this library)
- load your tag file
- then, riot.mount('app')
`html`
`html`
// app.html
- Install riot-bootstrap via NPM.
- Create the main script.
- Prepare your tag files.
- Rollup.
- Load the compiled script into HTML.
`bash`
$ npm install --save riot-bootstrap
`javascript`
// app.js
import riot from 'riot'
import 'riot-bootstrap'
import './app.tag' // and other components
riot.mount('app')
`html`
// app.tag
`html`
See the demo page.
Riot.js has a scope for most inner Tag element. So we need to write like this:
`html`
this.message = 'Click me!'
push (e) {
this.message = 'Thanks!'
this.update() // needed to re-render
}
But this is a little bit inconvenient, so riot-bootstrap has a simple 'Scope emulation' mechanism. Now we can write like this.
`html`
this.message = 'Click me!'
push (e) {
this.message = 'Thanks!'
// automatically re-rendered
}
There is some limitation:
- The variables in the parent's scope are updated just before update event.Tag
- The view is automatically re-rendered only if the method is a member of element. In NG case below, this.update() is needed to call manually.
- OK:
- NG:
- NG:
- v0.0.1: Buttons, button groups, dropdowns
- v0.1.0: Now transclusion is supported, thanks to Riot 2.0.15
- v0.1.1: Radio groups
- v0.1.2: Support Browserify and publish to NPM
- v0.1.7: Fix: CommonJS issue
- v0.2.0: Scope emulation. Related to https://github.com/muut/riotjs/issues/662
- v0.2.1: Fix: automatic update
- v0.2.2: Fix: opts also supported in scope emulationdisabled
- v0.2.3: Fix: now works with booleandisabled
- v0.2.4: Fix: update status after second updateparentScope
- v0.3.0: as a mixinhref
- v0.3.1: Use mixin initializer
- v0.3.2: Add attribute to btn tagdomEvent
- v0.3.3: Fix the bug #10
- v1.0.0: Completely rewrites into ES6!, supports , makes parentScope external. Add: and .align="right"
- v1.1.0: option for
Rebuilding Bootstrap components for Riot.js
- Input groups
- Breadcrumbs
- Badges
- Panels
- Progress bars
- Anything else? Send us a new issue or PR!