x-tag-route
v0.3.0
Published
A X-Tag element for URL routing
Downloads
3
Readme
<x-route>
A X-Tag element for URL routing.
Maintained by Gianni Furger.
Port of Polymer <x-route>
by Addy Osmani; based on <flatiron-director>
by the Polymer team.
Support x-route elements on Android 4.3 - Polymer seems rather incompatible with Android versions prior 4.4/KitKat.
Demo
Install
Install with Bower:
$ bower install --save x-tag-route
Usage
Import Web Components' polyfill:
<script src="dist/x-tags-components.js"></script>
Import
<flatiron-director>
:<script src="dist/director.min.js"></script>
Import Custom Element:
<script src="dist/route.js"></script>
Start using it!
<x-route></x-route>
Examples
HTML
<!-- Automatically navigate to a route 'home' -->
<x-route route="/home" auto>
<!-- Define paths to routes we would like to support -->
<x-route path="/favorites">
<x-route path="/about">
<x-route path="/books">
<x-route path="/books/view/:bookId">
<x-route path="/:foo/:bar/:bazz">
JavaScript
You can listen to a route-changed
event for details about the route that was matched.
document.addEventListener('route-changed', function (route) {
console.log(route.detail);
});
Setup
In order to run it locally you'll need a basic server setup.
Install Node.js
Install Grunt:
$ npm install --global grunt-cli
Install Bower
Install local dependencies:
$ npm install && bower install
Run a local server and open
http://localhost:3001
.$ grunt connect
Options
Attribute | Options | Default | Description
--- | --- | --- | ---
path
| string | | A routing path
`route` | *string* |
| The current route
auto
| boolean | false
| Automatically navigate to a defined route
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
History
For detailed changelog, check Releases.