Router transition
This commit is contained in:
2
dist/sigpro.esm.js
vendored
2
dist/sigpro.esm.js
vendored
@@ -365,7 +365,7 @@ var For = (source, renderFn, keyFn, tag = "div", props = { style: "display:conte
|
|||||||
var Router = (routes) => {
|
var Router = (routes) => {
|
||||||
const currentPath = $(window.location.hash.replace(/^#/, "") || "/");
|
const currentPath = $(window.location.hash.replace(/^#/, "") || "/");
|
||||||
window.addEventListener("hashchange", () => currentPath(window.location.hash.replace(/^#/, "") || "/"));
|
window.addEventListener("hashchange", () => currentPath(window.location.hash.replace(/^#/, "") || "/"));
|
||||||
const outlet = Tag("div", { class: "router-outlet" });
|
const outlet = Tag("div", { class: "router-transition" });
|
||||||
let currentView = null;
|
let currentView = null;
|
||||||
Watch([currentPath], async () => {
|
Watch([currentPath], async () => {
|
||||||
const path = currentPath();
|
const path = currentPath();
|
||||||
|
|||||||
2
dist/sigpro.esm.min.js
vendored
2
dist/sigpro.esm.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/sigpro.js
vendored
2
dist/sigpro.js
vendored
@@ -408,7 +408,7 @@
|
|||||||
var Router = (routes) => {
|
var Router = (routes) => {
|
||||||
const currentPath = $(window.location.hash.replace(/^#/, "") || "/");
|
const currentPath = $(window.location.hash.replace(/^#/, "") || "/");
|
||||||
window.addEventListener("hashchange", () => currentPath(window.location.hash.replace(/^#/, "") || "/"));
|
window.addEventListener("hashchange", () => currentPath(window.location.hash.replace(/^#/, "") || "/"));
|
||||||
const outlet = Tag("div", { class: "router-outlet" });
|
const outlet = Tag("div", { class: "router-transition" });
|
||||||
let currentView = null;
|
let currentView = null;
|
||||||
Watch([currentPath], async () => {
|
Watch([currentPath], async () => {
|
||||||
const path = currentPath();
|
const path = currentPath();
|
||||||
|
|||||||
2
dist/sigpro.min.js
vendored
2
dist/sigpro.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -19,7 +19,7 @@ Router(routes: Route[]): HTMLElement
|
|||||||
## Usage Patterns
|
## Usage Patterns
|
||||||
|
|
||||||
### 1. Defining Routes
|
### 1. Defining Routes
|
||||||
The `Router` returns a `div` element with the class `.router-outlet`. When the hash changes, the router destroys the previous view and mounts the new one inside this container.
|
The `Router` returns a `div` element with the class `.router-transition`. When the hash changes, the router destroys the previous view and mounts the new one inside this container.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const App = () => Div({ class: "app-layout" }, [
|
const App = () => Div({ class: "app-layout" }, [
|
||||||
@@ -79,11 +79,11 @@ Watch(() => {
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Styling the Outlet
|
## Styling the transition of Router
|
||||||
The router returns a standard `div` with the `.router-outlet` class. You can easily style it or add transitions:
|
The router returns a standard `div` with the `.router-transition` class. You can easily style it or add transitions:
|
||||||
|
|
||||||
```css
|
```css
|
||||||
.router-outlet {
|
.router-transition {
|
||||||
display: block;
|
display: block;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
animation: fadeIn 0.3s ease;
|
animation: fadeIn 0.3s ease;
|
||||||
|
|||||||
@@ -408,7 +408,7 @@
|
|||||||
var Router = (routes) => {
|
var Router = (routes) => {
|
||||||
const currentPath = $(window.location.hash.replace(/^#/, "") || "/");
|
const currentPath = $(window.location.hash.replace(/^#/, "") || "/");
|
||||||
window.addEventListener("hashchange", () => currentPath(window.location.hash.replace(/^#/, "") || "/"));
|
window.addEventListener("hashchange", () => currentPath(window.location.hash.replace(/^#/, "") || "/"));
|
||||||
const outlet = Tag("div", { class: "router-outlet" });
|
const outlet = Tag("div", { class: "router-transition" });
|
||||||
let currentView = null;
|
let currentView = null;
|
||||||
Watch([currentPath], async () => {
|
Watch([currentPath], async () => {
|
||||||
const path = currentPath();
|
const path = currentPath();
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ const For = (source, renderFn, keyFn, tag = "div", props = { style: "display:con
|
|||||||
const Router = (routes) => {
|
const Router = (routes) => {
|
||||||
const currentPath = $(window.location.hash.replace(/^#/, "") || "/");
|
const currentPath = $(window.location.hash.replace(/^#/, "") || "/");
|
||||||
window.addEventListener("hashchange", () => currentPath(window.location.hash.replace(/^#/, "") || "/"));
|
window.addEventListener("hashchange", () => currentPath(window.location.hash.replace(/^#/, "") || "/"));
|
||||||
const outlet = Tag("div", { class: "router-outlet" });
|
const outlet = Tag("div", { class: "router-transition" });
|
||||||
let currentView = null;
|
let currentView = null;
|
||||||
|
|
||||||
Watch([currentPath], async () => {
|
Watch([currentPath], async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user