2.0.2 • Published 5 years ago
@conectate/ct-route v2.0.2
ct-route
It's a simple routing system that changes the viewport depending on the route given
Installation
To include this, type:
$ npm i @conectate/ct-route
Usage
Lazy-import
To lazy-import use the from
attr, like a:
<page-element-one route="/one" from="/src/page-element-one.html"></page-element-one>
Lazy-import finished
maybe you want to know when an import has finished loading...
to know this use finish-load
attr in <c2-route>
If you plan to manage the dynamic imports, skip this attr
<page-element-one route="/one"></page-element-one>
Routing
To route page use the route
attr
route="/page/:id"
you can use :id
to varible path and *
for any path or your own regex
Auth
There are pages that only a user with session started can see.
for this it passes a Boolean parameter to auth of ct-route
and add auth
to element
<ct-route path="{{path}}" auth="[[isLogged]]">
<auth-needed route="/page/:id" from="/src/auth-needed.js" auth></<auth-needed>
</ct-route>
Full example:
<ct-route path="{{path}}" params="{{params}}" query-params="{{queryParams}}" finish-load="{{finishLoad}}" auth="[[isLogged]]">
<page-element-one route="/page" from="/src/page-element-one.js"></page-element-one>
<auth-needed route="/page/:id" from="/src/auth-needed.js" auth></<auth-needed>
<my-view404 route="/404" from="/src/mainc2-view404.js"></my-view404>
</ct-route>
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
History
- v0.1 Initial Release
Credits
littleqairoes/qairoe-app-router created this for his projects in polymer v1.
License
See LICENSE