0.6.0 • Published 6 years ago
@wces/router v0.6.0
\
This webcomponent follows the open-wc recommendation.
Installation
npm i @wces/routerExample Usage
<script type="module">
import { html, render } from "lit-html";
import './wces-router.js';
import './demo/app-page1.js';
const routes = [
{
id: 'page1',
pattern: '(/)',
component: 'app-page1'
},
{
id: 'page2',
pattern: '/page2/:name',
component: 'app-page2',
url: '/demo/app-page2.js',
context: async ({params: { name }}) => ({ greeting: `Hello ${name}`})
}
];
const route404 = {
id: 'route404',
component: 'app-404',
url: '/demo/app-404.js'
}
window.addEventListener('load', () => {
const rootEl = document.getElementById('demo');
render(
html`<wces-router .routes="${routes}" .route404="${route404}"></wces-router>`,
rootEl
);
})
</script>
<div id="demo"></div>Features
Lazy loading
...
Route path params and query params
...
Optional 404 route
...
Linting with ESLint, Prettier, and Types
To scan the project for linting errors, run
npm run lintYou can lint with ESLint and Prettier individually as well
npm run lint:eslintnpm run lint:prettierTo automatically fix many linting errors, run
npm run formatYou can format using ESLint and Prettier individually as well
npm run format:eslintnpm run format:prettierTesting with Karma
To run the suite of karma tests, run
npm run testTo run the tests in watch mode (for TDD, for example), run
npm run test:watchTooling configs
For most of the tools, the configuration is in the package.json to reduce the amount of files in your project.
If you customize the configuration a lot, you can consider moving them to individual files.
Local Demo with es-dev-server
npm startTo run a local development server that serves the basic demo located in index.html