├── .gitignore
├── LICENSE
├── README.md
├── assets
├── favicon-16x16.png
├── favicon-32x32.png
├── logo-white.png
├── logo.png
├── logo.svg
├── simplr-router-logo-banner.png
├── simplr-router-logo-black.png
├── simplr-router-logo-transparent.png
├── simplr-router-logo-white.png
└── simplr-router-logo.jpeg
├── build-docs.sh
├── docs
├── 0332ee92.png
├── 078800d4.png
├── 0abae851.png
├── 0b52c7d6.png
├── 0d2fe2f7.svg
├── 0d7ffa66.png
├── 0f73e263.js
├── 0fe6ea42.svg
├── 1749e3ec.png
├── 176cd193.png
├── 1d559c8f.png
├── 1e574a75.svg
├── 248138a9.png
├── 269a33fb.png
├── 28cea4e0.png
├── 337751cf.png
├── 36057de5.png
├── 384ca148.png
├── 3ac4863b.png
├── 3dfb6b8e.js
├── 404.html
├── 46d66be1.png
├── 5280dd3f.js
├── 5663b789.png
├── 636405e5.svg
├── 6a645292.png
├── 74a5dba1.css
├── 78a4a5a2.js
├── 7e744e1c.png
├── 866a7333.png
├── 9379d4b8.png
├── 962426a7.js
├── _merged_assets
│ └── _static
│ │ ├── 404
│ │ ├── bg_purple.png
│ │ └── overlay_stars.svg
│ │ ├── icons
│ │ ├── android-chrome-192x192.png
│ │ ├── android-chrome-512x512.png
│ │ ├── apple-touch-icon.png
│ │ ├── favicon-16x16.png
│ │ ├── favicon-32x32.png
│ │ ├── icon-128x128.png
│ │ ├── icon-512x512.png
│ │ ├── maskable-icon-128x128.png
│ │ ├── maskable-icon.png
│ │ ├── mstile-150x150.png
│ │ └── safari-pinned-tab.svg
│ │ ├── noscript.css
│ │ ├── rocket-search-index.json
│ │ └── search
│ │ └── noscript.css
├── a108fe31.png
├── a63b1bdf.png
├── a7589c58.png
├── ac2ea3b8.css
├── ae5c019b.png
├── assets
│ ├── apple-touch-icon.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── safari-pinned-tab.svg
│ └── webmanifest.json
├── b8c01bc2.css
├── c05ac5c9.png
├── d15d5a5d.js
├── d5808608.png
├── d86a67d8.png
├── dba25cba.css
├── docs
│ ├── api
│ │ ├── events
│ │ │ └── index.html
│ │ ├── helper-functions
│ │ │ └── index.html
│ │ ├── index.html
│ │ ├── route
│ │ │ └── index.html
│ │ ├── router-options
│ │ │ └── index.html
│ │ └── router
│ │ │ └── index.html
│ └── index.html
├── ef817fcb.png
├── f563d575.png
├── f6311b2e.png
├── guides
│ ├── customizing
│ │ ├── index.html
│ │ ├── middleware
│ │ │ └── index.html
│ │ ├── rootpaths
│ │ │ └── index.html
│ │ └── styling-transitions
│ │ │ └── index.html
│ ├── getting-started
│ │ ├── index.html
│ │ ├── using-a-starter
│ │ │ └── index.html
│ │ ├── using-an-outlet
│ │ │ └── index.html
│ │ └── your-first-setup
│ │ │ └── index.html
│ ├── index.html
│ └── recipes
│ │ ├── child-routes
│ │ └── index.html
│ │ ├── dynamic-routes
│ │ └── index.html
│ │ ├── error-pages
│ │ └── index.html
│ │ ├── guards
│ │ └── index.html
│ │ ├── index.html
│ │ ├── lazy-loading
│ │ └── index.html
│ │ ├── named-routes
│ │ └── index.html
│ │ ├── nested-routes
│ │ └── index.html
│ │ ├── passing-properties
│ │ └── index.html
│ │ ├── preventing-navigation
│ │ └── index.html
│ │ ├── programmatic-navigation
│ │ └── index.html
│ │ ├── redirects
│ │ └── index.html
│ │ └── slots
│ │ └── index.html
├── index.html
├── service-worker.js
├── sitemap.njk
└── sitemap.xml
├── examples
├── application-demo
│ ├── .editorconfig
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── rollup.config.js
│ ├── src
│ │ ├── components
│ │ │ ├── ItemList.ts
│ │ │ ├── ItemListEntry.ts
│ │ │ ├── SideNav.ts
│ │ │ └── SideNavItem.ts
│ │ ├── index.ts
│ │ ├── router.ts
│ │ ├── service
│ │ │ └── GitHub.ts
│ │ └── views
│ │ │ ├── AboutPage.ts
│ │ │ ├── DataPage.ts
│ │ │ ├── LandingPage.ts
│ │ │ └── data-views
│ │ │ ├── DataPageCommitPanel.ts
│ │ │ ├── DataPageCommits.ts
│ │ │ ├── DataPageInfo.ts
│ │ │ ├── DataPageIssuePanel.ts
│ │ │ ├── DataPageIssues.ts
│ │ │ ├── DataPagePullRequestPanel.ts
│ │ │ └── DataPagePullRequests.ts
│ ├── tsconfig.json
│ └── web-dev-server.config.mjs
├── middleware-example.js
├── minimal-setup
│ ├── .editorconfig
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── assets
│ │ └── open-wc-logo.svg
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── dynamic-view.js
│ │ ├── example-view.js
│ │ ├── minimal-setup.js
│ │ ├── routing.js
│ │ └── view-styles.js
│ └── web-dev-server.config.mjs
├── router-demo
│ ├── .editorconfig
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── assets
│ │ └── open-wc-logo.svg
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── RouterDemo.js
│ │ ├── forbidden-view.js
│ │ ├── not-found-view.js
│ │ ├── param-example.js
│ │ ├── pattern-example.js
│ │ ├── pattern-with-name-example.js
│ │ ├── prevent-example.js
│ │ ├── regular-top-bar.js
│ │ ├── router-demo.js
│ │ ├── router-example.js
│ │ ├── special-top-bar.js
│ │ ├── user-add-view.js
│ │ ├── user-edit-view.js
│ │ ├── user-profile-view.js
│ │ ├── users-list-view.js
│ │ └── users-view.js
│ └── web-dev-server.config.mjs
├── router-outlet-demo
│ ├── .editorconfig
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── assets
│ │ └── open-wc-logo.svg
│ ├── index.html
│ ├── package-lock.json
│ ├── package.json
│ ├── src
│ │ ├── RouterDemo.js
│ │ ├── param-example.js
│ │ ├── router-demo.js
│ │ ├── router-example.js
│ │ └── router-frontpage.js
│ └── web-dev-server.config.mjs
└── type-testing
│ ├── index.js
│ ├── index.ts
│ ├── package-lock.json
│ ├── package.json
│ └── tsconfig.json
├── index.html
├── lib
├── .gitignore
├── .npmignore
├── .prettierrc.json
├── README.md
├── jsconfig.json
├── modules
│ ├── builder.js
│ ├── config.js
│ ├── deepquery.js
│ ├── dispatcher.js
│ ├── helper.js
│ ├── middleware-handler.js
│ ├── observer.js
│ ├── parser.js
│ ├── router.js
│ ├── simplr-router-container.js
│ └── simplr-router-outlet.js
├── package-lock.json
├── package.json
├── simplr-router.js
└── types
│ ├── Shared.js
│ ├── SimplrRoute.js
│ └── SimplrRouterOptions.js
├── package-lock.json
├── package.json
└── rocket-docs
├── .gitignore
├── _site-dev
├── .eleventyignore
├── _merged_assets
│ ├── 404
│ │ ├── 404.svg
│ │ ├── astronaut.svg
│ │ ├── earth.svg
│ │ ├── moon.svg
│ │ └── rocket.svg
│ ├── _inline-scripts
│ │ └── serviceWorkerUpdate.js
│ ├── _static
│ │ ├── 404
│ │ │ ├── bg_purple.png
│ │ │ └── overlay_stars.svg
│ │ ├── icons
│ │ │ ├── android-chrome-192x192.png
│ │ │ ├── android-chrome-512x512.png
│ │ │ ├── apple-touch-icon.png
│ │ │ ├── favicon-16x16.png
│ │ │ ├── favicon-32x32.png
│ │ │ ├── icon-128x128.png
│ │ │ ├── icon-512x512.png
│ │ │ ├── maskable-icon-128x128.png
│ │ │ ├── maskable-icon.png
│ │ │ ├── mstile-150x150.png
│ │ │ └── safari-pinned-tab.svg
│ │ ├── noscript.css
│ │ ├── rocket-search-index.json
│ │ └── search
│ │ │ └── noscript.css
│ ├── brand-logos
│ │ ├── discord.svg
│ │ ├── github.svg
│ │ ├── gitlab.svg
│ │ ├── slack.svg
│ │ ├── telegram.svg
│ │ └── twitter.svg
│ ├── burger-menu.svg
│ ├── home-background.svg
│ ├── layout.css
│ ├── logo.svg
│ ├── markdown.css
│ ├── octicon.svg
│ ├── scripts
│ │ ├── define-rocket-search.js
│ │ ├── init-navigation.js
│ │ └── registerServiceWorker.js
│ ├── service-worker.js
│ ├── simplr-router-logo-black.png
│ ├── simplr-router-logo-transparent.png
│ ├── social-media-image.jpg
│ ├── style.css
│ ├── variables.css
│ └── webmanifest.json
├── docs
│ ├── api
│ │ ├── index.html
│ │ ├── route
│ │ │ └── index.html
│ │ ├── router-options
│ │ │ └── index.html
│ │ └── router
│ │ │ └── index.html
│ └── index.html
├── guides
│ ├── customizing
│ │ ├── index.html
│ │ ├── middleware
│ │ │ └── index.html
│ │ ├── rootpaths
│ │ │ └── index.html
│ │ └── styling-transitions
│ │ │ └── index.html
│ ├── getting-started
│ │ ├── index.html
│ │ ├── using-a-starter
│ │ │ └── index.html
│ │ ├── using-an-outlet
│ │ │ └── index.html
│ │ └── your-first-setup
│ │ │ └── index.html
│ ├── index.html
│ └── recipes
│ │ ├── child-routes
│ │ └── index.html
│ │ ├── dynamic-routes
│ │ └── index.html
│ │ ├── error-pages
│ │ └── index.html
│ │ ├── guards
│ │ └── index.html
│ │ ├── index.html
│ │ ├── lazy-loading
│ │ └── index.html
│ │ ├── named-routes
│ │ └── index.html
│ │ ├── programmatic-navigation
│ │ └── index.html
│ │ ├── redirects
│ │ └── index.html
│ │ └── slots
│ │ └── index.html
├── index.html
└── index.md
├── _site
├── .eleventyignore
├── 0d2fe2f7.svg
├── 0f73e263.js
├── 0fe6ea42.svg
├── 1e574a75.svg
├── 3dfb6b8e.js
├── 5280dd3f.js
├── 636405e5.svg
├── 74a5dba1.css
├── 78a4a5a2.js
├── 866a7333.png
├── 962426a7.js
├── _merged_assets
│ └── _static
│ │ ├── 404
│ │ ├── bg_purple.png
│ │ └── overlay_stars.svg
│ │ ├── icons
│ │ ├── android-chrome-192x192.png
│ │ ├── android-chrome-512x512.png
│ │ ├── apple-touch-icon.png
│ │ ├── favicon-16x16.png
│ │ ├── favicon-32x32.png
│ │ ├── icon-128x128.png
│ │ ├── icon-512x512.png
│ │ ├── maskable-icon-128x128.png
│ │ ├── maskable-icon.png
│ │ ├── mstile-150x150.png
│ │ └── safari-pinned-tab.svg
│ │ ├── noscript.css
│ │ ├── rocket-search-index.json
│ │ └── search
│ │ └── noscript.css
├── ac2ea3b8.css
├── assets
│ ├── apple-touch-icon.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── safari-pinned-tab.svg
│ └── webmanifest.json
├── b8c01bc2.css
├── d15d5a5d.js
├── dba25cba.css
├── docs
│ ├── api
│ │ ├── index.html
│ │ ├── route
│ │ │ └── index.html
│ │ ├── router-options
│ │ │ └── index.html
│ │ └── router
│ │ │ └── index.html
│ └── index.html
├── guides
│ ├── customizing
│ │ ├── index.html
│ │ ├── middleware
│ │ │ └── index.html
│ │ ├── rootpaths
│ │ │ └── index.html
│ │ └── styling-transitions
│ │ │ └── index.html
│ ├── getting-started
│ │ ├── index.html
│ │ ├── using-a-starter
│ │ │ └── index.html
│ │ ├── using-an-outlet
│ │ │ └── index.html
│ │ └── your-first-setup
│ │ │ └── index.html
│ ├── index.html
│ └── recipes
│ │ ├── child-routes
│ │ └── index.html
│ │ ├── dynamic-routes
│ │ └── index.html
│ │ ├── error-pages
│ │ └── index.html
│ │ ├── guards
│ │ └── index.html
│ │ ├── index.html
│ │ ├── lazy-loading
│ │ └── index.html
│ │ ├── named-routes
│ │ └── index.html
│ │ ├── programmatic-navigation
│ │ └── index.html
│ │ ├── redirects
│ │ └── index.html
│ │ └── slots
│ │ └── index.html
├── index.html
└── service-worker.js
├── docs
├── .eleventyignore
├── 404.md
├── _assets
│ ├── _static
│ │ └── icons
│ │ │ ├── favicon-16x16.png
│ │ │ └── favicon-32x32.png
│ ├── layout.css
│ ├── logo.svg
│ ├── simplr-router-logo-black.png
│ ├── simplr-router-logo-transparent.png
│ └── variables.css
├── _data
│ ├── eleventyComputed.cjs
│ ├── footer.json
│ ├── rocketConfig.cjs
│ ├── rocketLaunch.json
│ ├── site.cjs
│ └── siteUrl.cjs
├── _includes
│ ├── _joiningBlocks
│ │ ├── _layoutHome
│ │ │ └── content
│ │ │ │ └── 10-hero.njk
│ │ └── header
│ │ │ └── 20-logo.njk
│ └── partials
│ │ ├── _shared
│ │ └── logoLink.njk
│ │ └── header.njk
├── docs
│ ├── api
│ │ ├── events.md
│ │ ├── helper-functions.md
│ │ ├── index.md
│ │ ├── route.md
│ │ ├── router-options.md
│ │ └── router.md
│ └── index.md
├── guides
│ ├── customizing
│ │ ├── index.md
│ │ ├── middleware.md
│ │ ├── rootpaths.md
│ │ └── styling-transitions.md
│ ├── getting-started
│ │ ├── index.md
│ │ ├── using-a-starter.md
│ │ ├── using-an-outlet.md
│ │ └── your-first-setup.md
│ ├── index.md
│ └── recipes
│ │ ├── child-routes.md
│ │ ├── dynamic-routes.md
│ │ ├── error-pages.md
│ │ ├── guards.md
│ │ ├── index.md
│ │ ├── lazy-loading.md
│ │ ├── named-routes.md
│ │ ├── nested-routes.md
│ │ ├── passing-properties.md
│ │ ├── preventing-navigation.md
│ │ ├── programmatic-navigation.md
│ │ ├── redirects.md
│ │ └── slots.md
├── index.md
└── sitemap.njk
├── package-lock.json
├── package.json
└── rocket.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Matsuuu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | [](https://www.npmjs.com/package/@simplr-wc/router)
4 |
5 | # Simplr Router
6 |
7 | A small and effective routing solution for Web Components.
8 |
9 | ## Getting started
10 |
11 | Get started using Simplr Router with [one of the guides from the documentation site](https://simplr.github.io/simplr-router/guides/getting-started/using-a-starter/)
12 |
13 | ```javascript
14 | import { SimplrRouter } from "@simplr-wc/router";
15 |
16 | const routes = [
17 | { path: "", component: "minimal-setup" },
18 | { path: "example", component: "example-view" },
19 | { path: "dynamic/:id", component: "dynamic-view" },
20 | ];
21 |
22 | new SimplrRouter({ routes }).init();
23 | ```
24 |
25 | ## Why
26 |
27 | #### Quick and Simple
28 |
29 | Simple to get up and running. Basic setup in just a few lines of code.
30 |
31 | #### Small
32 |
33 | No dependencies and a small codebase means less breaking parts.
34 | 0 dependencies means that what you see is what you get.
35 |
36 | #### Easy to transition into
37 |
38 | Works by utilizing the native API's used for navigation and therefore doesn't require any extra steps compared to your every day MPA.
39 |
40 | #### Web Component focused
41 |
42 | Built with web components, for web components. Simplr Router was designed from the get go to be used in web component applications.
43 |
44 | #### Customizable
45 |
46 | Even though there's no configuration necessary to get started, the router ships with a lot of customizability to fit your needs.
47 |
48 |
49 | #### Performant
50 |
51 | Allowing for lazy loading and creating dynamic routes, Simplr Router is a great library for projects of all sizes.
52 | Discover
53 |
--------------------------------------------------------------------------------
/assets/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/assets/favicon-16x16.png
--------------------------------------------------------------------------------
/assets/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/assets/favicon-32x32.png
--------------------------------------------------------------------------------
/assets/logo-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/assets/logo-white.png
--------------------------------------------------------------------------------
/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/assets/logo.png
--------------------------------------------------------------------------------
/assets/simplr-router-logo-banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/assets/simplr-router-logo-banner.png
--------------------------------------------------------------------------------
/assets/simplr-router-logo-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/assets/simplr-router-logo-black.png
--------------------------------------------------------------------------------
/assets/simplr-router-logo-transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/assets/simplr-router-logo-transparent.png
--------------------------------------------------------------------------------
/assets/simplr-router-logo-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/assets/simplr-router-logo-white.png
--------------------------------------------------------------------------------
/assets/simplr-router-logo.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/assets/simplr-router-logo.jpeg
--------------------------------------------------------------------------------
/build-docs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | rm -rf docs
4 | mkdir docs
5 | cd rocket-docs
6 | npm run docs
7 | cd ..
8 | cp -r rocket-docs/_site/* docs/
9 |
--------------------------------------------------------------------------------
/docs/0332ee92.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/0332ee92.png
--------------------------------------------------------------------------------
/docs/078800d4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/078800d4.png
--------------------------------------------------------------------------------
/docs/0abae851.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/0abae851.png
--------------------------------------------------------------------------------
/docs/0b52c7d6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/0b52c7d6.png
--------------------------------------------------------------------------------
/docs/0d2fe2f7.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/docs/0d7ffa66.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/0d7ffa66.png
--------------------------------------------------------------------------------
/docs/1749e3ec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/1749e3ec.png
--------------------------------------------------------------------------------
/docs/176cd193.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/176cd193.png
--------------------------------------------------------------------------------
/docs/1d559c8f.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/1d559c8f.png
--------------------------------------------------------------------------------
/docs/248138a9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/248138a9.png
--------------------------------------------------------------------------------
/docs/269a33fb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/269a33fb.png
--------------------------------------------------------------------------------
/docs/28cea4e0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/28cea4e0.png
--------------------------------------------------------------------------------
/docs/337751cf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/337751cf.png
--------------------------------------------------------------------------------
/docs/36057de5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/36057de5.png
--------------------------------------------------------------------------------
/docs/384ca148.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/384ca148.png
--------------------------------------------------------------------------------
/docs/3ac4863b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/3ac4863b.png
--------------------------------------------------------------------------------
/docs/46d66be1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/46d66be1.png
--------------------------------------------------------------------------------
/docs/5663b789.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/5663b789.png
--------------------------------------------------------------------------------
/docs/6a645292.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/6a645292.png
--------------------------------------------------------------------------------
/docs/7e744e1c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/7e744e1c.png
--------------------------------------------------------------------------------
/docs/866a7333.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/866a7333.png
--------------------------------------------------------------------------------
/docs/9379d4b8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/9379d4b8.png
--------------------------------------------------------------------------------
/docs/962426a7.js:
--------------------------------------------------------------------------------
1 | const t=new WeakMap;function e(e){return r=>{if(function(e,r){let n=r;for(;n;){if(t.get(n)===e)return!0;n=Object.getPrototypeOf(n)}return!1}(e,r))return r;const n=e(r);return t.set(n,e),n}}export{e as d};
2 |
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/404/bg_purple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/404/bg_purple.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/404/overlay_stars.svg:
--------------------------------------------------------------------------------
1 |
5 |
6 | overlay_stars_1
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/android-chrome-192x192.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/android-chrome-512x512.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/apple-touch-icon.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/favicon-16x16.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/favicon-32x32.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/icon-128x128.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/icon-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/icon-512x512.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/maskable-icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/maskable-icon-128x128.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/maskable-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/maskable-icon.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/icons/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/_merged_assets/_static/icons/mstile-150x150.png
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/noscript.css:
--------------------------------------------------------------------------------
1 | /* override to add noscript styles */
2 |
3 | /* Make sure unregistered custom elements don't hide their contents */
4 | :not(:defined) {
5 | opacity: 1 !important;
6 | }
7 |
8 | inline-notification {
9 | padding: 0.1rem 1.5rem;
10 | border-left-width: 0.5rem;
11 | border-left-style: solid;
12 | margin: 1rem 0;
13 | display: block;
14 | opacity: 1 !important;
15 | }
16 |
17 | inline-notification::before {
18 | content: attr(type);
19 | font-weight: 600;
20 | font-size: 1.17em;
21 | margin-top: 24px;
22 | margin-bottom: 7px;
23 | display: block;
24 | text-transform: uppercase;
25 | }
26 |
27 | inline-notification[type='tip'] {
28 | background-color: var(--inline-notification-tip-background-color, rgba(221, 221, 221, 0.3));
29 | border-color: var(--inline-notification-tip-border-color, #42b983);
30 | }
31 |
32 | inline-notification[type='warning'] {
33 | background-color:
34 | var(
35 | --inline-notification-warning-background-color,
36 | rgba(255, 229, 100, 0.2)
37 | );
38 | border-color: var(--inline-notification-warning-border-color, #e7c000);
39 | }
40 |
41 | inline-notification[type='danger'] {
42 | background-color: var(--inline-notification-danger-background-color, rgba(192, 0, 0, 0.1));
43 | border-color: var(--inline-notification-danger-border-color, #c00);
44 | }
45 |
46 | inline-notification[type='warning']::before {
47 | color: var(--inline-notification-warning-heading-color, #b29400);
48 | }
49 |
50 | inline-notification[type='danger']::before {
51 | color: var(--inline-notification-danger-heading-color, #900);
52 | }
53 |
54 | inline-notification > p {
55 | line-height: 1.7;
56 | }
57 |
--------------------------------------------------------------------------------
/docs/_merged_assets/_static/search/noscript.css:
--------------------------------------------------------------------------------
1 | rocket-search {
2 | display: none;
3 | }
4 |
--------------------------------------------------------------------------------
/docs/a108fe31.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/a108fe31.png
--------------------------------------------------------------------------------
/docs/a63b1bdf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/a63b1bdf.png
--------------------------------------------------------------------------------
/docs/a7589c58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/a7589c58.png
--------------------------------------------------------------------------------
/docs/ae5c019b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/ae5c019b.png
--------------------------------------------------------------------------------
/docs/assets/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/assets/apple-touch-icon.png
--------------------------------------------------------------------------------
/docs/assets/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/assets/favicon-16x16.png
--------------------------------------------------------------------------------
/docs/assets/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/assets/favicon-32x32.png
--------------------------------------------------------------------------------
/docs/assets/webmanifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Rocket",
3 | "short_name": "Rocket",
4 | "theme_color": "#e63946",
5 | "background_color": "#1d3557",
6 | "display": "standalone",
7 | "orientation": "portrait",
8 | "Scope": "/",
9 | "start_url": "/",
10 | "icons": [
11 | {
12 | "src": "../_merged_assets/_static/icons/android-chrome-192x192.png",
13 | "sizes": "128x128",
14 | "type": "image/png"
15 | },
16 | {
17 | "src": "../_merged_assets/_static/icons/android-chrome-512x512.png",
18 | "sizes": "512x512",
19 | "type": "image/png"
20 | },
21 | {
22 | "src": "../_merged_assets/_static/icons/maskable-icon.jpg",
23 | "sizes": "1024x1024",
24 | "type": "image/jpg",
25 | "purpose": "any maskable"
26 | }
27 | ],
28 | "splash_pages": null
29 | }
30 |
--------------------------------------------------------------------------------
/docs/b8c01bc2.css:
--------------------------------------------------------------------------------
1 | /* feel free to override this file for your page - add a file docs/_assets/style.css */
2 |
3 | body[layout^='layout-home'] .markdown-body .call-to-action:nth-of-type(2) {
4 | --primary-color: #222;
5 | --primary-color-lighter: #333;
6 | --primary-color-darker: #000;
7 | }
8 |
9 | @media screen and (min-width: 1024px) {
10 | body[layout='layout-home-background'] .page-background {
11 | top: -210px;
12 | right: -463px;
13 | transform: rotate(45deg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/docs/c05ac5c9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/c05ac5c9.png
--------------------------------------------------------------------------------
/docs/d15d5a5d.js:
--------------------------------------------------------------------------------
1 | (async()=>{if("serviceWorker"in navigator){const{Workbox:e}=await import("./3dfb6b8e.js"),o=new e(window.__rocketServiceWorkerUrl||"/service-worker.js");o.addEventListener("message",(e=>{if("CACHE_UPDATED"===e.data.type){const{updatedURL:o}=e.data.payload;console.log(`Reloading as a newer version of ${o} became available!`),window.location.reload()}})),o.register().then((function(){console.log("ServiceWorker registered.")})).catch((function(e){console.log("ServiceWorker registration failed: ",e)}))}})();
2 |
--------------------------------------------------------------------------------
/docs/d5808608.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/d5808608.png
--------------------------------------------------------------------------------
/docs/d86a67d8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/d86a67d8.png
--------------------------------------------------------------------------------
/docs/dba25cba.css:
--------------------------------------------------------------------------------
1 | html {
2 | --primary-color: #ff6d00;
3 | --primary-color-lighter: #ff8b33;
4 | --primary-color-darker: #cc5800;
5 | --primary-color-accent: #994200;
6 | --primary-text-color: #2c3e50;
7 | --primary-lines-color: #ccc;
8 | --primary-text-inverse-color: #eee;
9 |
10 | /* Contrast colors */
11 | --contrast-color-light: #fff;
12 | --contrast-color-dark: #1d3557;
13 |
14 | /* background-colors */
15 | --page-background: white;
16 | --footer-background: rgba(0, 0, 0, 0.1);
17 |
18 | /* typography */
19 | --text-color: black;
20 | --primary-font-family: 'Open Sans', sans-serif;
21 | --secondary-font-family: 'Montserrat', sans-serif;
22 | --monospace-font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace;
23 |
24 | /* controls */
25 | --switch-unselected-color: #808080;
26 | --switch-selected-color: #42b983;
27 | }
28 |
29 | html.dark {
30 | --primary-color: #e63946;
31 | --primary-color-lighter: #e25761;
32 | --primary-color-darker: #a22831;
33 | --primary-color-accent: #cee5f6;
34 | --primary-text-color: #eee;
35 | --primary-text-inverse-color: #2c3e50;
36 |
37 | /* Contrast colors */
38 | --contrast-color-light: #fff;
39 | --contrast-color-dark: #1d3557;
40 |
41 | /* background-colors */
42 | --page-background: #333;
43 | --footer-background: #4f4f4f;
44 |
45 | /* typography */
46 | --text-color: white;
47 |
48 | /* controls */
49 | --switch-unselected-color: #808080;
50 | --switch-selected-color: #42b983;
51 |
52 | /* markdown */
53 | --markdown-octicon-link: white;
54 | --markdown-syntax-background-color: #a0a0a0;
55 | --markdown-link-color: #fb7881;
56 | --markdown-blockquote-color: #c9e3ff;
57 | }
58 |
--------------------------------------------------------------------------------
/docs/ef817fcb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/ef817fcb.png
--------------------------------------------------------------------------------
/docs/f563d575.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/f563d575.png
--------------------------------------------------------------------------------
/docs/f6311b2e.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/docs/f6311b2e.png
--------------------------------------------------------------------------------
/docs/sitemap.njk:
--------------------------------------------------------------------------------
1 | ---
2 | layout: layout-raw
3 | permalink: /sitemap.xml
4 | eleventyExcludeFromCollections: true
5 | ---
6 |
7 |
8 |
9 | {% for page in collections.all %}
10 | {%- if page.url !== '/404.html' -%}
11 |
12 | {{ rocketConfig.absoluteBaseUrl }}{{ page.url | url }}
13 | {{ page.date.toISOString() }}
14 | {{ page.data.changeFreq if page.data.changeFreq else "monthly" }}
15 |
16 | {%- endif -%}
17 | {% endfor %}
18 |
19 |
--------------------------------------------------------------------------------
/examples/application-demo/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 |
8 | [*]
9 |
10 | # Change these settings to your own preference
11 | indent_style = tab
12 | indent_size = 4
13 |
14 | # We recommend you to keep these unchanged
15 | end_of_line = lf
16 | charset = utf-8
17 | trim_trailing_whitespace = true
18 | insert_final_newline = true
19 |
20 | [*.md]
21 | trim_trailing_whitespace = false
22 |
23 | [*.json]
24 | indent_size = 2
25 |
26 | [*.{html,js,md}]
27 | block_comment_start = /**
28 | block_comment = *
29 | block_comment_end = */
30 |
--------------------------------------------------------------------------------
/examples/application-demo/.gitignore:
--------------------------------------------------------------------------------
1 | ## editors
2 | /.idea
3 | /.vscode
4 |
5 | ## system files
6 | .DS_Store
7 |
8 | ## npm
9 | /node_modules/
10 | /npm-debug.log
11 |
12 | ## testing
13 | /coverage/
14 |
15 | ## temp folders
16 | /.tmp/
17 |
18 | # build
19 | /_site/
20 | /dist/
21 | /out-tsc/
22 |
23 | storybook-static
--------------------------------------------------------------------------------
/examples/application-demo/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 application-demo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/examples/application-demo/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ## Open-wc Starter App
6 |
7 | [](https://github.com/open-wc)
8 |
9 | ## Quickstart
10 |
11 | To get started:
12 |
13 | ```sh
14 | npm init @open-wc
15 | # requires node 10 & npm 6 or higher
16 | ```
17 |
18 | ## Scripts
19 |
20 | - `start` runs your app for development, reloading on file changes
21 | - `start:build` runs your app after it has been built using the build command
22 | - `build` builds your app and outputs it in your `dist` directory
23 | - `test` runs your test suite with Web Test Runner
24 | - `lint` runs the linter for your project
25 |
26 | ## Tooling configs
27 |
28 | For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
29 |
30 | If you customize the configuration a lot, you can consider moving them to individual files.
--------------------------------------------------------------------------------
/examples/application-demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
12 |
13 |
14 |
18 |
37 | application-demo
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/examples/application-demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "application-demo",
3 | "description": "Webcomponent application-demo following open-wc recommendations",
4 | "license": "MIT",
5 | "author": "application-demo",
6 | "version": "0.0.0",
7 | "scripts": {
8 | "build": "rimraf dist && tsc && rollup -c rollup.config.js",
9 | "start:build": "web-dev-server --root-dir dist --app-index index.html --open",
10 | "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\""
11 | },
12 | "dependencies": {
13 | "@simplr-wc/router": "file:../../lib",
14 | "lit": "^2.0.0-rc.2"
15 | },
16 | "devDependencies": {
17 | "@babel/preset-env": "^7.15.0",
18 | "@open-wc/building-rollup": "^1.10.0",
19 | "@rollup/plugin-babel": "^5.3.0",
20 | "@rollup/plugin-node-resolve": "^13.0.4",
21 | "@web/dev-server": "^0.1.21",
22 | "@web/rollup-plugin-html": "^1.9.1",
23 | "@web/rollup-plugin-import-meta-assets": "^1.0.7",
24 | "babel-plugin-template-html-minifier": "^4.1.0",
25 | "concurrently": "^5.3.0",
26 | "deepmerge": "^4.2.2",
27 | "rimraf": "^3.0.2",
28 | "rollup": "^2.56.2",
29 | "rollup-plugin-terser": "^7.0.2",
30 | "rollup-plugin-workbox": "^6.2.0",
31 | "tslib": "^2.3.1",
32 | "typescript": "^4.3.5"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/examples/application-demo/src/components/ItemList.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 |
4 | @customElement("item-list")
5 | export class ItemList extends LitElement {
6 |
7 | static get styles() {
8 | return css``;
9 | }
10 |
11 | render() {
12 | return html`
13 |
14 | `
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/examples/application-demo/src/components/ItemListEntry.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import { property } from "lit/decorators/property.js";
4 |
5 | @customElement("item-list-entry")
6 | export class ItemListEntry extends LitElement {
7 | @property({ type: String })
8 | href: string = "";
9 | @property({ type: String })
10 | title: string = "";
11 | @property({ type: String })
12 | content: string = "";
13 |
14 | static get styles() {
15 | return css`
16 | :host {
17 | display: flex;
18 | border: 1px solid #4f4f4f;
19 | margin-bottom: 1rem;
20 | font-size: 0.8rem;
21 | transition: 200ms ease-in-out;
22 | }
23 |
24 | :host(:hover) {
25 | background: salmon;
26 | }
27 |
28 | a {
29 | padding: 0.5rem 1rem;
30 | color: inherit;
31 | text-decoration: none;
32 | width: 100%;
33 | }
34 | `;
35 | }
36 |
37 | render() {
38 | return html`
39 |
40 | ${this.title}
41 | ${this.content.substring(0, 200)}...
42 |
43 | `;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/examples/application-demo/src/components/SideNav.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import "./SideNavItem";
4 |
5 | @customElement("side-nav")
6 | export class SideNav extends LitElement {
7 |
8 |
9 | static get styles() {
10 | return css`
11 | :host {
12 | display: flex;
13 | flex-direction: column;
14 | height: 100vh;
15 | width: 250px;
16 | background: grey;
17 | padding: 1rem 0;
18 | background: #2f2f2f;
19 | box-sizing: border-box;
20 | }
21 |
22 | .logo {
23 | display: flex;
24 | width: 100%;
25 | height: 100px;
26 | align-items: center;
27 | color: #FFF;
28 | font-size: 22px;
29 | font-weight: bold;
30 | margin-bottom: 6rem;
31 | padding: 0 1rem;
32 | }
33 |
34 | .logo img {
35 | height: 100px;
36 | filter: invert(1);
37 | }
38 | `;
39 | }
40 |
41 | render() {
42 | return html`
43 |
44 |
45 |
Simplr Router
46 |
47 |
48 |
49 |
50 |
51 |
52 | `;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/examples/application-demo/src/components/SideNavItem.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import { property } from "lit/decorators/property.js";
4 |
5 | @customElement("side-nav-item")
6 | export class SideNavItem extends LitElement {
7 | @property({ type: String, reflect: true })
8 | href: string = "";
9 |
10 | @property({ type: String, reflect: true })
11 | label: string = "";
12 |
13 | @property({ type: Boolean, reflect: true })
14 | external: boolean = false;
15 |
16 | static get styles() {
17 | return css`
18 | :host {
19 | color: #fff;
20 | font-size: 1.6rem;
21 | background: inherit;
22 | cursor: pointer;
23 | transition: 200ms ease-in-out;
24 | display: flex;
25 | }
26 |
27 | :host(:hover) {
28 | background: salmon;
29 | color: #2f2f2f;
30 | }
31 |
32 | a {
33 | width: 100%;
34 | padding: 1rem 2rem;
35 | color: inherit;
36 | text-decoration: none;
37 | }
38 | `;
39 | }
40 |
41 | render() {
42 | return html`${this.label}${this.external ? html`☇` : ''} `;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/examples/application-demo/src/index.ts:
--------------------------------------------------------------------------------
1 | import "./components/SideNav";
2 | import "./router";
3 |
4 |
--------------------------------------------------------------------------------
/examples/application-demo/src/service/GitHub.ts:
--------------------------------------------------------------------------------
1 | const ROUTER_REPO_URL = "https://api.github.com/repos/Simplr/simplr-router";
2 |
3 | export async function getIssues() {
4 | return fetch(ROUTER_REPO_URL + "/issues")
5 | .then(res => res.json())
6 | .catch(err => {
7 | console.error("Can't fetch data", err);
8 | return [];
9 | })
10 | }
11 |
12 | export async function getIssue(issueNumber: number) {
13 | return fetch(ROUTER_REPO_URL + "/issues/" + issueNumber)
14 | .then(res => res.json())
15 | .catch(err => {
16 | console.error("Can't fetch data", err);
17 | return [];
18 | })
19 | }
20 |
21 | export async function getCommits() {
22 | return fetch(ROUTER_REPO_URL + "/commits")
23 | .then(res => res.json())
24 | .catch(err => {
25 | console.error("Can't fetch data", err);
26 | return [];
27 | })
28 | }
29 |
30 | export async function getCommit(sha: string) {
31 | return fetch(ROUTER_REPO_URL + "/commits/" + sha)
32 | .then(res => res.json())
33 | .catch(err => {
34 | console.error("Can't fetch data", err);
35 | return [];
36 | })
37 | }
38 |
39 | export async function getPullRequests() {
40 | return fetch(ROUTER_REPO_URL + "/pulls")
41 | .then(res => res.json())
42 | .catch(err => {
43 | console.error("Can't fetch data", err);
44 | return [];
45 | })
46 | }
47 |
48 | export async function getPullRequest(prNumber: number) {
49 | return fetch(ROUTER_REPO_URL + "/pulls/" + prNumber)
50 | .then(res => res.json())
51 | .catch(err => {
52 | console.error("Can't fetch data", err);
53 | return [];
54 | })
55 | }
56 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/AboutPage.ts:
--------------------------------------------------------------------------------
1 |
2 | import { html, LitElement } from "lit";
3 | import { customElement } from "lit/decorators/custom-element.js";
4 |
5 | @customElement("about-page")
6 | export class AboutPage extends LitElement {
7 |
8 | render() {
9 | return html`About
`;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/DataPage.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import "../components/ItemList";
4 | import "../components/ItemListEntry";
5 |
6 | @customElement("data-page")
7 | export class DataPage extends LitElement {
8 |
9 | firstUpdated() {
10 | this._getRepositoryData();
11 | }
12 |
13 | async _getRepositoryData() {
14 | // Create a 3x1 grid with fields:
15 | // - Issues
16 | // - Pull Requests
17 | // - Commits
18 | //
19 | // ISSUES | PULL REQUESTS | COMMITS
20 | //
21 | // Under them, create a 2x1 grid, left side populates with a list of chosen category.
22 | // When clicked on a list item in the category, the right side populates with the data of the chosen item
23 | }
24 |
25 | render() {
26 | return html`
27 |
32 |
33 | `;
34 | }
35 |
36 | static get styles() {
37 | return css`
38 | :host {
39 | display: flex;
40 | padding: 5rem 10rem;
41 | flex-direction: column;
42 | }
43 |
44 | section.categories {
45 | display: flex;
46 | width: 100%;
47 | justify-content: space-between;
48 | }
49 |
50 | section.categories a {
51 | display: flex;
52 | align-items: center;
53 | justify-content: center;
54 | flex-basis: 25%;
55 | padding: 5rem 0;
56 | font-size: 26px;
57 | text-decoration: none;
58 | color: #2f2f2f;
59 | box-shadow: 0px 3px 3px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14),0px 1px 8px 0px rgba(0, 0, 0, 0.12);
60 | border-radius: 4px;
61 | }
62 |
63 | section.categories a {
64 | background: #2f2f2f;
65 | color: #FFF;
66 | transition: 200ms ease-in-out;
67 | }
68 |
69 | section.categories a:hover,
70 | section.categories a[selected] {
71 | background: salmon;
72 | color: #2f2f2f;
73 | }
74 | `;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/LandingPage.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 |
4 | @customElement("landing-page")
5 | export class LandingPage extends LitElement {
6 | static get styles() {
7 | return css`
8 | main {
9 | display: flex;
10 | flex-direction: column;
11 | align-items: center;
12 | justify-content: center;
13 | height: 100%;
14 | }
15 |
16 | ul {
17 | text-align: center;
18 | list-style: none;
19 | }
20 | li {
21 | padding: 0.5rem 0;
22 | }
23 | `;
24 | }
25 |
26 | render() {
27 | return html`
28 |
29 | Simplr Router Application Demo
30 | This demo consists of
31 |
32 | The use of a router outlet to display content
33 | And external navigation component
34 | Code splitting
35 | Page transitions
36 | Nested views
37 | Dynamic views
38 | And more!
39 |
40 |
41 | `;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/data-views/DataPageCommitPanel.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import { property } from "lit/decorators/property.js";
4 | import { getCommit } from "../../service/GitHub";
5 |
6 | @customElement("data-page-commit-panel")
7 | export class DataPageCommitPanel extends LitElement {
8 | @property({ type: String })
9 | commitSha: string = "";
10 |
11 | @property({ type: Object })
12 | commit: any | undefined;
13 |
14 | firstUpdated() {
15 | this._getCommitData();
16 | }
17 |
18 | private async _getCommitData() {
19 | if (!this.commitSha) return;
20 |
21 | this.commit = await getCommit(this.commitSha);
22 | }
23 |
24 | render() {
25 | if (!this.commit) return html``;
26 |
27 | return html`
28 | ${this.commit.sha}
29 | ${this.commit.commit.message}
30 |
31 | Created: ${new Date(this.commit.commit.committer.date).toUTCString()}
32 |
33 |
34 | ${this.commit.files.map(
35 | (file: any) => html`
36 |
37 | ${file.filename}
38 | +${file.additions}
39 | -${file.deletions}
40 |
41 | `
42 | )}
43 |
44 |
45 | Link to issue
46 | `;
47 | }
48 |
49 | static get styles() {
50 | return css`
51 | ul {
52 | list-style: none;
53 | padding: 0;
54 | }
55 |
56 | li {
57 | margin-bottom: 0.4rem;
58 | }
59 |
60 | ins {
61 | color: green;
62 | }
63 |
64 | del {
65 | text-decoration: none;
66 | color: red;
67 | }
68 |
69 | `
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/data-views/DataPageCommits.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import { property } from "lit/decorators/property.js";
4 | import { getCommits } from "../../service/GitHub";
5 |
6 | @customElement("data-page-commits")
7 | export class DataPageCommits extends LitElement {
8 | @property({ type: Object })
9 | commits: Array = [];
10 |
11 | firstUpdated() {
12 | this._fetchCommits();
13 | }
14 |
15 | private async _fetchCommits() {
16 | this.commits = await getCommits();
17 | }
18 |
19 | _createCommitUrl(commit: any) {
20 | return "/data/commits/" + commit.sha;
21 | }
22 |
23 | render() {
24 | return html`
25 |
26 | ${this.commits.length <= 0 ? html`No commits found
` : ''}
27 |
28 | ${this.commits.map(
29 | (comm) => html`
30 |
35 | `
36 | )}
37 |
38 |
39 |
42 | `;
43 | }
44 |
45 | static get styles() {
46 | return css`
47 | :host {
48 | margin: 4rem 0 0;
49 | display: flex;
50 | justify-content: space-between;
51 | }
52 |
53 | section {
54 | flex-basis: 40%;
55 | max-height: 600px;
56 | overflow-y: auto;
57 | }
58 | `;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/data-views/DataPageInfo.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 |
4 | @customElement("data-page-info")
5 | export class DataPageInfo extends LitElement {
6 |
7 | render() {
8 | return html`
9 | This is the data page. On this page you can browse data about the Simplr Router project, provided by the GitHub API
10 | The routing handles different child views inside this view, and displays the needed parts dynamically
11 | This content is loaded as a slotted element of the above view, and will dynamically change when you navigate with the buttons above
12 | `
13 | }
14 |
15 | static get styles() {
16 | return css`
17 | :host {
18 | padding-top: 4rem;
19 | }
20 | `
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/data-views/DataPageIssuePanel.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import { property } from "lit/decorators/property.js";
4 | import { getIssue } from "../../service/GitHub";
5 |
6 | @customElement("data-page-issue-panel")
7 | export class DataPageIssuePanel extends LitElement {
8 | @property({ type: Number })
9 | issueNumber: number = 0;
10 |
11 | @property({ type: Object })
12 | issue: any | undefined;
13 |
14 | firstUpdated() {
15 | this._getIssueData();
16 | }
17 |
18 | private async _getIssueData() {
19 | if (!this.issueNumber) return;
20 |
21 | this.issue = await getIssue(this.issueNumber);
22 | }
23 |
24 | render() {
25 | if (!this.issue) return html``;
26 |
27 | return html`
28 | ${this.issue.title}
29 | ${this.issue.body}
30 |
31 | Created: ${this.issue.created_at}
32 | Last updated: ${this.issue.updated_at}
33 |
34 | Link to issue
35 | `;
36 | }
37 |
38 | static get styles() {
39 | return css`
40 | :host {
41 | display: flex;
42 | flex-direction: column;
43 | }
44 | `
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/data-views/DataPageIssues.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import { property } from "lit/decorators/property.js";
4 | import { getIssues } from "../../service/GitHub";
5 |
6 | @customElement("data-page-issues")
7 | export class DataPageIssues extends LitElement {
8 | @property({ type: Object })
9 | issues: Array = [];
10 |
11 | firstUpdated() {
12 | this._fetchIssues();
13 | }
14 |
15 | private async _fetchIssues() {
16 | this.issues = await getIssues();
17 | }
18 |
19 | _createIssueUrl(issue: any) {
20 | return "/data/issues/" + issue.number;
21 | }
22 |
23 | render() {
24 | return html`
25 |
26 | ${this.issues.length <= 0 ? html`No issues found
` : ''}
27 |
28 | ${this.issues.map(
29 | (iss) => html`
30 |
35 | `
36 | )}
37 |
38 |
39 |
42 | `;
43 | }
44 |
45 | static get styles() {
46 | return css`
47 | :host {
48 | margin: 4rem 0 0;
49 | display: flex;
50 | justify-content: space-between;
51 | }
52 |
53 | section {
54 | flex-basis: 40%;
55 | max-height: 600px;
56 | overflow-y: scroll;
57 | }
58 | `;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/data-views/DataPagePullRequestPanel.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import { property } from "lit/decorators/property.js";
4 | import { getIssue } from "../../service/GitHub";
5 |
6 | @customElement("data-page-pull-request-panel")
7 | export class DataPagePullRequestPanel extends LitElement {
8 | @property({ type: Number })
9 | prNumber: number = 0;
10 |
11 | @property({ type: Object })
12 | pullRequest: any | undefined;
13 |
14 | firstUpdated() {
15 | this._getPullRequestData();
16 | }
17 |
18 | private async _getPullRequestData() {
19 | if (!this.prNumber) return;
20 |
21 | this.pullRequest = await getIssue(this.prNumber);
22 | }
23 |
24 | render() {
25 | if (!this.pullRequest) return html``;
26 |
27 | return html`
28 | ${this.pullRequest.title}
29 | ${this.pullRequest.body}
30 |
31 | Created: ${this.pullRequest.created_at}
32 | Last updated: ${this.pullRequest.updated_at}
33 |
34 | Link to pull request
35 | `;
36 | }
37 |
38 | static get styles() {
39 | return css`
40 | :host {
41 | display: flex;
42 | flex-direction: column;
43 | }
44 | `
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/examples/application-demo/src/views/data-views/DataPagePullRequests.ts:
--------------------------------------------------------------------------------
1 | import { css, html, LitElement } from "lit";
2 | import { customElement } from "lit/decorators/custom-element.js";
3 | import { property } from "lit/decorators/property.js";
4 | import { getPullRequests } from "../../service/GitHub";
5 |
6 | @customElement("data-page-pull-requests")
7 | export class DataPagePullRequests extends LitElement {
8 | @property({ type: Object })
9 | pullRequests: Array = [];
10 |
11 | firstUpdated() {
12 | this._fetchpullRequests();
13 | }
14 |
15 | private async _fetchpullRequests() {
16 | this.pullRequests = await getPullRequests();
17 | }
18 |
19 | _createPrUrl(pr: any) {
20 | return "/data/pull-requests/" + pr.number;
21 | }
22 |
23 | render() {
24 | return html`
25 |
26 | ${this.pullRequests.length <= 0 ? html`No pull-requests found
` : ''}
27 |
28 | ${this.pullRequests.map(
29 | (pr) => html`
30 |
35 | `
36 | )}
37 |
38 |
39 |
42 | `;
43 | }
44 |
45 | static get styles() {
46 | return css`
47 | :host {
48 | margin: 4rem 0 0;
49 | display: flex;
50 | justify-content: space-between;
51 | }
52 |
53 | section {
54 | flex-basis: 40%;
55 | max-height: 600px;
56 | overflow-y: auto;
57 | }
58 | `;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/examples/application-demo/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2018",
4 | "module": "esnext",
5 | "moduleResolution": "node",
6 | "noEmitOnError": true,
7 | "lib": ["es2017", "dom"],
8 | "strict": true,
9 | "esModuleInterop": false,
10 | "allowSyntheticDefaultImports": true,
11 | "experimentalDecorators": true,
12 | "importHelpers": true,
13 | "outDir": "out-tsc",
14 | "sourceMap": true,
15 | "inlineSources": true,
16 | "rootDir": "./",
17 | "incremental": true
18 | },
19 | "include": ["**/*.ts"]
20 | }
21 |
--------------------------------------------------------------------------------
/examples/application-demo/web-dev-server.config.mjs:
--------------------------------------------------------------------------------
1 | // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2 |
3 | /** Use Hot Module replacement by adding --hmr to the start command */
4 | const hmr = process.argv.includes('--hmr');
5 |
6 | export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7 | open: '/',
8 | watch: !hmr,
9 | /** Resolve bare module imports */
10 | nodeResolve: {
11 | exportConditions: ['browser', 'development'],
12 | },
13 |
14 | /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
15 | // esbuildTarget: 'auto'
16 |
17 | /** Set appIndex to enable SPA routing */
18 | appIndex: 'index.html',
19 |
20 | plugins: [
21 | /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
22 | // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
23 | ],
24 |
25 | // See documentation for all available options
26 | });
27 |
--------------------------------------------------------------------------------
/examples/middleware-example.js:
--------------------------------------------------------------------------------
1 | export default class SimplrRouterMiddleware {
2 | routerNavigating(viewObject) {
3 | return viewObject;
4 | }
5 |
6 | routerNavigationComplete() {}
7 |
8 | newViewAddedToDOM() {}
9 |
10 | /*
11 | * Original implementation:
12 | *
13 | * container.appendChild(viewComponent);
14 | *
15 | * */
16 | addViewToContainerOverride(container, viewObject) {}
17 |
18 | /**
19 | * Original implementation:
20 | *
21 | * Builder.createComponentElement(view);
22 | * */
23 | createComponentOverride(view) {}
24 | }
25 |
--------------------------------------------------------------------------------
/examples/minimal-setup/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 |
8 | [*]
9 |
10 | # Change these settings to your own preference
11 | indent_style = space
12 | indent_size = 2
13 |
14 | # We recommend you to keep these unchanged
15 | end_of_line = lf
16 | charset = utf-8
17 | trim_trailing_whitespace = true
18 | insert_final_newline = true
19 |
20 | [*.md]
21 | trim_trailing_whitespace = false
22 |
23 | [*.json]
24 | indent_size = 2
25 |
26 | [*.{html,js,md}]
27 | block_comment_start = /**
28 | block_comment = *
29 | block_comment_end = */
30 |
--------------------------------------------------------------------------------
/examples/minimal-setup/.gitignore:
--------------------------------------------------------------------------------
1 | ## editors
2 | /.idea
3 | /.vscode
4 |
5 | ## system files
6 | .DS_Store
7 |
8 | ## npm
9 | /node_modules/
10 | /npm-debug.log
11 |
12 | ## testing
13 | /coverage/
14 |
15 | ## temp folders
16 | /.tmp/
17 |
18 | # build
19 | /_site/
20 | /dist/
21 | /out-tsc/
22 |
23 | storybook-static
24 | custom-elements.json
25 |
--------------------------------------------------------------------------------
/examples/minimal-setup/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 minimal-setup
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/examples/minimal-setup/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ## Open-wc Starter App
6 |
7 | [](https://github.com/open-wc)
8 |
9 | ## Quickstart
10 |
11 | To get started:
12 |
13 | ```bash
14 | npm init @open-wc
15 | # requires node 10 & npm 6 or higher
16 | ```
17 |
18 | ## Scripts
19 |
20 | - `start` runs your app for development, reloading on file changes
21 | - `start:build` runs your app after it has been built using the build command
22 | - `build` builds your app and outputs it in your `dist` directory
23 | - `test` runs your test suite with Web Test Runner
24 | - `lint` runs the linter for your project
25 | - `format` fixes linting and formatting errors
26 |
27 | ## Tooling configs
28 |
29 | For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
30 |
31 | If you customize the configuration a lot, you can consider moving them to individual files.
32 |
--------------------------------------------------------------------------------
/examples/minimal-setup/assets/open-wc-logo.svg:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/minimal-setup/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
12 |
21 | minimal-setup
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/minimal-setup/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "minimal-setup",
3 | "description": "Webcomponent minimal-setup following open-wc recommendations",
4 | "license": "MIT",
5 | "author": "minimal-setup",
6 | "version": "0.0.0",
7 | "scripts": {
8 | "analyze": "cem analyze --litelement",
9 | "start": "web-dev-server"
10 | },
11 | "dependencies": {
12 | "@simplr-wc/router": "file:../../lib",
13 | "lit": "^2.0.2"
14 | },
15 | "devDependencies": {
16 | "@custom-elements-manifest/analyzer": "^0.4.17",
17 | "@web/dev-server": "^0.1.25"
18 | },
19 | "customElements": "custom-elements.json"
20 | }
21 |
--------------------------------------------------------------------------------
/examples/minimal-setup/src/dynamic-view.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html } from "lit";
2 | import { viewStyles } from "./view-styles.js";
3 |
4 | const logo = new URL("../assets/open-wc-logo.svg", import.meta.url).href;
5 |
6 | export class DynamicView extends LitElement {
7 | static get properties() {
8 | return {
9 | title: { type: String },
10 | };
11 | }
12 |
13 | static get styles() {
14 | return viewStyles;
15 | }
16 |
17 | constructor() {
18 | super();
19 | this.title = "Welcome to the dynamic view";
20 | }
21 |
22 | render() {
23 | return html`
24 |
25 |
26 | ${this.title}
27 | The parameter from the URL is bound to the "id" property of this view
28 | The current value is: ${this.id}
29 |
30 |
36 |
37 | `;
38 | }
39 | }
40 |
41 | customElements.define("dynamic-view", DynamicView);
42 |
--------------------------------------------------------------------------------
/examples/minimal-setup/src/example-view.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html } from "lit";
2 | import { viewStyles } from "./view-styles.js";
3 |
4 | const logo = new URL("../assets/open-wc-logo.svg", import.meta.url).href;
5 |
6 | export class ExampleView extends LitElement {
7 | static get properties() {
8 | return {
9 | title: { type: String },
10 | };
11 | }
12 |
13 | static get styles() {
14 | return viewStyles;
15 | }
16 |
17 | constructor() {
18 | super();
19 | this.title = "Welcome to the example view";
20 | }
21 |
22 | render() {
23 | return html`
24 |
25 |
26 | ${this.title}
27 |
28 |
34 |
35 | `;
36 | }
37 | }
38 |
39 | customElements.define("example-view", ExampleView);
40 |
--------------------------------------------------------------------------------
/examples/minimal-setup/src/minimal-setup.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html } from "lit";
2 | import { viewStyles } from "./view-styles.js";
3 |
4 | const logo = new URL("../assets/open-wc-logo.svg", import.meta.url).href;
5 |
6 | export class MinimalSetup extends LitElement {
7 | static get properties() {
8 | return {
9 | title: { type: String },
10 | };
11 | }
12 |
13 | static get styles() {
14 | return viewStyles;
15 | }
16 |
17 | constructor() {
18 | super();
19 | this.title = "Welcome to the minimal demo";
20 | }
21 |
22 | render() {
23 | return html`
24 |
25 |
26 | ${this.title}
27 |
28 |
34 |
35 | `;
36 | }
37 | }
38 |
39 | customElements.define("minimal-setup", MinimalSetup);
40 |
--------------------------------------------------------------------------------
/examples/minimal-setup/src/routing.js:
--------------------------------------------------------------------------------
1 | import { SimplrRouter } from "@simplr-wc/router";
2 | import "./minimal-setup.js";
3 | import "./example-view.js";
4 | import "./dynamic-view.js";
5 |
6 | const routes = [
7 | { path: "", component: "minimal-setup" },
8 | { path: "example", component: "example-view", name: "Example" },
9 | { path: "dynamic/:id", component: "dynamic-view" },
10 | ];
11 |
12 | new SimplrRouter({ routes }).init();
13 |
--------------------------------------------------------------------------------
/examples/minimal-setup/src/view-styles.js:
--------------------------------------------------------------------------------
1 | import { css } from "lit";
2 |
3 | export const viewStyles = css`
4 | :host {
5 | min-height: 100vh;
6 | display: flex;
7 | flex-direction: column;
8 | align-items: center;
9 | justify-content: flex-start;
10 | font-size: calc(10px + 2vmin);
11 | color: #1a2b42;
12 | max-width: 960px;
13 | margin: 0 auto;
14 | text-align: center;
15 | background-color: var(--minimal-setup-background-color);
16 | }
17 |
18 | main {
19 | flex-grow: 1;
20 | }
21 |
22 | .logo {
23 | margin-top: 36px;
24 | animation: app-logo-spin infinite 20s linear;
25 | }
26 |
27 | @keyframes app-logo-spin {
28 | from {
29 | transform: rotate(0deg);
30 | }
31 | to {
32 | transform: rotate(360deg);
33 | }
34 | }
35 |
36 | .app-footer {
37 | font-size: calc(12px + 0.5vmin);
38 | align-items: center;
39 | }
40 |
41 | .app-footer a {
42 | margin-left: 5px;
43 | }
44 | `;
45 |
--------------------------------------------------------------------------------
/examples/minimal-setup/web-dev-server.config.mjs:
--------------------------------------------------------------------------------
1 | // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2 |
3 | /** Use Hot Module replacement by adding --hmr to the start command */
4 | const hmr = process.argv.includes('--hmr');
5 |
6 | export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7 | open: '/',
8 | watch: !hmr,
9 | /** Resolve bare module imports */
10 | nodeResolve: {
11 | exportConditions: ['browser', 'development'],
12 | },
13 |
14 | /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
15 | // esbuildTarget: 'auto'
16 |
17 | /** Set appIndex to enable SPA routing */
18 | appIndex: 'index.html',
19 |
20 | plugins: [
21 | /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
22 | // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
23 | ],
24 |
25 | // See documentation for all available options
26 | });
27 |
--------------------------------------------------------------------------------
/examples/router-demo/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 |
8 | [*]
9 |
10 | # Change these settings to your own preference
11 | indent_style = space
12 | indent_size = 2
13 |
14 | # We recommend you to keep these unchanged
15 | end_of_line = lf
16 | charset = utf-8
17 | trim_trailing_whitespace = true
18 | insert_final_newline = true
19 |
20 | [*.md]
21 | trim_trailing_whitespace = false
22 |
23 | [*.json]
24 | indent_size = 2
25 |
26 | [*.{html,js,md}]
27 | block_comment_start = /**
28 | block_comment = *
29 | block_comment_end = */
30 |
--------------------------------------------------------------------------------
/examples/router-demo/.gitignore:
--------------------------------------------------------------------------------
1 | ## editors
2 | /.idea
3 | /.vscode
4 |
5 | ## system files
6 | .DS_Store
7 |
8 | ## npm
9 | /node_modules/
10 | /npm-debug.log
11 |
12 | ## testing
13 | /coverage/
14 |
15 | ## temp folders
16 | /.tmp/
17 |
18 | # build
19 | /_site/
20 | /dist/
21 | /out-tsc/
22 |
23 | storybook-static
24 | custom-elements.json
25 |
--------------------------------------------------------------------------------
/examples/router-demo/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 router-demo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/examples/router-demo/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ## Open-wc Starter App
6 |
7 | [](https://github.com/open-wc)
8 |
9 | ## Quickstart
10 |
11 | To get started:
12 |
13 | ```bash
14 | npm init @open-wc
15 | # requires node 10 & npm 6 or higher
16 | ```
17 |
18 | ## Scripts
19 |
20 | - `start` runs your app for development, reloading on file changes
21 | - `start:build` runs your app after it has been built using the build command
22 | - `build` builds your app and outputs it in your `dist` directory
23 | - `test` runs your test suite with Web Test Runner
24 | - `lint` runs the linter for your project
25 | - `format` fixes linting and formatting errors
26 |
27 | ## Tooling configs
28 |
29 | For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
30 |
31 | If you customize the configuration a lot, you can consider moving them to individual files.
32 |
--------------------------------------------------------------------------------
/examples/router-demo/assets/open-wc-logo.svg:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/router-demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
12 |
26 | router-demo
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/examples/router-demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "router-demo",
3 | "description": "Webcomponent router-demo following open-wc recommendations",
4 | "license": "MIT",
5 | "author": "router-demo",
6 | "version": "0.0.0",
7 | "scripts": {
8 | "analyze": "cem analyze --litelement",
9 | "start": "web-dev-server"
10 | },
11 | "dependencies": {
12 | "@simplr-wc/router": "file:../../lib",
13 | "lit": "^2.0.2"
14 | },
15 | "devDependencies": {
16 | "@custom-elements-manifest/analyzer": "^0.4.17",
17 | "@web/dev-server": "^0.1.25"
18 | },
19 | "customElements": "custom-elements.json"
20 | }
21 |
--------------------------------------------------------------------------------
/examples/router-demo/src/RouterDemo.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from 'lit';
2 |
3 | const logo = new URL('../assets/open-wc-logo.svg', import.meta.url).href;
4 |
5 | export class RouterDemo extends LitElement {
6 | static get properties() {
7 | return {
8 | title: { type: String },
9 | };
10 | }
11 |
12 | static get styles() {
13 | return css`
14 | :host {
15 | min-height: 100vh;
16 | display: flex;
17 | flex-direction: column;
18 | align-items: center;
19 | justify-content: flex-start;
20 | font-size: calc(10px + 2vmin);
21 | color: #1a2b42;
22 | max-width: 960px;
23 | margin: 0 auto;
24 | text-align: center;
25 | background-color: var(--router-demo-background-color);
26 | }
27 |
28 | main {
29 | flex-grow: 1;
30 | }
31 |
32 | .logo {
33 | margin-top: 36px;
34 | animation: app-logo-spin infinite 20s linear;
35 | }
36 |
37 | @keyframes app-logo-spin {
38 | from {
39 | transform: rotate(0deg);
40 | }
41 | to {
42 | transform: rotate(360deg);
43 | }
44 | }
45 |
46 | .app-footer {
47 | font-size: calc(12px + 0.5vmin);
48 | align-items: center;
49 | }
50 |
51 | .app-footer a {
52 | margin-left: 5px;
53 | }
54 | `;
55 | }
56 |
57 | constructor() {
58 | super();
59 | this.title = 'My app';
60 | }
61 |
62 | render() {
63 | return html`
64 |
65 |
66 |
67 | ${this.title}
68 |
69 | Press here to navigate to the users
70 | Press here to navigate to the example page
71 | Hash
72 |
73 | `;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/examples/router-demo/src/forbidden-view.js:
--------------------------------------------------------------------------------
1 | import { html, LitElement } from "lit";
2 |
3 | export class ForbiddenView extends LitElement {
4 |
5 | render() {
6 | return html`You do not have the authority to access this page
`
7 | }
8 | }
9 |
10 | customElements.define("forbidden-view", ForbiddenView);
11 |
--------------------------------------------------------------------------------
/examples/router-demo/src/not-found-view.js:
--------------------------------------------------------------------------------
1 | import { html, LitElement } from "lit";
2 |
3 | export class NotFoundView extends LitElement {
4 |
5 | render() {
6 | return html`The view you tried to access was not found
`
7 | }
8 | }
9 |
10 | customElements.define("not-found-view", NotFoundView);
11 |
--------------------------------------------------------------------------------
/examples/router-demo/src/param-example.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from "lit";
2 | import { getBreadcrumbs } from "@simplr-wc/router";
3 |
4 | const logo = new URL("../assets/open-wc-logo.svg", import.meta.url).href;
5 |
6 | export class ParamExample extends LitElement {
7 | static get properties() {
8 | return {
9 | title: { type: String },
10 | };
11 | }
12 |
13 | static get styles() {
14 | return css`
15 | :host {
16 | min-height: 100vh;
17 | display: flex;
18 | flex-direction: column;
19 | align-items: center;
20 | justify-content: flex-start;
21 | font-size: calc(10px + 2vmin);
22 | color: #1a2b42;
23 | max-width: 960px;
24 | margin: 0 auto;
25 | text-align: center;
26 | background-color: var(--router-demo-background-color);
27 | }
28 |
29 | main {
30 | flex-grow: 1;
31 | }
32 |
33 | .logo {
34 | margin-top: 36px;
35 | animation: app-logo-spin infinite 20s linear;
36 | }
37 |
38 | @keyframes app-logo-spin {
39 | from {
40 | transform: rotate(0deg);
41 | }
42 | to {
43 | transform: rotate(360deg);
44 | }
45 | }
46 |
47 | .app-footer {
48 | font-size: calc(12px + 0.5vmin);
49 | align-items: center;
50 | }
51 |
52 | .app-footer a {
53 | margin-left: 5px;
54 | }
55 | `;
56 | }
57 |
58 | constructor() {
59 | super();
60 | this.title = "Welcome to the param example";
61 | }
62 |
63 | renderBreadcrumbs() {
64 | const breadcrumbs = getBreadcrumbs();
65 | return html`${breadcrumbs.map(
66 | (bc) =>
67 | html`${bc.name}${bc.params
69 | ? html`(Params: ${JSON.stringify(bc.params)})`
70 | : ""}
72 | / `
73 | )}`;
74 | }
75 |
76 | render() {
77 | return html`
78 |
79 |
80 | ${this.title}
81 |
82 |
83 | This parameter was acquired from the URL: ${this.id}. Try changing it
84 | and see it change here too.
85 |
86 |
87 | You can find the application breadcrumbs below:
88 | ${this.renderBreadcrumbs()}
89 |
90 | `;
91 | }
92 | }
93 |
94 | customElements.define("param-example", ParamExample);
95 |
--------------------------------------------------------------------------------
/examples/router-demo/src/pattern-example.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from "lit";
2 | import { getBreadcrumbs } from "@simplr-wc/router";
3 |
4 | const logo = new URL("../assets/open-wc-logo.svg", import.meta.url).href;
5 |
6 | export class PatternExample extends LitElement {
7 | static get properties() {
8 | return {
9 | title: { type: String },
10 | };
11 | }
12 |
13 | static get styles() {
14 | return css`
15 | :host {
16 | min-height: 100vh;
17 | display: flex;
18 | flex-direction: column;
19 | align-items: center;
20 | justify-content: flex-start;
21 | font-size: calc(10px + 2vmin);
22 | color: #1a2b42;
23 | max-width: 960px;
24 | margin: 0 auto;
25 | text-align: center;
26 | background-color: var(--router-demo-background-color);
27 | }
28 |
29 | main {
30 | flex-grow: 1;
31 | }
32 |
33 | .logo {
34 | margin-top: 36px;
35 | animation: app-logo-spin infinite 20s linear;
36 | }
37 |
38 | @keyframes app-logo-spin {
39 | from {
40 | transform: rotate(0deg);
41 | }
42 | to {
43 | transform: rotate(360deg);
44 | }
45 | }
46 |
47 | .app-footer {
48 | font-size: calc(12px + 0.5vmin);
49 | align-items: center;
50 | }
51 |
52 | .app-footer a {
53 | margin-left: 5px;
54 | }
55 | `;
56 | }
57 |
58 | constructor() {
59 | super();
60 | this.title = "Welcome to the param example";
61 | }
62 |
63 | renderBreadcrumbs() {
64 | const breadcrumbs = getBreadcrumbs();
65 | return html`${breadcrumbs.map(
66 | (bc) =>
67 | html`${bc.name}${bc.params
69 | ? html`(Params: ${JSON.stringify(bc.params)})`
70 | : ""}
72 | / `
73 | )}`;
74 | }
75 |
76 | render() {
77 | return html`
78 |
79 |
80 | ${this.title}
81 |
82 | Params from url:
83 | ID: ${this.id}
84 | word: ${this.word}
85 |
86 | You can find the application breadcrumbs below:
87 | ${this.renderBreadcrumbs()}
88 |
89 | `;
90 | }
91 | }
92 |
93 | customElements.define("pattern-example", PatternExample);
94 |
--------------------------------------------------------------------------------
/examples/router-demo/src/pattern-with-name-example.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from "lit";
2 | import { getBreadcrumbs } from "@simplr-wc/router";
3 |
4 | const logo = new URL("../assets/open-wc-logo.svg", import.meta.url).href;
5 |
6 | export class PatternWithNameExample extends LitElement {
7 | static get properties() {
8 | return {
9 | title: { type: String },
10 | };
11 | }
12 |
13 | static get styles() {
14 | return css`
15 | :host {
16 | min-height: 100vh;
17 | display: flex;
18 | flex-direction: column;
19 | align-items: center;
20 | justify-content: flex-start;
21 | font-size: calc(10px + 2vmin);
22 | color: #1a2b42;
23 | max-width: 960px;
24 | margin: 0 auto;
25 | text-align: center;
26 | background-color: var(--router-demo-background-color);
27 | }
28 |
29 | main {
30 | flex-grow: 1;
31 | }
32 |
33 | .logo {
34 | margin-top: 36px;
35 | animation: app-logo-spin infinite 20s linear;
36 | }
37 |
38 | @keyframes app-logo-spin {
39 | from {
40 | transform: rotate(0deg);
41 | }
42 | to {
43 | transform: rotate(360deg);
44 | }
45 | }
46 |
47 | .app-footer {
48 | font-size: calc(12px + 0.5vmin);
49 | align-items: center;
50 | }
51 |
52 | .app-footer a {
53 | margin-left: 5px;
54 | }
55 | `;
56 | }
57 |
58 | constructor() {
59 | super();
60 | this.title = "Welcome to the param example";
61 | }
62 |
63 | renderBreadcrumbs() {
64 | const breadcrumbs = getBreadcrumbs();
65 | return html`${breadcrumbs.map(
66 | (bc) =>
67 | html`${bc.name}${bc.params
69 | ? html`(Params: ${JSON.stringify(bc.params)})`
70 | : ""}
72 | / `
73 | )}`;
74 | }
75 |
76 | render() {
77 | return html`
78 |
79 |
80 | ${this.title}
81 |
82 | Params from url:
83 | ID: ${this.id}
84 | name: ${this.name}
85 |
86 | You can find the application breadcrumbs below:
87 | ${this.renderBreadcrumbs()}
88 |
89 | `;
90 | }
91 | }
92 |
93 | customElements.define("pattern-with-name-example", PatternWithNameExample);
94 |
--------------------------------------------------------------------------------
/examples/router-demo/src/prevent-example.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from 'lit';
2 | import { getBreadcrumbs } from "@simplr-wc/router";
3 |
4 | const logo = new URL('../assets/open-wc-logo.svg', import.meta.url).href;
5 |
6 | export class PreventExample extends LitElement {
7 | static get properties() {
8 | return {
9 | title: { type: String },
10 | };
11 | }
12 |
13 | static get styles() {
14 | return css`
15 | :host {
16 | min-height: 100vh;
17 | display: flex;
18 | flex-direction: column;
19 | align-items: center;
20 | justify-content: flex-start;
21 | font-size: calc(10px + 2vmin);
22 | color: #1a2b42;
23 | max-width: 960px;
24 | margin: 0 auto;
25 | text-align: center;
26 | background-color: var(--router-demo-background-color);
27 | }
28 |
29 | main {
30 | flex-grow: 1;
31 | }
32 |
33 | .logo {
34 | margin-top: 36px;
35 | animation: app-logo-spin infinite 20s linear;
36 | }
37 |
38 | @keyframes app-logo-spin {
39 | from {
40 | transform: rotate(0deg);
41 | }
42 | to {
43 | transform: rotate(360deg);
44 | }
45 | }
46 |
47 | .app-footer {
48 | font-size: calc(12px + 0.5vmin);
49 | align-items: center;
50 | }
51 |
52 | .app-footer a {
53 | margin-left: 5px;
54 | }
55 | `;
56 | }
57 |
58 | constructor() {
59 | super();
60 | this.title = "This page will alert you as you're about to leave it";
61 | }
62 |
63 | renderBreadcrumbs() {
64 | const breadcrumbs = getBreadcrumbs();
65 | return html`${breadcrumbs.map(bc => html`${bc.name} / `)}`
66 | }
67 |
68 | render() {
69 | return html`
70 |
71 |
72 | ${this.title}
73 |
74 | Go to parametrized url
75 |
76 | You can find the application breadcrumbs below:
77 | ${this.renderBreadcrumbs()}
78 | `;
79 | }
80 | }
81 |
82 | customElements.define("prevent-example", PreventExample);
83 |
--------------------------------------------------------------------------------
/examples/router-demo/src/regular-top-bar.js:
--------------------------------------------------------------------------------
1 | import { html, LitElement } from "lit";
2 |
3 | export class RegularTopBar extends LitElement {
4 | render() {
5 | return html`This is the regular top bar
`;
6 | }
7 | }
8 |
9 | customElements.define("regular-top-bar", RegularTopBar);
10 |
--------------------------------------------------------------------------------
/examples/router-demo/src/special-top-bar.js:
--------------------------------------------------------------------------------
1 | import { html, LitElement } from "lit";
2 |
3 | export class SpecialTopBar extends LitElement {
4 | render() {
5 | return html`This is the special top bar
`;
6 | }
7 | }
8 |
9 | customElements.define("special-top-bar", SpecialTopBar);
10 |
--------------------------------------------------------------------------------
/examples/router-demo/src/user-add-view.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html } from "lit";
2 |
3 | export class UserAddView extends LitElement {
4 | static get properties() {
5 | return {
6 | userId: { type: Number },
7 | };
8 | }
9 |
10 | render() {
11 | return html`
12 |
13 | You can't add any more users at the moment
14 | Go back
15 |
16 | `;
17 | }
18 | }
19 |
20 | customElements.define("user-add-view", UserAddView);
21 |
--------------------------------------------------------------------------------
/examples/router-demo/src/user-edit-view.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html } from "lit";
2 |
3 | export class UserEditView extends LitElement {
4 | static get properties() {
5 | return {
6 | userId: { type: Number },
7 | };
8 | }
9 |
10 | render() {
11 | return html`
12 |
13 | Editing users is not permitted at the moment
14 |
15 | `;
16 | }
17 | }
18 |
19 | customElements.define("user-edit-view", UserEditView);
20 |
--------------------------------------------------------------------------------
/examples/router-demo/src/user-profile-view.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html } from "lit";
2 |
3 | export class UserProfileView extends LitElement {
4 | static get properties() {
5 | return {
6 | userId: { type: Number },
7 | };
8 | }
9 |
10 | render() {
11 | return html`
12 |
13 |
14 |
This is the page of user ${this.userId}
15 |
Edit
16 |
Go back
17 |
18 | And the second here
20 |
21 |
22 |
23 | `;
24 | }
25 | }
26 |
27 | customElements.define("user-profile-view", UserProfileView);
28 |
--------------------------------------------------------------------------------
/examples/router-demo/src/users-list-view.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html } from "lit";
2 |
3 | export class UsersListView extends LitElement {
4 | render() {
5 | return html`
6 |
7 | Users list
8 |
13 |
14 | Add new user
15 |
16 | `;
17 | }
18 | }
19 |
20 | customElements.define("users-list-view", UsersListView);
21 |
--------------------------------------------------------------------------------
/examples/router-demo/src/users-view.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from "lit";
2 | import { getBreadcrumbs } from "@simplr-wc/router";
3 |
4 | const logo = new URL("../assets/open-wc-logo.svg", import.meta.url).href;
5 |
6 | export class UsersView extends LitElement {
7 | static get properties() {
8 | return {
9 | title: { type: String },
10 | };
11 | }
12 |
13 | static get styles() {
14 | return css`
15 | :host {
16 | min-height: 100vh;
17 | display: flex;
18 | flex-direction: column;
19 | align-items: center;
20 | justify-content: flex-start;
21 | font-size: calc(10px + 2vmin);
22 | color: #1a2b42;
23 | max-width: 960px;
24 | margin: 0 auto;
25 | text-align: center;
26 | background-color: var(--router-demo-background-color);
27 | }
28 |
29 | main {
30 | flex-grow: 1;
31 | }
32 |
33 | .logo {
34 | margin-top: 36px;
35 | animation: app-logo-spin infinite 20s linear;
36 | }
37 |
38 | @keyframes app-logo-spin {
39 | from {
40 | transform: rotate(0deg);
41 | }
42 | to {
43 | transform: rotate(360deg);
44 | }
45 | }
46 |
47 | .app-footer {
48 | font-size: calc(12px + 0.5vmin);
49 | align-items: center;
50 | }
51 |
52 | .app-footer a {
53 | margin-left: 5px;
54 | }
55 | `;
56 | }
57 |
58 | constructor() {
59 | super();
60 | this.title = "Nested routes";
61 | }
62 |
63 | render() {
64 | return html`
65 |
66 |
67 | ${this.title}
68 | Back to home page
69 |
70 |
71 |
First subview will come here
72 |
73 |
74 |
75 | `;
76 | }
77 | }
78 |
79 | customElements.define("users-view", UsersView);
80 |
--------------------------------------------------------------------------------
/examples/router-demo/web-dev-server.config.mjs:
--------------------------------------------------------------------------------
1 | // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2 |
3 | /** Use Hot Module replacement by adding --hmr to the start command */
4 | const hmr = process.argv.includes('--hmr');
5 |
6 | export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7 | open: '/',
8 | watch: !hmr,
9 | /** Resolve bare module imports */
10 | nodeResolve: {
11 | exportConditions: ['browser', 'development'],
12 | },
13 |
14 | /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
15 | // esbuildTarget: 'auto'
16 |
17 | /** Set appIndex to enable SPA routing */
18 | appIndex: 'index.html',
19 |
20 | plugins: [
21 | /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
22 | // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
23 | ],
24 |
25 | // See documentation for all available options
26 | });
27 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 |
8 | [*]
9 |
10 | # Change these settings to your own preference
11 | indent_style = space
12 | indent_size = 2
13 |
14 | # We recommend you to keep these unchanged
15 | end_of_line = lf
16 | charset = utf-8
17 | trim_trailing_whitespace = true
18 | insert_final_newline = true
19 |
20 | [*.md]
21 | trim_trailing_whitespace = false
22 |
23 | [*.json]
24 | indent_size = 2
25 |
26 | [*.{html,js,md}]
27 | block_comment_start = /**
28 | block_comment = *
29 | block_comment_end = */
30 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/.gitignore:
--------------------------------------------------------------------------------
1 | ## editors
2 | /.idea
3 | /.vscode
4 |
5 | ## system files
6 | .DS_Store
7 |
8 | ## npm
9 | /node_modules/
10 | /npm-debug.log
11 |
12 | ## testing
13 | /coverage/
14 |
15 | ## temp folders
16 | /.tmp/
17 |
18 | # build
19 | /_site/
20 | /dist/
21 | /out-tsc/
22 |
23 | storybook-static
24 | custom-elements.json
25 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 router-demo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/examples/router-outlet-demo/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ## Open-wc Starter App
6 |
7 | [](https://github.com/open-wc)
8 |
9 | ## Quickstart
10 |
11 | To get started:
12 |
13 | ```bash
14 | npm init @open-wc
15 | # requires node 10 & npm 6 or higher
16 | ```
17 |
18 | ## Scripts
19 |
20 | - `start` runs your app for development, reloading on file changes
21 | - `start:build` runs your app after it has been built using the build command
22 | - `build` builds your app and outputs it in your `dist` directory
23 | - `test` runs your test suite with Web Test Runner
24 | - `lint` runs the linter for your project
25 | - `format` fixes linting and formatting errors
26 |
27 | ## Tooling configs
28 |
29 | For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
30 |
31 | If you customize the configuration a lot, you can consider moving them to individual files.
32 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/assets/open-wc-logo.svg:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
19 | router-demo
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "router-demo",
3 | "description": "Webcomponent router-demo following open-wc recommendations",
4 | "license": "MIT",
5 | "author": "router-demo",
6 | "version": "0.0.0",
7 | "scripts": {
8 | "analyze": "cem analyze --litelement",
9 | "start": "web-dev-server"
10 | },
11 | "dependencies": {
12 | "@simplr-wc/router": "file:../../lib",
13 | "lit": "^2.0.2"
14 | },
15 | "devDependencies": {
16 | "@custom-elements-manifest/analyzer": "^0.4.17",
17 | "@web/dev-server": "^0.1.25"
18 | },
19 | "customElements": "custom-elements.json"
20 | }
21 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/src/RouterDemo.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from "lit";
2 |
3 | const logo = new URL("../assets/open-wc-logo.svg", import.meta.url).href;
4 |
5 | export class RouterDemo extends LitElement {
6 | static get properties() {
7 | return {
8 | title: { type: String },
9 | };
10 | }
11 |
12 | static get styles() {
13 | return css`
14 | :host {
15 | min-height: 100vh;
16 | display: flex;
17 | flex-direction: column;
18 | align-items: center;
19 | justify-content: flex-start;
20 | font-size: calc(10px + 2vmin);
21 | color: #1a2b42;
22 | max-width: 960px;
23 | margin: 0 auto;
24 | text-align: center;
25 | background-color: var(--router-demo-background-color);
26 | }
27 |
28 | simplr-router-container {
29 | background: transparent;
30 | opacity: 1;
31 | }
32 |
33 | simplr-router-container[leaving-view],
34 | simplr-router-container[entering-view] {
35 | background: transparent;
36 | opacity: 0;
37 | }
38 |
39 | main {
40 | flex-grow: 1;
41 | height: 100vh;
42 | width: 100%;
43 | }
44 |
45 | .logo {
46 | margin-top: 36px;
47 | animation: app-logo-spin infinite 20s linear;
48 | }
49 |
50 | @keyframes app-logo-spin {
51 | from {
52 | transform: rotate(0deg);
53 | }
54 | to {
55 | transform: rotate(360deg);
56 | }
57 | }
58 |
59 | .app-footer {
60 | font-size: calc(12px + 0.5vmin);
61 | align-items: center;
62 | }
63 |
64 | .app-footer a {
65 | margin-left: 5px;
66 | }
67 | `;
68 | }
69 |
70 | constructor() {
71 | super();
72 | this.title = "My app";
73 | }
74 |
75 | render() {
76 | return html`
77 |
78 |
79 |
80 |
81 | `;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/src/param-example.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from "lit";
2 | import { getBreadcrumbs } from "@simplr-wc/router";
3 |
4 | export class ParamExample extends LitElement {
5 | static get properties() {
6 | return {
7 | title: { type: String },
8 | };
9 | }
10 |
11 | static get styles() {
12 | return css`
13 | :host {
14 | min-height: 100vh;
15 | display: flex;
16 | flex-direction: column;
17 | align-items: center;
18 | justify-content: flex-start;
19 | font-size: calc(10px + 2vmin);
20 | color: #1a2b42;
21 | max-width: 960px;
22 | margin: 0 auto;
23 | text-align: center;
24 | background-color: var(--router-demo-background-color);
25 | }
26 |
27 | main {
28 | flex-grow: 1;
29 | }
30 |
31 | .logo {
32 | margin-top: 36px;
33 | animation: app-logo-spin infinite 20s linear;
34 | }
35 |
36 | @keyframes app-logo-spin {
37 | from {
38 | transform: rotate(0deg);
39 | }
40 | to {
41 | transform: rotate(360deg);
42 | }
43 | }
44 |
45 | .app-footer {
46 | font-size: calc(12px + 0.5vmin);
47 | align-items: center;
48 | }
49 |
50 | .app-footer a {
51 | margin-left: 5px;
52 | }
53 | `;
54 | }
55 |
56 | constructor() {
57 | super();
58 | this.title = "Welcome to the param example";
59 | }
60 |
61 | renderBreadcrumbs() {
62 | const breadcrumbs = getBreadcrumbs();
63 | return html`${breadcrumbs.map(
64 | (bc) =>
65 | html`${bc.name}${bc.params
67 | ? html`(Params: ${JSON.stringify(bc.params)})`
68 | : ""}
70 | / `
71 | )}`;
72 | }
73 |
74 | render() {
75 | return html`
76 |
77 | ${this.title}
78 |
79 |
80 | This parameter was acquired from the URL: ${this.id}. Try changing it
81 | and see it change here too.
82 |
83 |
84 | You can find the application breadcrumbs below:
85 | ${this.renderBreadcrumbs()}
86 |
87 | `;
88 | }
89 | }
90 |
91 | customElements.define("param-example", ParamExample);
92 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/src/router-demo.js:
--------------------------------------------------------------------------------
1 | import { SimplrRouter } from '@simplr-wc/router';
2 | import { RouterDemo } from './RouterDemo.js';
3 |
4 | const routerOptions = {
5 | routes: [
6 | {
7 | name: "Home",
8 | path: "",
9 | component: "router-frontpage",
10 | import: () => import("./router-frontpage.js")
11 | },
12 | {
13 | name: "Example",
14 | path: "example",
15 | component: "router-example",
16 | import: () => import("./router-example.js")
17 | },
18 | {
19 | name: "Parameter",
20 | path: "param/:id",
21 | component: "param-example",
22 | import: () => import("./param-example.js")
23 | }
24 | ],
25 | transitionSpeed: 500
26 | }
27 |
28 | const router = new SimplrRouter(routerOptions);
29 | router.init();
30 |
31 | customElements.define('router-demo', RouterDemo);
32 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/src/router-example.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from "lit";
2 | import { getBreadcrumbs } from "@simplr-wc/router";
3 |
4 | export class RouterExample extends LitElement {
5 | static get properties() {
6 | return {
7 | title: { type: String },
8 | };
9 | }
10 |
11 | static get styles() {
12 | return css`
13 | :host {
14 | min-height: 100vh;
15 | display: flex;
16 | flex-direction: column;
17 | align-items: center;
18 | justify-content: flex-start;
19 | font-size: calc(10px + 2vmin);
20 | color: #1a2b42;
21 | max-width: 960px;
22 | margin: 0 auto;
23 | text-align: center;
24 | background-color: var(--router-demo-background-color);
25 | }
26 |
27 | main {
28 | flex-grow: 1;
29 | }
30 |
31 | .logo {
32 | margin-top: 36px;
33 | animation: app-logo-spin infinite 20s linear;
34 | }
35 |
36 | @keyframes app-logo-spin {
37 | from {
38 | transform: rotate(0deg);
39 | }
40 | to {
41 | transform: rotate(360deg);
42 | }
43 | }
44 |
45 | .app-footer {
46 | font-size: calc(12px + 0.5vmin);
47 | align-items: center;
48 | }
49 |
50 | .app-footer a {
51 | margin-left: 5px;
52 | }
53 | `;
54 | }
55 |
56 | constructor() {
57 | super();
58 | this.title = "Welcome to the routing example";
59 | }
60 |
61 | renderBreadcrumbs() {
62 | const breadcrumbs = getBreadcrumbs();
63 | return html`${breadcrumbs.map(
64 | (bc) => html`${bc.name} / `
65 | )}`;
66 | }
67 |
68 | render() {
69 | return html`
70 |
71 | ${this.title}
72 |
73 | Go to parametrized url
74 |
75 | You can find the application breadcrumbs below:
76 | ${this.renderBreadcrumbs()}
77 |
78 | `;
79 | }
80 | }
81 |
82 | customElements.define("router-example", RouterExample);
83 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/src/router-frontpage.js:
--------------------------------------------------------------------------------
1 | import { LitElement, html, css } from 'lit';
2 |
3 | export class RouterFrontpage extends LitElement {
4 | static get properties() {
5 | return {
6 | title: { type: String },
7 | };
8 | }
9 |
10 | static get styles() {
11 | return css`
12 | :host {
13 | min-height: 100vh;
14 | display: flex;
15 | flex-direction: column;
16 | align-items: center;
17 | justify-content: flex-start;
18 | font-size: calc(10px + 2vmin);
19 | color: #1a2b42;
20 | max-width: 960px;
21 | margin: 0 auto;
22 | text-align: center;
23 | background-color: var(--router-demo-background-color);
24 | }
25 |
26 | main {
27 | flex-grow: 1;
28 | }
29 |
30 | .logo {
31 | margin-top: 36px;
32 | animation: app-logo-spin infinite 20s linear;
33 | }
34 |
35 | .app-footer {
36 | font-size: calc(12px + 0.5vmin);
37 | align-items: center;
38 | }
39 |
40 | .app-footer a {
41 | margin-left: 5px;
42 | }
43 | `;
44 | }
45 |
46 | constructor() {
47 | super();
48 | this.title = 'My app';
49 | }
50 |
51 | render() {
52 | return html`
53 |
54 | ${this.title}
55 |
56 | Go to example url
57 |
58 | You can find the application breadcrumbs below:
59 |
60 | `;
61 | }
62 | }
63 |
64 | customElements.define("router-frontpage", RouterFrontpage);
65 |
--------------------------------------------------------------------------------
/examples/router-outlet-demo/web-dev-server.config.mjs:
--------------------------------------------------------------------------------
1 | // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2 |
3 | /** Use Hot Module replacement by adding --hmr to the start command */
4 | const hmr = process.argv.includes('--hmr');
5 |
6 | export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7 | open: '/',
8 | watch: !hmr,
9 | /** Resolve bare module imports */
10 | nodeResolve: {
11 | exportConditions: ['browser', 'development'],
12 | },
13 |
14 | /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
15 | // esbuildTarget: 'auto'
16 |
17 | /** Set appIndex to enable SPA routing */
18 | appIndex: 'index.html',
19 |
20 | plugins: [
21 | /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
22 | // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
23 | ],
24 |
25 | // See documentation for all available options
26 | });
27 |
--------------------------------------------------------------------------------
/examples/type-testing/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var router_1 = require("@simplr-wc/router");
4 | var options = {};
5 | var router = new router_1.SimplrRouter(options);
6 |
--------------------------------------------------------------------------------
/examples/type-testing/index.ts:
--------------------------------------------------------------------------------
1 | import { SimplrRouter, SimplrRouterOptions } from "@simplr-wc/router";
2 |
3 | const options = {
4 |
5 | } as SimplrRouterOptions;
6 |
7 | const router = new SimplrRouter(options);
8 |
9 |
--------------------------------------------------------------------------------
/examples/type-testing/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "type-testing",
3 | "version": "1.0.0",
4 | "lockfileVersion": 2,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "type-testing",
9 | "version": "1.0.0",
10 | "license": "ISC",
11 | "dependencies": {
12 | "@simplr-wc/router": "file:../../lib",
13 | "tslib": "^2.3.1"
14 | },
15 | "devDependencies": {
16 | "typescript": "^4.5.2"
17 | }
18 | },
19 | "../../lib": {
20 | "name": "@simplr-wc/router",
21 | "version": "7.0.0-rc12",
22 | "license": "ISC"
23 | },
24 | "node_modules/@simplr-wc/router": {
25 | "resolved": "../../lib",
26 | "link": true
27 | },
28 | "node_modules/tslib": {
29 | "version": "2.3.1",
30 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
31 | "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
32 | },
33 | "node_modules/typescript": {
34 | "version": "4.5.2",
35 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz",
36 | "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==",
37 | "dev": true,
38 | "bin": {
39 | "tsc": "bin/tsc",
40 | "tsserver": "bin/tsserver"
41 | },
42 | "engines": {
43 | "node": ">=4.2.0"
44 | }
45 | }
46 | },
47 | "dependencies": {
48 | "@simplr-wc/router": {
49 | "version": "file:../../lib"
50 | },
51 | "tslib": {
52 | "version": "2.3.1",
53 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
54 | "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
55 | },
56 | "typescript": {
57 | "version": "4.5.2",
58 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz",
59 | "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==",
60 | "dev": true
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/examples/type-testing/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "type-testing",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "@simplr-wc/router": "file:../../lib",
14 | "tslib": "^2.3.1"
15 | },
16 | "devDependencies": {
17 | "typescript": "^4.5.2"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/examples/type-testing/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "esModuleInterop": true,
7 | "skipLibCheck": true,
8 | "forceConsistentCasingInFileNames": true
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 | Simplr Router
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/lib/.gitignore:
--------------------------------------------------------------------------------
1 | *.d.ts
2 |
--------------------------------------------------------------------------------
/lib/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .prettierrc.json
3 |
--------------------------------------------------------------------------------
/lib/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "trailingComma": "es5",
3 | "tabWidth": 4,
4 | "printWidth": 120,
5 | "semi": true,
6 | "singleQuote": true,
7 | "proseWrap": "never"
8 | }
9 |
--------------------------------------------------------------------------------
/lib/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | [](https://www.npmjs.com/package/@simplr-wc/router)
4 |
5 | # Simplr Router
6 |
7 | A small and effective routing solution for Web Components.
8 |
9 | ## Getting started
10 |
11 | Get started using Simplr Router with [one of the guides from the documentation site](https://simplr.github.io/simplr-router/guides/getting-started/using-a-starter/)
12 |
13 | ```javascript
14 | import { SimplrRouter } from "@simplr-wc/router";
15 |
16 | const routes = [
17 | { path: "", component: "minimal-setup" },
18 | { path: "example", component: "example-view" },
19 | { path: "dynamic/:id", component: "dynamic-view" },
20 | ];
21 |
22 | new SimplrRouter({ routes }).init();
23 | ```
24 |
25 | ## Why
26 |
27 | #### Quick and Simple
28 |
29 | Simple to get up and running. Basic setup in just a few lines of code.
30 |
31 | #### Small
32 |
33 | No dependencies and a small codebase means less breaking parts.
34 | 0 dependencies means that what you see is what you get.
35 |
36 | #### Easy to transition into
37 |
38 | Works by utilizing the native API's used for navigation and therefore doesn't require any extra steps compared to your every day MPA.
39 |
40 | #### Web Component focused
41 |
42 | Built with web components, for web components. Simplr Router was designed from the get go to be used in web component applications.
43 |
44 | #### Customizable
45 |
46 | Even though there's no configuration necessary to get started, the router ships with a lot of customizability to fit your needs.
47 |
48 |
49 | #### Performant
50 |
51 | Allowing for lazy loading and creating dynamic routes, Simplr Router is a great library for projects of all sizes.
52 | Discover
53 |
--------------------------------------------------------------------------------
/lib/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "esnext",
4 | "target": "esnext",
5 | "checkJs": true,
6 | "moduleResolution": "node"
7 | },
8 | "exclude": ["node_modules"]
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/lib/modules/config.js:
--------------------------------------------------------------------------------
1 | export class Config {
2 | /**
3 | * @param {import("../types/SimplrRouterOptions").SimplrRouterOptions} options
4 | */
5 | constructor(options) {
6 | this._parseOptions(options);
7 | }
8 |
9 | /**
10 | * @param {import("../types/SimplrRouterOptions").SimplrRouterOptions} options
11 | */
12 | _parseOptions(options) {
13 | this.routes = options.routes;
14 | this.rootPath = options.rootPath;
15 | this.debugging = options.debugging;
16 | this.transitionSpeed = options.transitionSpeed == null ? 0 : options.transitionSpeed;
17 | this.notFoundAction = options.notFoundAction;
18 | this.forbiddenAction = options.forbiddenAction;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/lib/modules/deepquery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @returns {Element}
3 | * */
4 | export function findOutlet() {
5 | const outlet = deepQuery('simplr-router-outlet');
6 | return outlet;
7 | }
8 |
9 | /**
10 | * @param {string} target
11 | * @param {Element | ShadowRoot} [dom]
12 | *
13 | * @returns {Element}
14 | */
15 | export function deepQuery(target, dom = document.body) {
16 | let foundItem = dom.querySelector(target);
17 | if (foundItem) return foundItem;
18 | for (const el of dom.querySelectorAll('*')) {
19 | if (el.shadowRoot) {
20 | foundItem = deepQuery(target, el.shadowRoot);
21 | if (foundItem) break;
22 | }
23 | }
24 | return foundItem;
25 | }
26 |
--------------------------------------------------------------------------------
/lib/modules/dispatcher.js:
--------------------------------------------------------------------------------
1 | export function sendTransitionStartEvent(view) {
2 | sendEvent(new CustomEvent('simplr-router-transition-start', { detail: { view } }));
3 | }
4 |
5 | export function sendTransitionFinishEvent() {
6 | sendEvent(new CustomEvent('simplr-router-transition-end'));
7 | }
8 |
9 | export function sendRouterInitializedEvent(routes) {
10 | sendEvent(new CustomEvent('simplr-router-initialized', { detail: { routes } }));
11 | }
12 |
13 | export function sendNavigatedEvent(view, historyPath) {
14 | sendEvent(new CustomEvent('simplr-router-navigated', { detail: { view, historyPath } }));
15 | }
16 |
17 | function sendEvent(event) {
18 | window.dispatchEvent(event);
19 | }
20 |
--------------------------------------------------------------------------------
/lib/modules/helper.js:
--------------------------------------------------------------------------------
1 | export const getEventPath = (event) => event.path || (event.composedPath && event.composedPath());
2 |
3 | /**
4 | * @augments SimplrRouterNavigationData
5 | */
6 | export class ForwardsTransitionObject {
7 | /**
8 | * @returns {import("../types/Shared").SimplrRouterNavigationData} view
9 | * @param {import("../types/Shared").SimplrRouterNavigationData} view
10 | */
11 | static from(view) {
12 | return {
13 | ...view,
14 | backwards: false,
15 | initialView: false,
16 | };
17 | }
18 | }
19 |
20 | export class BackwardsTransitionObject {
21 | /**
22 | * @returns {import("../types/Shared").SimplrRouterNavigationData} view
23 | * @param {import("../types/Shared").SimplrRouterNavigationData} view
24 | */
25 | static from(view) {
26 | return {
27 | ...view,
28 | backwards: true,
29 | initialView: false,
30 | };
31 | }
32 | }
33 |
34 | export class InitialTransitionObject {
35 | /**
36 | * @returns {import("../types/Shared").SimplrRouterNavigationData} view
37 | * @param {import("../types/Shared").SimplrRouterNavigationData} view
38 | */
39 | static from(view) {
40 | return {
41 | ...view,
42 | backwards: false,
43 | initialView: true,
44 | };
45 | }
46 | }
47 |
48 | export const updateHistory = (path) => window.history.pushState(null, '', path);
49 |
--------------------------------------------------------------------------------
/lib/modules/observer.js:
--------------------------------------------------------------------------------
1 | import { SimplrRouter } from '../simplr-router';
2 | import { getEventPath, ForwardsTransitionObject, BackwardsTransitionObject } from './helper';
3 |
4 | export class Observer {
5 | /**
6 | * @param {import('../types/Shared').ObserverFunctions} functions
7 | */
8 | constructor(functions) {
9 | this._setAnchorListener(functions);
10 | this._setReturnActionListeners(functions);
11 | }
12 |
13 | /**
14 | * @param {import('../types/Shared').ObserverFunctions} functions
15 | */
16 | _setAnchorListener(functions) {
17 | document.body.addEventListener('click', (e) => {
18 | const path = getEventPath(e);
19 | let target = path.shift();
20 | const origin = window.location.origin;
21 | do {
22 | if (target.href) {
23 | const targetSplit = target.href.replace(origin, '').split("#");
24 | const targetHref = targetSplit[0];
25 | const hash = targetSplit.length > 1 ? "#" + targetSplit[1] : "";
26 | const newView = functions.findViewForRoute(targetHref);
27 | if (newView) {
28 | e.preventDefault();
29 | const fullTargetPath = targetHref + hash;
30 | if (targetHref === SimplrRouter._instance.getCurrentView().path) {
31 | break;
32 | }
33 | functions.changeView(ForwardsTransitionObject.from(newView), fullTargetPath);
34 | break;
35 | }
36 | }
37 | } while ((target = path.shift()));
38 | });
39 | }
40 |
41 | /**
42 | * @param {import('../types/Shared').ObserverFunctions} functions
43 | */
44 | _setReturnActionListeners(functions) {
45 | window.addEventListener('popstate', () => {
46 | const newView = functions.getViewFromUrl();
47 | functions.changeView(BackwardsTransitionObject.from(newView));
48 | });
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/lib/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@simplr-wc/router",
3 | "version": "7.0.0-rc2",
4 | "lockfileVersion": 2,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "@simplr-wc/router",
9 | "version": "7.0.0-rc2",
10 | "license": "ISC"
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/lib/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@simplr-wc/router",
3 | "version": "7.0.0-rc19",
4 | "keywords": [
5 | "javascript",
6 | "routing",
7 | "vanilla",
8 | "webcomponents",
9 | "preact",
10 | "react",
11 | "router",
12 | "simplr"
13 | ],
14 | "description": "Simplr Router is a routing solution for the Web providing a seamless SPA experience with minimal setup.",
15 | "homepage": "https://router.matsu.fi/",
16 | "repository": {
17 | "type": "git",
18 | "url": "https://github.com/Simplr/simplr-router"
19 | },
20 | "types": "./simplr-router.d.ts",
21 | "main": "simplr-router.js",
22 | "scripts": {
23 | "clean-types": "rm -rf ./*.d.ts && rm -rf ./modules/*.d.ts && rm -rf ./types/*.d.ts",
24 | "types": "npm run clean-types && npx -p typescript tsc ./**/*.js --declaration --allowJs --emitDeclarationOnly"
25 | },
26 | "author": "Matsuuu (https://matsu.fi/)",
27 | "license": "ISC"
28 | }
29 |
--------------------------------------------------------------------------------
/lib/types/Shared.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @typedef ChangeViewObject
3 | * @property {string} [path]
4 | * @property {string} [name]
5 | * @property {string} [hash]
6 | * */
7 |
8 | /**
9 | * @typedef SimplrRouterNavigationDataProps
10 | *
11 | * @property { string } [realPath] The original determined path of the route
12 | * @property { string[] } [parts] String parts of the parsed route
13 | * @property { Object. } [params] Dynamic parts of the route mapped
14 | * @property { boolean } backwards If the navigation is being done backwards in history
15 | * @property { boolean } initialView If this is the initial view loaded first on load instead of navigation
16 | * @property { SimplrRouterBreadcrumb[] } crumbs The breadcrumbs to the current path
17 | * @property { SimplrRouterNavigationData } [nestedParent] The parent view of a nested route
18 | * @property { Object. } [properties] Properties to be passed to the view component
19 | *
20 | * @typedef { import("./SimplrRoute").SimplrRoute & SimplrRouterNavigationDataProps } SimplrRouterNavigationData
21 | * */
22 |
23 | /**
24 | * @typedef SimplrRouterBreadcrumb
25 | * @property {string} path
26 | * @property {string} [name]
27 | * @property {Object.} [params]
28 | * */
29 |
30 | /**
31 | * @typedef ObserverFunctions
32 | * @property { Function } findViewForRoute
33 | * @property { Function } changeView
34 | * @property { Function } getViewFromUrl
35 | * */
36 |
37 | export const _shared = {};
38 |
--------------------------------------------------------------------------------
/lib/types/SimplrRoute.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @typedef SimplrRoute
3 | * @property { string } path The URL path for the route
4 | * @property { string } [component] The view component name for the route
5 | * @property { string } [name] Name of the view route
6 | * @property { Function } [import] An import function for lazy loading. e.g. () => import("./my-view.js")
7 | * @property { Function } [guard] A guard function to check view access
8 | * @property { SimplrRoute[] } [routes] An array of subroutes that inherit paths from the parent route
9 | * @property { SimplrRoute[] } [children] An array of nested routes that are rendered inside a nested router outlet
10 | * @property { Object.[] } [slots] An array of slots to append to the view component
11 | * @property { Object. } [pattern] RegExp pattern to match dynamic route keys
12 | * @property { string | {name: string} } [redirect] Path to redirect to
13 | * @property { boolean } [preventUnload] If navigation from this page should be prevented with a confirmation dialog
14 | * */
15 |
16 | export const _route = {}
17 |
--------------------------------------------------------------------------------
/lib/types/SimplrRouterOptions.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @typedef SimplrRouterOptions
3 | * @property { import("./SimplrRoute").SimplrRoute[] } routes Routes provided for the Simplr Router.
4 | * @property { string } [rootPath] Root path of the router. If the root is not the origin of the host.
5 | * @property { number } [transitionSpeed] Transition speed of view transitions in milliseconds.
6 | * @property { Function } [notFoundAction] Action triggered when a view is not found.
7 | * @property { Function } [forbiddenAction] Action triggered when access to a view is forbidden by a guard function.
8 | * @property { boolean } [debugging] Enable debugging
9 | * */
10 |
11 | export const _routerOptions = {};
12 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo",
3 | "version": "1.0.0",
4 | "lockfileVersion": 2,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "demo",
9 | "version": "1.0.0",
10 | "license": "ISC"
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "demo",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "cd examples/router-demo && npm start",
8 | "start:outlet": "cd examples/router-outlet-demo && npm start",
9 | "start:minimal": "cd examples/minimal-setup && npm start"
10 | },
11 | "author": "",
12 | "license": "ISC"
13 | }
14 |
--------------------------------------------------------------------------------
/rocket-docs/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
3 | ## Rocket ignore files (need to be the full relative path to the folders)
4 | docs/_merged_data/
5 | docs/_merged_assets/
6 | docs/_merged_includes/
7 |
8 | _site
9 | _site-dev
10 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/.eleventyignore:
--------------------------------------------------------------------------------
1 | _assets
2 | _includes
3 | _data
4 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/404/rocket.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
27 | rocket_1
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_inline-scripts/serviceWorkerUpdate.js:
--------------------------------------------------------------------------------
1 | async function serviceWorkerUpdate() {
2 | if ('serviceWorker' in navigator) {
3 | const oldReg = await navigator.serviceWorker.getRegistration();
4 | let oldSwState;
5 | if (oldReg && oldReg.active) {
6 | oldSwState = oldReg.active.state;
7 | }
8 |
9 | let refreshing;
10 |
11 | navigator.serviceWorker.addEventListener('controllerchange', async () => {
12 | if (refreshing) {
13 | return;
14 | }
15 |
16 | const newReg = await navigator.serviceWorker.getRegistration();
17 | let newSwState;
18 | if (newReg && newReg.active) {
19 | newSwState = newReg.active.state;
20 | }
21 |
22 | if (oldSwState === 'activated' && newSwState === 'activating') {
23 | refreshing = true;
24 | window.location.reload();
25 | }
26 | });
27 | }
28 | }
29 |
30 | serviceWorkerUpdate();
31 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/404/bg_purple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/404/bg_purple.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/404/overlay_stars.svg:
--------------------------------------------------------------------------------
1 |
5 |
6 | overlay_stars_1
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/android-chrome-192x192.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/android-chrome-512x512.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/apple-touch-icon.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/favicon-16x16.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/favicon-32x32.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/icon-128x128.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/icon-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/icon-512x512.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/maskable-icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/maskable-icon-128x128.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/maskable-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/maskable-icon.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/icons/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/_static/icons/mstile-150x150.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/noscript.css:
--------------------------------------------------------------------------------
1 | /* override to add noscript styles */
2 |
3 | /* Make sure unregistered custom elements don't hide their contents */
4 | :not(:defined) {
5 | opacity: 1 !important;
6 | }
7 |
8 | inline-notification {
9 | padding: 0.1rem 1.5rem;
10 | border-left-width: 0.5rem;
11 | border-left-style: solid;
12 | margin: 1rem 0;
13 | display: block;
14 | opacity: 1 !important;
15 | }
16 |
17 | inline-notification::before {
18 | content: attr(type);
19 | font-weight: 600;
20 | font-size: 1.17em;
21 | margin-top: 24px;
22 | margin-bottom: 7px;
23 | display: block;
24 | text-transform: uppercase;
25 | }
26 |
27 | inline-notification[type='tip'] {
28 | background-color: var(--inline-notification-tip-background-color, rgba(221, 221, 221, 0.3));
29 | border-color: var(--inline-notification-tip-border-color, #42b983);
30 | }
31 |
32 | inline-notification[type='warning'] {
33 | background-color:
34 | var(
35 | --inline-notification-warning-background-color,
36 | rgba(255, 229, 100, 0.2)
37 | );
38 | border-color: var(--inline-notification-warning-border-color, #e7c000);
39 | }
40 |
41 | inline-notification[type='danger'] {
42 | background-color: var(--inline-notification-danger-background-color, rgba(192, 0, 0, 0.1));
43 | border-color: var(--inline-notification-danger-border-color, #c00);
44 | }
45 |
46 | inline-notification[type='warning']::before {
47 | color: var(--inline-notification-warning-heading-color, #b29400);
48 | }
49 |
50 | inline-notification[type='danger']::before {
51 | color: var(--inline-notification-danger-heading-color, #900);
52 | }
53 |
54 | inline-notification > p {
55 | line-height: 1.7;
56 | }
57 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/_static/search/noscript.css:
--------------------------------------------------------------------------------
1 | rocket-search {
2 | display: none;
3 | }
4 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/brand-logos/discord.svg:
--------------------------------------------------------------------------------
1 |
2 | Discord
3 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/brand-logos/github.svg:
--------------------------------------------------------------------------------
1 |
2 | GitHub
3 |
4 |
5 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/brand-logos/slack.svg:
--------------------------------------------------------------------------------
1 |
2 | Slack
3 |
5 |
6 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/brand-logos/telegram.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/brand-logos/twitter.svg:
--------------------------------------------------------------------------------
1 | Twitter
2 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/burger-menu.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/octicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/scripts/define-rocket-search.js:
--------------------------------------------------------------------------------
1 | import '@rocket/search/rocket-search.js';
2 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/scripts/init-navigation.js:
--------------------------------------------------------------------------------
1 | import '@rocket/navigation/rocket-navigation.js';
2 | import '@rocket/drawer/rocket-drawer.js';
3 | const drawer = document.querySelector('#sidebar');
4 |
5 | // Toggle button
6 | const triggers = document.querySelectorAll('[data-action="trigger-mobile-menu"]');
7 | for (const trigger of [...triggers]) {
8 | trigger.addEventListener('click', function () {
9 | drawer.opened = true;
10 | });
11 | }
12 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/scripts/registerServiceWorker.js:
--------------------------------------------------------------------------------
1 | (async () => {
2 | if ('serviceWorker' in navigator) {
3 | const { Workbox } = await import('workbox-window');
4 |
5 | const url = window.__rocketServiceWorkerUrl || '/service-worker.js';
6 | const wb = new Workbox(url);
7 | wb.addEventListener('message', event => {
8 | if (event.data.type === 'CACHE_UPDATED') {
9 | const { updatedURL } = event.data.payload;
10 | console.log(`Reloading as a newer version of ${updatedURL} became available!`);
11 | window.location.reload();
12 | }
13 | });
14 | wb.register()
15 | .then(function () {
16 | console.log('ServiceWorker registered.');
17 | })
18 | .catch(function (err) {
19 | console.log('ServiceWorker registration failed: ', err);
20 | });
21 | }
22 | })();
23 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/service-worker.js:
--------------------------------------------------------------------------------
1 | import { registerRoute } from 'workbox-routing';
2 | import { CacheFirst, StaleWhileRevalidate } from 'workbox-strategies';
3 | import { BroadcastUpdatePlugin } from 'workbox-broadcast-update';
4 | import { ExpirationPlugin } from 'workbox-expiration';
5 |
6 | addEventListener('install', () => {
7 | // eslint-disable-next-line no-undef
8 | skipWaiting();
9 | });
10 |
11 | // addEventListener('activate', () => {
12 | // console.log('activate');
13 | // });
14 |
15 | const cacheFirst = new CacheFirst({
16 | cacheName: 'assets',
17 | plugins: [
18 | new ExpirationPlugin({
19 | maxEntries: 100,
20 | }),
21 | ],
22 | });
23 | const staleWhileRevalidate = new StaleWhileRevalidate({
24 | cacheName: 'pages',
25 | plugins: [new BroadcastUpdatePlugin()],
26 | });
27 |
28 | registerRoute(/(\/|\.html)$/, staleWhileRevalidate);
29 | registerRoute(/\.(css|m?js|svg|woff2|png|jpg|gif|json|xml)$/, cacheFirst);
30 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/simplr-router-logo-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/simplr-router-logo-black.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/simplr-router-logo-transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/simplr-router-logo-transparent.png
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/social-media-image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site-dev/_merged_assets/social-media-image.jpg
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/style.css:
--------------------------------------------------------------------------------
1 | /* feel free to override this file for your page - add a file docs/_assets/style.css */
2 |
3 | body[layout^='layout-home'] .markdown-body .call-to-action:nth-of-type(2) {
4 | --primary-color: #222;
5 | --primary-color-lighter: #333;
6 | --primary-color-darker: #000;
7 | }
8 |
9 | @media screen and (min-width: 1024px) {
10 | body[layout='layout-home-background'] .page-background {
11 | top: -210px;
12 | right: -463px;
13 | transform: rotate(45deg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/variables.css:
--------------------------------------------------------------------------------
1 | html {
2 | --primary-color: #ff6d00;
3 | --primary-color-lighter: #ff8b33;
4 | --primary-color-darker: #cc5800;
5 | --primary-color-accent: #994200;
6 | --primary-text-color: #2c3e50;
7 | --primary-lines-color: #ccc;
8 | --primary-text-inverse-color: #eee;
9 |
10 | /* Contrast colors */
11 | --contrast-color-light: #fff;
12 | --contrast-color-dark: #1d3557;
13 |
14 | /* background-colors */
15 | --page-background: white;
16 | --footer-background: rgba(0, 0, 0, 0.1);
17 |
18 | /* typography */
19 | --text-color: black;
20 | --primary-font-family: 'Open Sans', sans-serif;
21 | --secondary-font-family: 'Montserrat', sans-serif;
22 | --monospace-font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace;
23 |
24 | /* controls */
25 | --switch-unselected-color: #808080;
26 | --switch-selected-color: #42b983;
27 | }
28 |
29 | html.dark {
30 | --primary-color: #e63946;
31 | --primary-color-lighter: #e25761;
32 | --primary-color-darker: #a22831;
33 | --primary-color-accent: #cee5f6;
34 | --primary-text-color: #eee;
35 | --primary-text-inverse-color: #2c3e50;
36 |
37 | /* Contrast colors */
38 | --contrast-color-light: #fff;
39 | --contrast-color-dark: #1d3557;
40 |
41 | /* background-colors */
42 | --page-background: #333;
43 | --footer-background: #4f4f4f;
44 |
45 | /* typography */
46 | --text-color: white;
47 |
48 | /* controls */
49 | --switch-unselected-color: #808080;
50 | --switch-selected-color: #42b983;
51 |
52 | /* markdown */
53 | --markdown-octicon-link: white;
54 | --markdown-syntax-background-color: #a0a0a0;
55 | --markdown-link-color: #fb7881;
56 | --markdown-blockquote-color: #c9e3ff;
57 | }
58 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/_merged_assets/webmanifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Rocket",
3 | "short_name": "Rocket",
4 | "theme_color": "#e63946",
5 | "background_color": "#1d3557",
6 | "display": "standalone",
7 | "orientation": "portrait",
8 | "Scope": "/",
9 | "start_url": "/",
10 | "icons": [
11 | {
12 | "src": "../_merged_assets/_static/icons/android-chrome-192x192.png",
13 | "sizes": "128x128",
14 | "type": "image/png"
15 | },
16 | {
17 | "src": "../_merged_assets/_static/icons/android-chrome-512x512.png",
18 | "sizes": "512x512",
19 | "type": "image/png"
20 | },
21 | {
22 | "src": "../_merged_assets/_static/icons/maskable-icon.jpg",
23 | "sizes": "1024x1024",
24 | "type": "image/jpg",
25 | "purpose": "any maskable"
26 | }
27 | ],
28 | "splash_pages": null
29 | }
30 |
--------------------------------------------------------------------------------
/rocket-docs/_site-dev/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Simplr Router
3 | layout: layout-home
4 | slogan: A small and effective routing solution for Web Components
5 | callToActionItems:
6 | - text: Follow Guides
7 | href: guides/
8 | - text: Browse Docs
9 | href: docs/
10 |
11 | reasonHeader: Why Simplr Router
12 | reasons:
13 | - header: Quick and simple
14 | text: Simple to get up and running. Basic setup in just a few lines of code.
15 | - header: Small
16 | text: No dependencies and a small codebase means less breaking parts. 0 dependencies means that what you see is what you get.
17 | - header: Easy to transition into
18 | text: Works by utilizing the native API's used for navigation and therefore doesn't require any extra steps compared to your every day MPA.
19 | - header: Web Component focused
20 | text: Built with web components, for web components. Simplr Router was designed from the get go to be used in web component applications.
21 | - header: Customizable
22 | text: Even though there's no configuration necessary to get started, the router ships with a lot of customizability to fit your needs.
23 | - header: Performant
24 | text: Allowing for lazy loading and creating dynamic routes, Simplr Router is a great library for projects of all sizes.
25 | ---
26 |
--------------------------------------------------------------------------------
/rocket-docs/_site/.eleventyignore:
--------------------------------------------------------------------------------
1 | _assets
2 | _includes
3 | _data
4 |
--------------------------------------------------------------------------------
/rocket-docs/_site/0d2fe2f7.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rocket-docs/_site/866a7333.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/866a7333.png
--------------------------------------------------------------------------------
/rocket-docs/_site/962426a7.js:
--------------------------------------------------------------------------------
1 | const t=new WeakMap;function e(e){return r=>{if(function(e,r){let n=r;for(;n;){if(t.get(n)===e)return!0;n=Object.getPrototypeOf(n)}return!1}(e,r))return r;const n=e(r);return t.set(n,e),n}}export{e as d};
2 |
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/404/bg_purple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/404/bg_purple.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/404/overlay_stars.svg:
--------------------------------------------------------------------------------
1 |
5 |
6 | overlay_stars_1
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/android-chrome-192x192.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/android-chrome-512x512.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/apple-touch-icon.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/favicon-16x16.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/favicon-32x32.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/icon-128x128.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/icon-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/icon-512x512.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/maskable-icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/maskable-icon-128x128.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/maskable-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/maskable-icon.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/icons/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/_merged_assets/_static/icons/mstile-150x150.png
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/noscript.css:
--------------------------------------------------------------------------------
1 | /* override to add noscript styles */
2 |
3 | /* Make sure unregistered custom elements don't hide their contents */
4 | :not(:defined) {
5 | opacity: 1 !important;
6 | }
7 |
8 | inline-notification {
9 | padding: 0.1rem 1.5rem;
10 | border-left-width: 0.5rem;
11 | border-left-style: solid;
12 | margin: 1rem 0;
13 | display: block;
14 | opacity: 1 !important;
15 | }
16 |
17 | inline-notification::before {
18 | content: attr(type);
19 | font-weight: 600;
20 | font-size: 1.17em;
21 | margin-top: 24px;
22 | margin-bottom: 7px;
23 | display: block;
24 | text-transform: uppercase;
25 | }
26 |
27 | inline-notification[type='tip'] {
28 | background-color: var(--inline-notification-tip-background-color, rgba(221, 221, 221, 0.3));
29 | border-color: var(--inline-notification-tip-border-color, #42b983);
30 | }
31 |
32 | inline-notification[type='warning'] {
33 | background-color:
34 | var(
35 | --inline-notification-warning-background-color,
36 | rgba(255, 229, 100, 0.2)
37 | );
38 | border-color: var(--inline-notification-warning-border-color, #e7c000);
39 | }
40 |
41 | inline-notification[type='danger'] {
42 | background-color: var(--inline-notification-danger-background-color, rgba(192, 0, 0, 0.1));
43 | border-color: var(--inline-notification-danger-border-color, #c00);
44 | }
45 |
46 | inline-notification[type='warning']::before {
47 | color: var(--inline-notification-warning-heading-color, #b29400);
48 | }
49 |
50 | inline-notification[type='danger']::before {
51 | color: var(--inline-notification-danger-heading-color, #900);
52 | }
53 |
54 | inline-notification > p {
55 | line-height: 1.7;
56 | }
57 |
--------------------------------------------------------------------------------
/rocket-docs/_site/_merged_assets/_static/search/noscript.css:
--------------------------------------------------------------------------------
1 | rocket-search {
2 | display: none;
3 | }
4 |
--------------------------------------------------------------------------------
/rocket-docs/_site/assets/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/assets/apple-touch-icon.png
--------------------------------------------------------------------------------
/rocket-docs/_site/assets/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/assets/favicon-16x16.png
--------------------------------------------------------------------------------
/rocket-docs/_site/assets/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/_site/assets/favicon-32x32.png
--------------------------------------------------------------------------------
/rocket-docs/_site/assets/webmanifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Rocket",
3 | "short_name": "Rocket",
4 | "theme_color": "#e63946",
5 | "background_color": "#1d3557",
6 | "display": "standalone",
7 | "orientation": "portrait",
8 | "Scope": "/",
9 | "start_url": "/",
10 | "icons": [
11 | {
12 | "src": "../_merged_assets/_static/icons/android-chrome-192x192.png",
13 | "sizes": "128x128",
14 | "type": "image/png"
15 | },
16 | {
17 | "src": "../_merged_assets/_static/icons/android-chrome-512x512.png",
18 | "sizes": "512x512",
19 | "type": "image/png"
20 | },
21 | {
22 | "src": "../_merged_assets/_static/icons/maskable-icon.jpg",
23 | "sizes": "1024x1024",
24 | "type": "image/jpg",
25 | "purpose": "any maskable"
26 | }
27 | ],
28 | "splash_pages": null
29 | }
30 |
--------------------------------------------------------------------------------
/rocket-docs/_site/b8c01bc2.css:
--------------------------------------------------------------------------------
1 | /* feel free to override this file for your page - add a file docs/_assets/style.css */
2 |
3 | body[layout^='layout-home'] .markdown-body .call-to-action:nth-of-type(2) {
4 | --primary-color: #222;
5 | --primary-color-lighter: #333;
6 | --primary-color-darker: #000;
7 | }
8 |
9 | @media screen and (min-width: 1024px) {
10 | body[layout='layout-home-background'] .page-background {
11 | top: -210px;
12 | right: -463px;
13 | transform: rotate(45deg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/rocket-docs/_site/d15d5a5d.js:
--------------------------------------------------------------------------------
1 | (async()=>{if("serviceWorker"in navigator){const{Workbox:e}=await import("./3dfb6b8e.js"),o=new e(window.__rocketServiceWorkerUrl||"/service-worker.js");o.addEventListener("message",(e=>{if("CACHE_UPDATED"===e.data.type){const{updatedURL:o}=e.data.payload;console.log(`Reloading as a newer version of ${o} became available!`),window.location.reload()}})),o.register().then((function(){console.log("ServiceWorker registered.")})).catch((function(e){console.log("ServiceWorker registration failed: ",e)}))}})();
2 |
--------------------------------------------------------------------------------
/rocket-docs/_site/dba25cba.css:
--------------------------------------------------------------------------------
1 | html {
2 | --primary-color: #ff6d00;
3 | --primary-color-lighter: #ff8b33;
4 | --primary-color-darker: #cc5800;
5 | --primary-color-accent: #994200;
6 | --primary-text-color: #2c3e50;
7 | --primary-lines-color: #ccc;
8 | --primary-text-inverse-color: #eee;
9 |
10 | /* Contrast colors */
11 | --contrast-color-light: #fff;
12 | --contrast-color-dark: #1d3557;
13 |
14 | /* background-colors */
15 | --page-background: white;
16 | --footer-background: rgba(0, 0, 0, 0.1);
17 |
18 | /* typography */
19 | --text-color: black;
20 | --primary-font-family: 'Open Sans', sans-serif;
21 | --secondary-font-family: 'Montserrat', sans-serif;
22 | --monospace-font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace;
23 |
24 | /* controls */
25 | --switch-unselected-color: #808080;
26 | --switch-selected-color: #42b983;
27 | }
28 |
29 | html.dark {
30 | --primary-color: #e63946;
31 | --primary-color-lighter: #e25761;
32 | --primary-color-darker: #a22831;
33 | --primary-color-accent: #cee5f6;
34 | --primary-text-color: #eee;
35 | --primary-text-inverse-color: #2c3e50;
36 |
37 | /* Contrast colors */
38 | --contrast-color-light: #fff;
39 | --contrast-color-dark: #1d3557;
40 |
41 | /* background-colors */
42 | --page-background: #333;
43 | --footer-background: #4f4f4f;
44 |
45 | /* typography */
46 | --text-color: white;
47 |
48 | /* controls */
49 | --switch-unselected-color: #808080;
50 | --switch-selected-color: #42b983;
51 |
52 | /* markdown */
53 | --markdown-octicon-link: white;
54 | --markdown-syntax-background-color: #a0a0a0;
55 | --markdown-link-color: #fb7881;
56 | --markdown-blockquote-color: #c9e3ff;
57 | }
58 |
--------------------------------------------------------------------------------
/rocket-docs/docs/.eleventyignore:
--------------------------------------------------------------------------------
1 | _assets
2 | _includes
3 | _data
4 |
--------------------------------------------------------------------------------
/rocket-docs/docs/404.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: layout-404
3 | permalink: 404.html
4 | ---
5 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_assets/_static/icons/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/docs/_assets/_static/icons/favicon-16x16.png
--------------------------------------------------------------------------------
/rocket-docs/docs/_assets/_static/icons/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/docs/_assets/_static/icons/favicon-32x32.png
--------------------------------------------------------------------------------
/rocket-docs/docs/_assets/simplr-router-logo-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/docs/_assets/simplr-router-logo-black.png
--------------------------------------------------------------------------------
/rocket-docs/docs/_assets/simplr-router-logo-transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Simplr/simplr-router/11e22c6d78255081745a8f96cdee426f77b402d4/rocket-docs/docs/_assets/simplr-router-logo-transparent.png
--------------------------------------------------------------------------------
/rocket-docs/docs/_assets/variables.css:
--------------------------------------------------------------------------------
1 | html {
2 | --primary-color: #ff6d00;
3 | --primary-color-lighter: #ff8b33;
4 | --primary-color-darker: #cc5800;
5 | --primary-color-accent: #994200;
6 | --primary-text-color: #2c3e50;
7 | --primary-lines-color: #ccc;
8 | --primary-text-inverse-color: #eee;
9 |
10 | /* Contrast colors */
11 | --contrast-color-light: #fff;
12 | --contrast-color-dark: #1d3557;
13 |
14 | /* background-colors */
15 | --page-background: white;
16 | --footer-background: rgba(0, 0, 0, 0.1);
17 |
18 | /* typography */
19 | --text-color: black;
20 | --primary-font-family: 'Open Sans', sans-serif;
21 | --secondary-font-family: 'Montserrat', sans-serif;
22 | --monospace-font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', 'Courier', monospace;
23 |
24 | /* controls */
25 | --switch-unselected-color: #808080;
26 | --switch-selected-color: #42b983;
27 | }
28 |
29 | html.dark {
30 | --primary-color: #e63946;
31 | --primary-color-lighter: #e25761;
32 | --primary-color-darker: #a22831;
33 | --primary-color-accent: #cee5f6;
34 | --primary-text-color: #eee;
35 | --primary-text-inverse-color: #2c3e50;
36 |
37 | /* Contrast colors */
38 | --contrast-color-light: #fff;
39 | --contrast-color-dark: #1d3557;
40 |
41 | /* background-colors */
42 | --page-background: #333;
43 | --footer-background: #4f4f4f;
44 |
45 | /* typography */
46 | --text-color: white;
47 |
48 | /* controls */
49 | --switch-unselected-color: #808080;
50 | --switch-selected-color: #42b983;
51 |
52 | /* markdown */
53 | --markdown-octicon-link: white;
54 | --markdown-syntax-background-color: #a0a0a0;
55 | --markdown-link-color: #fb7881;
56 | --markdown-blockquote-color: #c9e3ff;
57 | }
58 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_data/eleventyComputed.cjs:
--------------------------------------------------------------------------------
1 | const { generateEleventyComputed } = require('@rocket/cli');
2 |
3 | module.exports = {
4 | ...generateEleventyComputed(),
5 | };
6 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_data/footer.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Discover",
4 | "children": [
5 | {
6 | "text": "Help and Feedback",
7 | "href": "https://github.com/Simplr/simplr-router/issues"
8 | }
9 | ]
10 | },
11 | {
12 | "name": "Follow",
13 | "children": [
14 | {
15 | "text": "GitHub",
16 | "href": "https://github.com/Simplr/simplr-router"
17 | },
18 | {
19 | "text": "Twitter",
20 | "href": "https://twitter.com/matsuuu_"
21 | }
22 | ]
23 | },
24 | {
25 | "name": "Support",
26 | "children": [
27 | {
28 | "text": "Contribute",
29 | "href": "https://github.com/Simplr/simplr-router"
30 | }
31 | ]
32 | }
33 | ]
34 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_data/rocketConfig.cjs:
--------------------------------------------------------------------------------
1 | const { getComputedConfig } = require('@rocket/cli');
2 |
3 | module.exports = getComputedConfig();
4 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_data/rocketLaunch.json:
--------------------------------------------------------------------------------
1 | {
2 | "homeLayout": "logo",
3 | "newsletter": false
4 | }
5 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_data/site.cjs:
--------------------------------------------------------------------------------
1 | module.exports = function () {
2 | return {
3 | dir: 'ltr',
4 | lang: 'en',
5 | name: 'Simplr Router',
6 | description: 'Simplr Router is a small and effective routing solution for Web Components',
7 | socialLinks: [
8 | {
9 | name: 'GitHub',
10 | url: 'https://github.com/Simplr/simplr-router',
11 | },
12 | {
13 | name: 'Slack',
14 | url:
15 | 'https://join.slack.com/t/lit-and-friends/shared_invite/zt-llwznvsy-LZwT13R66gOgnrg12PUGqw',
16 | },
17 | ],
18 | gitSiteUrl: 'https://github.com/Simplr/simplr-router',
19 | gitBranch: 'master',
20 | helpUrl: 'https://github.com/Simplr/simplr-router/issues',
21 | logoAlt: 'Simplr Router logo',
22 | iconColorMaskIcon: '#3f93ce',
23 | iconColorMsapplicationTileColor: '#1d3557',
24 | iconColorThemeColor: '#1d3557',
25 | };
26 | };
27 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_data/siteUrl.cjs:
--------------------------------------------------------------------------------
1 | let url = 'https://simplr.github.io/simplr-router/';
2 |
3 | // handling netlify previews
4 | switch (process.env.CONTEXT) {
5 | case 'production':
6 | url = process.env.URL;
7 | break;
8 | case 'deploy-preview':
9 | url = process.env.DEPLOY_URL;
10 | break;
11 | case 'branch-deploy':
12 | url = process.env.DEPLOY_PRIME_URL;
13 | break;
14 | /* no default */
15 | }
16 |
17 | module.exports = url;
18 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_includes/_joiningBlocks/_layoutHome/content/10-hero.njk:
--------------------------------------------------------------------------------
1 |
2 |
3 | {% if rocketLaunch.homeLayout === 'background' %}
4 |
5 | {% endif %}
6 |
7 | {{title}}
8 |
9 | {{slogan}}
10 |
11 |
16 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_includes/_joiningBlocks/header/20-logo.njk:
--------------------------------------------------------------------------------
1 | {% if layout === "home.njk" and rocketLaunch.homeLayout === "background" %}
2 |
3 |
4 | {{ site.name }}
5 |
6 | {% else %}
7 | {% include 'partials/_shared/logoLink.njk' %}
8 | {% endif %}
9 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_includes/partials/_shared/logoLink.njk:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ site.name }}
4 |
5 |
--------------------------------------------------------------------------------
/rocket-docs/docs/_includes/partials/header.njk:
--------------------------------------------------------------------------------
1 |
2 |
3 | {% for blockName, blockPath in _joiningBlocks.header %}
4 | {% include blockPath %}
5 | {% endfor %}
6 |
7 |
8 |
--------------------------------------------------------------------------------
/rocket-docs/docs/docs/api/events.md:
--------------------------------------------------------------------------------
1 | # API >> Events
2 |
3 | Events are dispatched into the window context. Most of them ship payloads containing useful information about the event.
4 |
5 | Type name: SimplrRouterOptions
6 |
7 | | Name | Description |
8 | | ------------------------------ | ------------------------------------------------------------------------------ |
9 | | simplr-router-transition-start | Simplr router has started transitioning to another view |
10 | | simplr-router-transition-end | Simplr router has finished transitioning to another view |
11 | | simplr-router-initialized | Simplr router has initialized. (After init() call) |
12 | | simplr-router-navigated | Simplr router has navigated to a new view, and updated the history accordingly |
13 |
--------------------------------------------------------------------------------
/rocket-docs/docs/docs/api/helper-functions.md:
--------------------------------------------------------------------------------
1 | # API >> Helper functions
2 |
3 | Helper functions are callable functions that plug into the currently active Simplr Router instance
4 | without the developer having to hold onto a reference of the router.
5 |
6 | Helper functions are exported from the same package as the router itself.
7 |
8 | ```javascript
9 | import { getBreadcrumbs } from "@simplr-wc/router";
10 | ```
11 |
12 | | Name | Type | Description |
13 | | ---------------- | -------------------------------------------------- | ---------------------------------------------- |
14 | | changeView() | Function(changeViewObject: ChangeViewObject): void | Change view programmatically. |
15 | | getBreadcrumbs() | Function(): SimplrRouterBreadcrumb[] | Returns the breadcrumbs for the current route. |
16 | | getCurrentView() | Function(): SimplrRouterNavigationData | Returns the current view. |
17 |
--------------------------------------------------------------------------------
/rocket-docs/docs/docs/api/index.md:
--------------------------------------------------------------------------------
1 | # API
2 |
3 |
--------------------------------------------------------------------------------
/rocket-docs/docs/docs/api/route.md:
--------------------------------------------------------------------------------
1 | # API >> Route
2 |
3 | Type name: SimplrRoute
4 |
5 | | Name | Type | Description |
6 | | ------------- | ------------------------------- | ----------------------------------------------------------------------------------- |
7 | | path | string | The URL path for the route |
8 | | component | string | The view component name for the route |
9 | | name | string | Name of the view route |
10 | | import | Function | An import function for lazy loading. e.g. () => import("./my-view.js") |
11 | | guard | Function | A guard function to check view access |
12 | | routes | SimplrRoute[] | An array of subroutes that inherit paths from the parent route |
13 | | slots | [x: string]: string \| Function | An array of slots to append to the view component |
14 | | pattern | [x: string]: string \| | RegExp pattern to match dynamic route keys |
15 | | redirect | string \| { name: string } | Path to redirect to |
16 | | preventUnload | boolean | If the router should intercept navigation from this page with a confirmation dialog |
17 | | properties | [x: string]: string | Properties to pass to the view. |
18 |
--------------------------------------------------------------------------------
/rocket-docs/docs/docs/api/router-options.md:
--------------------------------------------------------------------------------
1 | # API >> Router Options
2 |
3 | Type name: SimplrRouterOptions
4 |
5 | | Name | Type | Description |
6 | | --------------- | ----------- | ------------------------------------------------------------------------ |
7 | | routes | SimplrRoute | Routes provided for the Simplr Router. |
8 | | rootPath | string | Root path of the router. If the root is not the origin of the host. |
9 | | transitionSpeed | number | Transition speed of view transitions in milliseconds. |
10 | | notFoundAction | Function | Action triggered when a view is not found. |
11 | | forbiddenAction | Function | Action triggered when access to a view is forbidden by a guard function. |
12 | | debugging | boolean | Enable debugging. |
13 |
--------------------------------------------------------------------------------
/rocket-docs/docs/docs/api/router.md:
--------------------------------------------------------------------------------
1 | # API >> Router
2 |
3 | Type name: SimplrRouter
4 |
5 | | Name | Type | Description |
6 | | -------------------- | -------------------------------------- | ---------------------------------------------- |
7 | | init() | Function() | Initialize Simplr Router and start navigating. |
8 | | changeView() | Function(ChangeViewObject) | Change view to given path or named route. |
9 | | use(middlewareClass) | Function(any) | Add middleware to Simplr Router. |
10 | | getBreadcrumbs() | Function(): SimplrRouterBreadcrumb[] | Returns the breadcrumbs for the current route. |
11 | | getCurrentView() | Function(): SimplrRouterNavigationData | Returns the current view. |
12 |
--------------------------------------------------------------------------------
/rocket-docs/docs/docs/index.md:
--------------------------------------------------------------------------------
1 | # Docs
2 |
3 | The API documentation has references to most of the public facing API's
4 | the Simplr Router exposes.
5 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/customizing/index.md:
--------------------------------------------------------------------------------
1 | # Customizing || 30
2 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/customizing/rootpaths.md:
--------------------------------------------------------------------------------
1 | # Customizing >> Changing routing root
2 |
3 | When hosting your SPA in a service, a situation might come where the URL path of your applications
4 | includes something more than the routes of your application.
5 |
6 | An example of this would be hosting on github pages, where your URL would look something like this:
7 | `https://simplr.github.io/simplr-router/guides`.
8 |
9 | In these cases you might not want to write the `simplr-router` part of the URL into every route manually.
10 |
11 | This can be resolved by using a root path, to determine from what part of the URL the router starts parsing.
12 |
13 | ```javascript
14 | const routerOptions = {
15 | routes: [
16 | {
17 | name: "Home",
18 | path: "",
19 | component: "router-demo",
20 | },
21 | {
22 | name: "Example",
23 | path: "example",
24 | component: "router-example",
25 | import: () => import("./router-example.js")
26 | }
27 | ],
28 | rootPath: "/my-app"
29 | }
30 |
31 | const router = new SimplrRouter(routerOptions);
32 | router.init();
33 | ```
34 |
35 | Now navigating to `/my-app/example` will provide the example route successfully.
36 |
37 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/customizing/styling-transitions.md:
--------------------------------------------------------------------------------
1 | # Customizing >> Styling transitions
2 |
3 | You can create transition animations for your views by modifying the css of the wrapper Simplr Router creates.
4 |
5 | To enable transitions, a `transitionSpeed` property needs to be set in the config.
6 |
7 | ```javascript
8 | const routerOptions = {
9 | routes: [
10 | {
11 | name: "Home",
12 | path: "",
13 | component: "router-demo",
14 | },
15 | {
16 | name: "Example",
17 | path: "example",
18 | component: "router-example",
19 | }
20 | ]
21 | transitionSpeed: 400 // in ms
22 | }
23 |
24 | const router = new SimplrRouter(routerOptions);
25 | router.init();
26 | ```
27 |
28 | Now all that is needed is to modify the css of the `simplr-router-container` -element.
29 |
30 | ### Example transitions
31 |
32 | #### Fade in out
33 |
34 | ```css
35 | simplr-router-container[entering-view],
36 | simplr-router-container[leaving-view] {
37 | opacity: 0;
38 | }
39 | ```
40 |
41 | #### Slide in out
42 |
43 | ```css
44 | simplr-router-container[entering-view] {
45 | transform: translateX(-100%);
46 | }
47 |
48 | simplr-router-container[leaving-view] {
49 | transform: translateX(100%);
50 | }
51 | ```
52 |
53 | #### Zoom
54 |
55 | ```css
56 | simplr-router-container[entering-view] {
57 | transform: scale(0);
58 | }
59 |
60 | simplr-router-container[leaving-view] {
61 | z-index: -1;
62 | }
63 | ```
64 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/getting-started/index.md:
--------------------------------------------------------------------------------
1 | # Getting started || 10
2 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/getting-started/using-an-outlet.md:
--------------------------------------------------------------------------------
1 | # Getting started >> Using an outlet || 30
2 |
3 | Simplr Router creates a container for your views that fills the whole screen by default.
4 |
5 | In some cases you might want to only have a part of the page change instead of the whole content.
6 |
7 | In these cases an outlet can be used to determine the area in which content changes.
8 |
9 | Determining an outlet is done by creating a `simplr-router-outlet` somewhere on your web page.
10 |
11 | ## Using an outlet
12 |
13 | ```javascript
14 | render() {}
15 | return html`
16 |
17 |
18 |
19 | `;
20 | }
21 | ```
22 |
23 | After the outlet has been added, Simplr Router will look for a outlet when navigating. If one is found, it is used instead
24 | of the default behavior.
25 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/getting-started/your-first-setup.md:
--------------------------------------------------------------------------------
1 | # Getting started >> Your first setup || 10
2 |
3 | Simplr Router works by matching url pathing with Custom Element views.
4 |
5 | Simplr Router aims to provide developers a quick-to-setup but configurable routing setup for projects of all size.
6 |
7 | ```javascript
8 | import { SimplrRouter } from "@simplr-wc/router";
9 | import "./minimal-setup.js";
10 | import "./example-view.js";
11 | import "./dynamic-view.js";
12 |
13 | const routes = [
14 | { path: "", component: "minimal-setup" },
15 | { path: "example", component: "example-view" },
16 | { path: "dynamic/:id", component: "dynamic-view" },
17 | ];
18 |
19 | new SimplrRouter({ routes }).init();
20 | ```
21 |
22 | The Router sets itself up as you call `init()` on the router instance. While setting up,
23 | the router starts listening for navigation events on the page and navigates with it's routing where possible.
24 |
25 | You don't need to create custom navigation methods. Simplr Router overrides the default action of anchor tags when
26 | the navigation target is listed as a route.
27 |
28 |
29 |
35 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/index.md:
--------------------------------------------------------------------------------
1 | # Guides
2 |
3 | This section of the documentation provides some examples, recipes and references for using Simplr Router.
4 |
5 | If you are new to Web Components, you should start from [Using a Starter](getting-started/using-a-starter/)
6 |
7 | If you are more experiences, you could look into the [Your first Setup](getting-started/your-first-setup/) -section and read through the recipes.
8 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/child-routes.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Child routes
2 |
3 | In many cases we want to create paths that inherit from the paths leading into them.
4 | In these cases we can add them as the child routes of a created route, saving us from having to write
5 | the whole route, and creating a cleaner routing table.
6 |
7 | ```javascript
8 | const routes = [
9 | { path: "", component: "simplr-router-demo" },
10 | {
11 | path: "user",
12 | component: "user-view",
13 | routes: [
14 | {
15 | path: ":id",
16 | component: "user-profile-view"
17 | },
18 | {
19 | path: "add",
20 | component: "user-add-view"
21 | },
22 | {
23 | path: "edit",
24 | component: "user-edit-view"
25 | }
26 | ]
27 | },
28 | ];
29 |
30 | const router = new SimplrRouter({ routes });
31 | router.init();
32 | ```
33 |
34 | The mapping above will create the following routes:
35 |
36 | ```
37 | /
38 | /user
39 | /user/{id}
40 | /user/add
41 | /user/edit
42 | ```
43 |
44 | Static routes will always take priority over dynamic routes, so `/user/add` will always match the static route
45 | and not the `/user/:id` -route
46 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/dynamic-routes.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Dynamic routes
2 |
3 | When creating frontend routing, often you might want to map a route by a given pattern. To achieve this,
4 | dynamic routing is needed.
5 |
6 | Example of a case where dynamic routing could be used is when creating a user view with a dynamic ID to differentiate between multiple users.
7 |
8 | ```javascript
9 | const routes = [
10 | { path: "", component: "front-page" },
11 | { path: "user", component: "user-list" },
12 | { path: "user/:id", component: "user-profile" },
13 | ];
14 | ```
15 |
16 | When navigating to `/user/123`, the `id` property of the view will be provided the paramter from the URL, in this case `123`.
17 |
18 | ### Dynamic route keys
19 |
20 | Dynamic routes can provide any key they want as the dynamic part, and it will be matched by that key.
21 |
22 | ```javascript
23 | // In route
24 | { path: "user/:id", component: "user-profile" },
25 | // In the view component when navigating to /user/123
26 | console.log(this.id)
27 | >>> 123
28 |
29 | // In route
30 | { path: "table/:tableType", component: "table-view" },
31 | // In the view component when navigating to /table/closed
32 | console.log(this.tableType)
33 | >>> "closed"
34 | ```
35 |
36 | ### Pattern matching routes
37 |
38 | If you want more control over the parameters your dynamic views accept, you can provide a `pattern` key for each key you want to check against.
39 |
40 | ```javascript
41 | const routes = [
42 | { path: "", component: "minimal-setup" },
43 | {
44 | path: "onlynumbers/:id",
45 | pattern: {
46 | // Matches routes with numbers as the :id
47 | // /onlynumbers/123
48 | // /onlynumbers/555
49 | id: "[0-9]+"
50 | },
51 | component: "dynamic-view"
52 | },
53 | {
54 | path: "onlynumbers/:id/thenword/:specialType",
55 | pattern: {
56 | id: "[0-9]+",
57 |
58 | // Matches routes with one of the matched words
59 | // /onlynumbers/123/thenword/foo
60 | // /onlynumbers/123/thenword/bar
61 | // /onlynumbers/123/thenword/baz
62 | specialType: "(foo|bar|baz)"
63 | },
64 | component: "dynamic-view"
65 | },
66 | ];
67 | ```
68 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/error-pages.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Error pages
2 |
3 | Simplr router supports 2 kinds of error pages by default:
4 |
5 | - Not found -page
6 | - Forbidden/Unauthorized -page
7 |
8 | These have special routings set up for them inside the router, and are programmed into the router.
9 |
10 | In action this means that if a not found -page is set in the routes, it will be displayed by the router in a case
11 | where the route provided by the user is not found on the application.
12 |
13 | In the same manner, if a guard returns a falsey value, a forbidden view will be loaded.
14 |
15 | ```javascript
16 | const routerOptions = {
17 | routes: [
18 | {
19 | name: "Home",
20 | path: "",
21 | component: "router-demo",
22 | },
23 | {
24 | name: "Example",
25 | path: "example",
26 | component: "router-example",
27 | },
28 | {
29 | name: "Guarded",
30 | path: "guarded",
31 | component: "router-example",
32 | guard: () => {
33 | return Math.random() >= 0.5;
34 | },
35 | },
36 | {
37 | path: "not-found",
38 | component: "not-found-view",
39 | },
40 | {
41 | path: "forbidden",
42 | component: "forbidden-view",
43 | },
44 | ],
45 | };
46 |
47 | const router = new SimplrRouter(routerOptions);
48 | router.init();
49 | ```
50 |
51 | ## Redirecting
52 |
53 | As the error pages are routes like any other, they can benefit from the same properties and settings too.
54 | A extremely useful setting to use with the error page route is `redirect`.
55 |
56 | You can easily for example redirect your users to the login screen, if they do not have the correct authorization status.
57 |
58 | ```javascript
59 | const routes = [
60 | {
61 | name: "Home",
62 | path: "/",
63 | component: "reportr-app",
64 | guard: () => {
65 | return isLoggedIn;
66 | },
67 | },
68 | {
69 | name: "Login",
70 | path: "login",
71 | component: "login-view",
72 | },
73 | {
74 | path: "forbidden",
75 | redirect: "/login",
76 | },
77 | ];
78 | ```
79 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/guards.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Guards
2 |
3 | Route guards can be used to prevent access to certain pages from users.
4 |
5 | Guards are a programmatic interface that allows you to create custom guard functions to check if the current user is authorized to
6 | view a route.
7 |
8 | If a guarding function returns true, access to the page is granted.
9 |
10 | On an unauthorized access attempt, the forbiddenAction is launched or the forbidden -view is displayed.
11 |
12 | ```javascript
13 | const routes = [
14 | { path: "", component: "minimal-setup" },
15 | { path: "example", component: "example-view", name: "Example" },
16 | {
17 | path: "/guarded",
18 | component: "example-view",
19 | guard: () => {
20 | // A 50/50 chance to get on page
21 | return Math.random() >= 0.5
22 | }
23 | }
24 | ];
25 |
26 | new SimplrRouter({ routes }).init();
27 | ```
28 |
29 | ## Binding values from guard functions
30 |
31 | Sometimes in guard functions, you might access data from an external source, like an API. In these
32 | situations you might want to carry this data onwards into the view.
33 |
34 | The Guard API passes the view params object to the guard function as it's first parameter, and allows
35 | you to bind values to it, binding them into the view as it's created.
36 |
37 | ```javascript
38 | const routes = [
39 | { path: "", component: "minimal-setup" },
40 | { path: "example", component: "example-view", name: "Example" },
41 | {
42 | path: "/guarded",
43 | component: "example-view",
44 | guard: (viewParams) => {
45 | // A 50/50 chance to get on page
46 | const roll = Math.random();
47 | viewParams.roll = roll;
48 | return roll >= 0.5;
49 | }
50 | }
51 | ];
52 |
53 | new SimplrRouter({ routes }).init();
54 | ```
55 |
56 | ## Observing view parameters in guard functions
57 |
58 | Similiarly to the binding of values, you can also access the view parameters of dynamic routes in your guard functions.
59 |
60 | ```javascript
61 | const routes = [
62 | { path: "", component: "minimal-setup" },
63 | { path: "example", component: "example-view", name: "Example" },
64 | {
65 | path: "/guarded/:id",
66 | component: "example-view",
67 | guard: (viewParams) => {
68 | console.log(viewParams);
69 | return viewParams.id > 0;
70 | }
71 | }
72 | ];
73 | ```
74 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/index.md:
--------------------------------------------------------------------------------
1 | # Recipes || 20
2 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/lazy-loading.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Lazy loading
2 |
3 | Lazy loading is a technique in which the content of the web page is split between multiple files,
4 | allowing for on-demand loading of content as it's needed, reducing initial load on your app.
5 |
6 | Simplr Router supports lazy loading for it's view routes. This has the potential of saving a lot
7 | of time in your page's initial load times.
8 |
9 | In a regular routing situation, your routing file might look something like this:
10 |
11 | ```javascript
12 | import { SimplrRouter } from "@simplr-wc/router";
13 | import "./ExampleView.js";
14 |
15 | const routes = [
16 | { path: "", component: "simplr-router-demo" },
17 | { path: "example", component: "example-view" }
18 | ];
19 |
20 | const router = new SimplrRouter({ routes });
21 | router.init();
22 | ```
23 |
24 | To enable lazy loading, remove the import statements of the views you want to load lazily from the
25 | top of the file, and add them as properties to your routes:
26 |
27 | ```javascript
28 | import { SimplrRouter } from "@simplr-wc/router";
29 |
30 | const routes = [
31 | { path: "", component: "simplr-router-demo" },
32 | { path: "example", component: "example-view", import: () => import("./ExampleView.js") }
33 | ];
34 |
35 | const router = new SimplrRouter({ routes });
36 | router.init();
37 | ```
38 |
39 | Now the view is only imported as the page is loaded, reducing initial load on your web app.
40 | It goes without saying that this might have magnitudes of effect on web applications where you have a large
41 | collections of views.
42 |
43 | ### Bundlers
44 |
45 | Due to the nature of the import being in code, most bundlers should be able to grasp onto the import statement
46 | and bundle it correctly, even if the file gets renamed.
47 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/named-routes.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Named routes
2 |
3 | Sometimes refering to the routes by the full path might be cumbersome, and you would father navigate using the
4 | name of the path. This can be done by naming the paths with a unique name and programmatically navigating to them.
5 |
6 | ```javascript
7 | const routes = [
8 | { path: "", component: "minimal-setup" },
9 | { path: "example", component: "example-view", name: "Example" }
10 | ];
11 |
12 | // Navigate to the named route
13 | changeView({ name: "Example" })
14 | ```
15 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/passing-properties.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Passing properties
2 |
3 | Sometimes we might want to "inject" some properties to our views while we render them. This is where the `properties` property comes to play.
4 |
5 | ```javascript
6 | const localeOptions = {
7 | locale: "fi_FI"
8 | }
9 |
10 | const routes = [
11 | { path: "", component: "simplr-router-demo" },
12 | {
13 | path: "user",
14 | component: "user-view",
15 | properties: {
16 | localeOptions: localeOptions
17 | }
18 | },
19 | ];
20 |
21 | const router = new SimplrRouter({ routes });
22 | router.init();
23 | ```
24 |
25 | The property is then accessible from the view itself
26 |
27 | ```javascript
28 | // Inside user-view
29 |
30 | console.log(this.localeOptions);
31 | // { locale: "fi_FI" }
32 | ```
33 |
34 | This can be useful for unit testing your application as you can provide separate implementations of properties into
35 | your views depending on the environment.
36 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/preventing-navigation.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Preventing navigation
2 |
3 | In some cases you might want to prevent leaving a page of your application. The normal case of preventing this
4 | would be done using the [onbeforeunload](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload)
5 | listener. This however doesn't work out of the box with SPA routers.
6 |
7 | If you want to prevent navigation to another page on your SPA application, you can add a `preventUnload` property
8 | to the route you want to prevent unloads from.
9 |
10 | ```javascript
11 | const routes = [
12 | { path: "", component: "minimal-setup" },
13 | { path: "example", component: "example-view", name: "Example" }
14 | {
15 | path: "prevent",
16 | component: "prevent-example",
17 | preventUnload: true,
18 | },
19 | ];
20 | ```
21 |
22 | Doing this will ask the user for confirmation, as they are about to navigate to another page of your application
23 | from your `prevent` view.
24 |
25 | Note that if you want to implement preventing navigation to another domain / site, you should do it yourself
26 | using the [onbeforeunload](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload)
27 | API.
28 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/programmatic-navigation.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Programmatic navigation
2 |
3 | You might run into a situation while writing your web page, where you want to programmatically
4 | navigate to a path. For these situations you can use the built in function `changeView`.
5 |
6 | `changeView` can be called with either the path of the page, or the name of the page.
7 | The function can also be provided with a page hash if needed.
8 |
9 | ```javascript
10 | import { changeView } from "@simplr-wc/router";
11 |
12 | // With path
13 | changeView({ path: "/user/123" });
14 |
15 | // With name
16 | changeView({ name: "home" });
17 |
18 | // With hash
19 | changeView({ path: "/docs/foo", hash: "#important-info" });
20 | ```
21 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/redirects.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Redirects
2 |
3 | Redirects can be done on any routes. Redirects can be to a path or a [named route](/guides/recipes/named-routes/).
4 |
5 | ```javascript
6 | const routes = [
7 | { path: "", component: "minimal-setup" },
8 | { path: "example", component: "example-view", name: "Example" },
9 | {
10 | path: "/do-redirect", redirect: "/example"
11 | },
12 | {
13 | path: "/name-redirect", redirect: { name: "Example" }
14 | }
15 | ];
16 | ```
17 |
--------------------------------------------------------------------------------
/rocket-docs/docs/guides/recipes/slots.md:
--------------------------------------------------------------------------------
1 | # Recipes >> Slots
2 |
3 | Simplr Router allows you to define slots to be appended to the view while the view is loaded to DOM.
4 |
5 | This allows creating views with dynamic slotted elements depending on the route the user accessed the view from.
6 |
7 |
8 | ```javascript
9 | const routerOptions = {
10 | routes: [
11 | {
12 | name: "Home",
13 | path: "",
14 | component: "router-demo",
15 | slots: [
16 | {
17 | 'top-bar': 'regular-top-bar',
18 | },
19 | ],
20 | },
21 | {
22 | path: 'special-home',
23 | component: 'router-demo',
24 | slots: [
25 | {
26 | 'top-bar': 'special-top-bar',
27 | },
28 | ],
29 | },
30 | ],
31 | }
32 | ```
33 |
34 | The following code will append a component named `regular-top-bar` or `special-top-bar` into the named slot `top-bar` of the view `router-demo`.
35 |
--------------------------------------------------------------------------------
/rocket-docs/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Simplr Router
3 | layout: layout-home
4 | slogan: A small and effective routing solution for Web Components
5 | callToActionItems:
6 | - text: Follow Guides
7 | href: guides/
8 | - text: Browse Docs
9 | href: docs/
10 |
11 | reasonHeader: Why Simplr Router
12 | reasons:
13 | - header: Quick and simple
14 | text: Simple to get up and running. Basic setup in just a few lines of code.
15 | - header: Small
16 | text: No dependencies and a small codebase means less breaking parts. 0 dependencies means that what you see is what you get.
17 | - header: Easy to transition into
18 | text: Works by utilizing the native API's used for navigation and therefore doesn't require any extra steps compared to your every day MPA.
19 | - header: Web Component focused
20 | text: Built with web components, for web components. Simplr Router was designed from the get go to be used in web component applications.
21 | - header: Customizable
22 | text: Even though there's no configuration necessary to get started, the router ships with a lot of customizability to fit your needs.
23 | - header: Performant
24 | text: Allowing for lazy loading and creating dynamic routes, Simplr Router is a great library for projects of all sizes.
25 | ---
26 |
--------------------------------------------------------------------------------
/rocket-docs/docs/sitemap.njk:
--------------------------------------------------------------------------------
1 | ---
2 | layout: layout-raw
3 | permalink: /sitemap.xml
4 | eleventyExcludeFromCollections: true
5 | ---
6 |
7 |
8 |
9 | {% for page in collections.all %}
10 | {%- if page.url !== '/404.html' -%}
11 |
12 | {{ rocketConfig.absoluteBaseUrl }}{{ page.url | url }}
13 | {{ page.date.toISOString() }}
14 | {{ page.data.changeFreq if page.data.changeFreq else "monthly" }}
15 |
16 | {%- endif -%}
17 | {% endfor %}
18 |
19 |
--------------------------------------------------------------------------------
/rocket-docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "docs",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "rocket start",
9 | "docs": "rocket build"
10 | },
11 | "keywords": [],
12 | "author": "",
13 | "license": "ISC",
14 | "devDependencies": {
15 | "@rocket/blog": "^0.4.0",
16 | "@rocket/cli": "^0.10.0",
17 | "@rocket/launch": "^0.6.0"
18 | },
19 | "type": "module",
20 | "dependencies": {
21 | "@rocket/search": "^0.5.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/rocket-docs/rocket.config.js:
--------------------------------------------------------------------------------
1 | import { rocketLaunch } from "@rocket/launch";
2 | import { rocketSearch } from "@rocket/search";
3 | import { adjustPluginOptions } from "plugins-manager";
4 |
5 |
6 | const config = {
7 | absoluteBaseUrl: "https://simplr.github.io/simplr-router/",
8 | pathPrefix: "/simplr-router/",
9 | urlPath: "/simplr-router/",
10 | setupEleventyComputedConfig: [
11 | adjustPluginOptions("socialMediaImage", {
12 | createSocialImageSvg: async ({
13 | title = "",
14 | subTitle = "",
15 | subTitle2 = "",
16 | footer = "",
17 | logo = "",
18 | }) => {
19 | let svgStr = `
20 |
21 |
22 |
23 | ${logo}
24 |
30 |
31 | ${title}
32 |
33 |
34 | ${subTitle}
35 |
36 |
37 |
38 | ${footer}
39 |
40 |
41 | `;
42 | return svgStr;
43 | },
44 | }),
45 | ],
46 | presets: [rocketLaunch(), rocketSearch()]
47 | };
48 |
49 | export default config;
50 |
--------------------------------------------------------------------------------