create-nix-app 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -0
- package/package.json +1 -1
- package/template-nix-ionic/README.md +17 -2
- package/template-nix-ionic/index.html +0 -2
- package/template-nix-ionic/package.json +2 -2
- package/template-nix-ionic/src/main.ts +7 -1
- package/template-nix-ionic-tabs/README.md +69 -0
- package/template-nix-ionic-tabs/capacitor.config.ts +9 -0
- package/template-nix-ionic-tabs/favicon.ico +0 -0
- package/template-nix-ionic-tabs/index.html +16 -0
- package/template-nix-ionic-tabs/package.json +23 -0
- package/template-nix-ionic-tabs/public/nix-js-logo.png +0 -0
- package/template-nix-ionic-tabs/src/main.ts +81 -0
- package/template-nix-ionic-tabs/src/pages/HomePage.ts +35 -0
- package/template-nix-ionic-tabs/src/pages/LoginPage.ts +43 -0
- package/template-nix-ionic-tabs/src/pages/MapPage.ts +49 -0
- package/template-nix-ionic-tabs/src/pages/ProfilePage.ts +46 -0
- package/template-nix-ionic-tabs/src/pages/RouteDetailPage.ts +35 -0
- package/template-nix-ionic-tabs/src/stores/auth.ts +13 -0
- package/template-nix-ionic-tabs/src/style.css +37 -0
- package/template-nix-ionic-tabs/tsconfig.json +25 -0
- package/template-nix-ionic-tabs/vite.config.ts +9 -0
- package/template-vanilla-js/index.html +15 -13
- package/template-vanilla-ts/index.html +13 -13
- package/template-vanilla-ts/package.json +1 -1
- package/template-vite-js/package.json +1 -1
- package/template-vite-ts/package.json +1 -1
package/index.js
CHANGED
|
@@ -25,6 +25,7 @@ async function init() {
|
|
|
25
25
|
{ title: yellow('Vite + TypeScript'), value: 'vite-ts', description: 'Recomendado para DX rápida y tipado estricto' },
|
|
26
26
|
{ title: yellow('Vite + JavaScript'), value: 'vite-js', description: 'Vite sin compilación de TS' },
|
|
27
27
|
{ title: blue('Ionic + Nix.js (Capacitor)'), value: 'nix-ionic', description: 'Template oficial con nix-ionic (Nix.js + Ionic + Capacitor)' },
|
|
28
|
+
{ title: blue('Ionic + Nix.js + Tabs'), value: 'nix-ionic-tabs', description: 'Template completo con IonRouterOutlet + createBottomTabBar + guards' },
|
|
28
29
|
{ title: blue('Vanilla TypeScript'), value: 'vanilla-ts', description: 'Sin bundler, puro TSC' },
|
|
29
30
|
{ title: blue('Vanilla JavaScript'), value: 'vanilla-js', description: 'Cero build, import maps directo en navegador' }
|
|
30
31
|
]
|
package/package.json
CHANGED
|
@@ -40,19 +40,34 @@ src/
|
|
|
40
40
|
|
|
41
41
|
## Modular Loading
|
|
42
42
|
|
|
43
|
-
This template uses **nix-ionic
|
|
43
|
+
This template uses **nix-ionic v1.2.0** modular component loading.
|
|
44
44
|
Import only the bundles your app needs in `main.ts`:
|
|
45
45
|
|
|
46
46
|
```ts
|
|
47
47
|
import { layoutComponents } from "@deijose/nix-ionic/bundles/layout";
|
|
48
|
+
import { navigationComponents } from "@deijose/nix-ionic/bundles/navigation";
|
|
48
49
|
import { formComponents } from "@deijose/nix-ionic/bundles/forms";
|
|
49
50
|
import { overlayComponents } from "@deijose/nix-ionic/bundles/overlays";
|
|
51
|
+
import { home, homeOutline } from "ionicons/icons";
|
|
50
52
|
|
|
51
|
-
setupNixIonic({
|
|
53
|
+
setupNixIonic({
|
|
54
|
+
components: [...layoutComponents, ...navigationComponents, ...formComponents],
|
|
55
|
+
icons: { home, "home-outline": homeOutline },
|
|
56
|
+
});
|
|
52
57
|
```
|
|
53
58
|
|
|
54
59
|
Available bundles: `layout`, `navigation`, `forms`, `lists`, `feedback`, `buttons`, `overlays`, `all`.
|
|
55
60
|
|
|
61
|
+
## Tabs and Bottom Navigation
|
|
62
|
+
|
|
63
|
+
For tab-based apps, use the built-in helper:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { createBottomTabBar } from "@deijose/nix-ionic";
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
It provides active-path sync without manual `window.location` listeners.
|
|
70
|
+
|
|
56
71
|
## Learn More
|
|
57
72
|
|
|
58
73
|
- [Nix.js Docs](https://github.com/DeijoseDevelop/nix-js)
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
<meta charset="UTF-8">
|
|
6
6
|
<link rel="icon" href="/favicon.ico">
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
-
<script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
|
|
9
|
-
<script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
|
|
10
8
|
<title>Nix.js + Vite TS</title>
|
|
11
9
|
</head>
|
|
12
10
|
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"@capacitor/android": "^8.2.0",
|
|
12
12
|
"@capacitor/cli": "^8.2.0",
|
|
13
13
|
"@capacitor/core": "^8.2.0",
|
|
14
|
-
"@deijose/nix-ionic": "^
|
|
15
|
-
"@deijose/nix-js": "^1.
|
|
14
|
+
"@deijose/nix-ionic": "^1.2.0",
|
|
15
|
+
"@deijose/nix-js": "^1.9.0",
|
|
16
16
|
"@ionic/core": "^8.8.1",
|
|
17
17
|
"ionicons": "^8.0.13"
|
|
18
18
|
},
|
|
@@ -11,18 +11,24 @@ import "./style.css";
|
|
|
11
11
|
// 2. Framework
|
|
12
12
|
import { NixComponent, html, mount } from "@deijose/nix-js";
|
|
13
13
|
import { setupNixIonic, IonRouterOutlet } from "@deijose/nix-ionic";
|
|
14
|
+
import { home, homeOutline } from "ionicons/icons";
|
|
14
15
|
|
|
15
16
|
// 3. Modular component bundles — import only what your app needs
|
|
16
17
|
import { layoutComponents } from "@deijose/nix-ionic/bundles/layout";
|
|
17
18
|
import { formComponents } from "@deijose/nix-ionic/bundles/forms";
|
|
18
19
|
import { listComponents } from "@deijose/nix-ionic/bundles/lists";
|
|
20
|
+
import { navigationComponents } from "@deijose/nix-ionic/bundles/navigation";
|
|
19
21
|
|
|
20
22
|
// 4. Pages
|
|
21
23
|
import { HomePage } from "./pages/HomePage";
|
|
22
24
|
|
|
23
25
|
// Register Ionic components
|
|
24
26
|
setupNixIonic({
|
|
25
|
-
components: [...layoutComponents, ...formComponents, ...listComponents],
|
|
27
|
+
components: [...layoutComponents, ...formComponents, ...listComponents, ...navigationComponents],
|
|
28
|
+
icons: {
|
|
29
|
+
home,
|
|
30
|
+
"home-outline": homeOutline,
|
|
31
|
+
},
|
|
26
32
|
});
|
|
27
33
|
|
|
28
34
|
// 5. Router
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Nix-Ionic Tabs App
|
|
2
|
+
|
|
3
|
+
Complete starter template with:
|
|
4
|
+
|
|
5
|
+
- `IonRouterOutlet` route definitions and guards
|
|
6
|
+
- `createBottomTabBar()` bottom navigation
|
|
7
|
+
- `useRouter()` navigation actions
|
|
8
|
+
- `useRouterState()` reactive route state
|
|
9
|
+
- `setupNixIonic({ icons })` custom icon registration
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install
|
|
15
|
+
npm run dev
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Build
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm run build
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Included Routes
|
|
25
|
+
|
|
26
|
+
- `/login` (public)
|
|
27
|
+
- `/` (Home tab, protected)
|
|
28
|
+
- `/map` (Map tab, protected)
|
|
29
|
+
- `/map/route/:id` (detail page, protected, outside tab flow)
|
|
30
|
+
- `/profile` (Profile tab, protected)
|
|
31
|
+
|
|
32
|
+
## Files to Explore
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
src/
|
|
36
|
+
├── main.ts
|
|
37
|
+
├── style.css
|
|
38
|
+
├── stores/
|
|
39
|
+
│ └── auth.ts
|
|
40
|
+
└── pages/
|
|
41
|
+
├── LoginPage.ts
|
|
42
|
+
├── HomePage.ts
|
|
43
|
+
├── MapPage.ts
|
|
44
|
+
├── RouteDetailPage.ts
|
|
45
|
+
└── ProfilePage.ts
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Core Pattern
|
|
49
|
+
|
|
50
|
+
`main.ts` wires everything:
|
|
51
|
+
|
|
52
|
+
1. Registers Ionic bundles and icons.
|
|
53
|
+
2. Creates `IonRouterOutlet` with `beforeEnter` auth guard.
|
|
54
|
+
3. Creates tabs with `createBottomTabBar()`.
|
|
55
|
+
4. Mounts both outlet and tabs inside `<ion-app>`.
|
|
56
|
+
|
|
57
|
+
## Android (Capacitor)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run build
|
|
61
|
+
npx cap sync android
|
|
62
|
+
npx cap open android
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Learn More
|
|
66
|
+
|
|
67
|
+
- [Nix-Ionic on npm](https://www.npmjs.com/package/@deijose/nix-ionic)
|
|
68
|
+
- [Ionic Components](https://ionicframework.com/docs/components)
|
|
69
|
+
- [Capacitor Docs](https://capacitorjs.com/docs)
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<link rel="icon" href="/favicon.ico">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
+
<title>Nix.js + Vite TS</title>
|
|
9
|
+
</head>
|
|
10
|
+
|
|
11
|
+
<body>
|
|
12
|
+
<div id="app"></div>
|
|
13
|
+
<script type="module" src="/src/main.ts"></script>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nix-ionic-tabs-app",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "tsc --noEmit && vite build",
|
|
8
|
+
"preview": "vite preview"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@capacitor/android": "^8.2.0",
|
|
12
|
+
"@capacitor/cli": "^8.2.0",
|
|
13
|
+
"@capacitor/core": "^8.2.0",
|
|
14
|
+
"@deijose/nix-ionic": "^1.2.0",
|
|
15
|
+
"@deijose/nix-js": "^1.9.0",
|
|
16
|
+
"@ionic/core": "^8.8.1",
|
|
17
|
+
"ionicons": "^8.0.13"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "~5.9.3",
|
|
21
|
+
"vite": "^8.0.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import "@ionic/core/css/core.css";
|
|
2
|
+
import "@ionic/core/css/normalize.css";
|
|
3
|
+
import "@ionic/core/css/structure.css";
|
|
4
|
+
import "@ionic/core/css/typography.css";
|
|
5
|
+
import "@ionic/core/css/padding.css";
|
|
6
|
+
import "@ionic/core/css/flex-utils.css";
|
|
7
|
+
import "@ionic/core/css/display.css";
|
|
8
|
+
import "./style.css";
|
|
9
|
+
|
|
10
|
+
import { NixComponent, html, mount } from "@deijose/nix-js";
|
|
11
|
+
import { setupNixIonic, IonRouterOutlet, createBottomTabBar } from "@deijose/nix-ionic";
|
|
12
|
+
import { layoutComponents } from "@deijose/nix-ionic/bundles/layout";
|
|
13
|
+
import { navigationComponents } from "@deijose/nix-ionic/bundles/navigation";
|
|
14
|
+
import { listComponents } from "@deijose/nix-ionic/bundles/lists";
|
|
15
|
+
import { buttonComponents } from "@deijose/nix-ionic/bundles/buttons";
|
|
16
|
+
import {
|
|
17
|
+
home,
|
|
18
|
+
homeOutline,
|
|
19
|
+
map,
|
|
20
|
+
mapOutline,
|
|
21
|
+
person,
|
|
22
|
+
personOutline,
|
|
23
|
+
logInOutline,
|
|
24
|
+
} from "ionicons/icons";
|
|
25
|
+
|
|
26
|
+
import { HomePage } from "./pages/HomePage";
|
|
27
|
+
import { MapPage } from "./pages/MapPage";
|
|
28
|
+
import { ProfilePage } from "./pages/ProfilePage";
|
|
29
|
+
import { LoginPage } from "./pages/LoginPage";
|
|
30
|
+
import { RouteDetailPage } from "./pages/RouteDetailPage";
|
|
31
|
+
import { authStore } from "./stores/auth";
|
|
32
|
+
|
|
33
|
+
setupNixIonic({
|
|
34
|
+
components: [
|
|
35
|
+
...layoutComponents,
|
|
36
|
+
...navigationComponents,
|
|
37
|
+
...listComponents,
|
|
38
|
+
...buttonComponents,
|
|
39
|
+
],
|
|
40
|
+
icons: {
|
|
41
|
+
home,
|
|
42
|
+
"home-outline": homeOutline,
|
|
43
|
+
map,
|
|
44
|
+
"map-outline": mapOutline,
|
|
45
|
+
person,
|
|
46
|
+
"person-outline": personOutline,
|
|
47
|
+
"log-in-outline": logInOutline,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const requireAuth = () => (authStore.isAuthenticated.value ? true : "/login");
|
|
52
|
+
|
|
53
|
+
const outlet = new IonRouterOutlet([
|
|
54
|
+
{ path: "/login", component: (ctx) => new LoginPage(ctx) },
|
|
55
|
+
{ path: "/", component: (ctx) => new HomePage(ctx), beforeEnter: requireAuth },
|
|
56
|
+
{ path: "/map", component: (ctx) => new MapPage(ctx), beforeEnter: requireAuth },
|
|
57
|
+
{ path: "/map/route/:id", component: (ctx) => new RouteDetailPage(ctx), beforeEnter: requireAuth },
|
|
58
|
+
{ path: "/profile", component: (ctx) => new ProfilePage(ctx), beforeEnter: requireAuth },
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
const tabs = createBottomTabBar(
|
|
62
|
+
[
|
|
63
|
+
{ path: "/", label: "Home", icon: "home-outline", activeIcon: "home", exact: true },
|
|
64
|
+
{ path: "/map", label: "Map", icon: "map-outline", activeIcon: "map" },
|
|
65
|
+
{ path: "/profile", label: "Profile", icon: "person-outline", activeIcon: "person" },
|
|
66
|
+
],
|
|
67
|
+
{
|
|
68
|
+
className: "app-tab-bar",
|
|
69
|
+
activeClassName: "tab-active",
|
|
70
|
+
navigationDirection: "root",
|
|
71
|
+
hideWhen: (path) => path === "/login" || path.startsWith("/map/route/"),
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
class App extends NixComponent {
|
|
76
|
+
override render() {
|
|
77
|
+
return html`<ion-app>${outlet}${tabs}</ion-app>`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
mount(new App(), "#app");
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { html } from "@deijose/nix-js";
|
|
2
|
+
import { IonPage, useRouter } from "@deijose/nix-ionic";
|
|
3
|
+
import type { PageContext } from "@deijose/nix-ionic";
|
|
4
|
+
|
|
5
|
+
export class HomePage extends IonPage {
|
|
6
|
+
constructor(ctx: PageContext) {
|
|
7
|
+
super(ctx.lc);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
override render() {
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
|
|
13
|
+
return html`
|
|
14
|
+
<ion-header>
|
|
15
|
+
<ion-toolbar>
|
|
16
|
+
<ion-title>Home</ion-title>
|
|
17
|
+
</ion-toolbar>
|
|
18
|
+
</ion-header>
|
|
19
|
+
|
|
20
|
+
<ion-content class="ion-padding">
|
|
21
|
+
<ion-card>
|
|
22
|
+
<ion-card-header>
|
|
23
|
+
<ion-card-title>Nix-Ionic Tabs Template</ion-card-title>
|
|
24
|
+
<ion-card-subtitle>IonRouterOutlet + createBottomTabBar</ion-card-subtitle>
|
|
25
|
+
</ion-card-header>
|
|
26
|
+
<ion-card-content>
|
|
27
|
+
<p>This page is protected by <code>beforeEnter</code> and rendered inside Ionic's router outlet.</p>
|
|
28
|
+
<ion-button expand="block" @click=${() => router.navigate("/map")}>Open Map Tab</ion-button>
|
|
29
|
+
<ion-button expand="block" fill="outline" @click=${() => router.navigate("/profile")}>Go to Profile Tab</ion-button>
|
|
30
|
+
</ion-card-content>
|
|
31
|
+
</ion-card>
|
|
32
|
+
</ion-content>
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { html } from "@deijose/nix-js";
|
|
2
|
+
import { IonPage, useRouter } from "@deijose/nix-ionic";
|
|
3
|
+
import type { PageContext } from "@deijose/nix-ionic";
|
|
4
|
+
import { authStore } from "../stores/auth";
|
|
5
|
+
|
|
6
|
+
export class LoginPage extends IonPage {
|
|
7
|
+
constructor(ctx: PageContext) {
|
|
8
|
+
super(ctx.lc);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
override render() {
|
|
12
|
+
const router = useRouter();
|
|
13
|
+
|
|
14
|
+
return html`
|
|
15
|
+
<ion-header>
|
|
16
|
+
<ion-toolbar>
|
|
17
|
+
<ion-title>Login</ion-title>
|
|
18
|
+
</ion-toolbar>
|
|
19
|
+
</ion-header>
|
|
20
|
+
|
|
21
|
+
<ion-content class="ion-padding login-page">
|
|
22
|
+
<ion-card>
|
|
23
|
+
<ion-card-header>
|
|
24
|
+
<ion-card-title>Protected Routes Example</ion-card-title>
|
|
25
|
+
<ion-card-subtitle>Login to unlock tabs and pages</ion-card-subtitle>
|
|
26
|
+
</ion-card-header>
|
|
27
|
+
<ion-card-content>
|
|
28
|
+
<ion-button
|
|
29
|
+
expand="block"
|
|
30
|
+
@click=${() => {
|
|
31
|
+
authStore.login();
|
|
32
|
+
router.replace("/");
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<ion-icon slot="start" name="log-in-outline"></ion-icon>
|
|
36
|
+
Sign in
|
|
37
|
+
</ion-button>
|
|
38
|
+
</ion-card-content>
|
|
39
|
+
</ion-card>
|
|
40
|
+
</ion-content>
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { html } from "@deijose/nix-js";
|
|
2
|
+
import { IonPage, useRouter } from "@deijose/nix-ionic";
|
|
3
|
+
import type { PageContext } from "@deijose/nix-ionic";
|
|
4
|
+
|
|
5
|
+
const demoRoutes = [
|
|
6
|
+
{ id: "101", name: "Mountain Loop" },
|
|
7
|
+
{ id: "102", name: "Coastal Ride" },
|
|
8
|
+
{ id: "103", name: "City Night Route" },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
export class MapPage extends IonPage {
|
|
12
|
+
constructor(ctx: PageContext) {
|
|
13
|
+
super(ctx.lc);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override render() {
|
|
17
|
+
const router = useRouter();
|
|
18
|
+
|
|
19
|
+
return html`
|
|
20
|
+
<ion-header>
|
|
21
|
+
<ion-toolbar>
|
|
22
|
+
<ion-title>Map</ion-title>
|
|
23
|
+
</ion-toolbar>
|
|
24
|
+
</ion-header>
|
|
25
|
+
|
|
26
|
+
<ion-content class="ion-padding">
|
|
27
|
+
<ion-card>
|
|
28
|
+
<ion-card-header>
|
|
29
|
+
<ion-card-title>Route List</ion-card-title>
|
|
30
|
+
<ion-card-subtitle>Tap one route to open a detail page outside tabs</ion-card-subtitle>
|
|
31
|
+
</ion-card-header>
|
|
32
|
+
<ion-card-content>
|
|
33
|
+
${demoRoutes.map(
|
|
34
|
+
(route) => html`
|
|
35
|
+
<ion-button
|
|
36
|
+
expand="block"
|
|
37
|
+
fill="outline"
|
|
38
|
+
@click=${() => router.navigate(`/map/route/${route.id}`)}
|
|
39
|
+
>
|
|
40
|
+
${route.name}
|
|
41
|
+
</ion-button>
|
|
42
|
+
`,
|
|
43
|
+
)}
|
|
44
|
+
</ion-card-content>
|
|
45
|
+
</ion-card>
|
|
46
|
+
</ion-content>
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { html } from "@deijose/nix-js";
|
|
2
|
+
import { IonPage, useRouter, useRouterState } from "@deijose/nix-ionic";
|
|
3
|
+
import type { PageContext } from "@deijose/nix-ionic";
|
|
4
|
+
import { authStore } from "../stores/auth";
|
|
5
|
+
|
|
6
|
+
export class ProfilePage extends IonPage {
|
|
7
|
+
constructor(ctx: PageContext) {
|
|
8
|
+
super(ctx.lc);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
override render() {
|
|
12
|
+
const router = useRouter();
|
|
13
|
+
const routerState = useRouterState();
|
|
14
|
+
|
|
15
|
+
return html`
|
|
16
|
+
<ion-header>
|
|
17
|
+
<ion-toolbar>
|
|
18
|
+
<ion-title>Profile</ion-title>
|
|
19
|
+
</ion-toolbar>
|
|
20
|
+
</ion-header>
|
|
21
|
+
|
|
22
|
+
<ion-content class="ion-padding">
|
|
23
|
+
<ion-card>
|
|
24
|
+
<ion-card-header>
|
|
25
|
+
<ion-card-title>Router State Demo</ion-card-title>
|
|
26
|
+
<ion-card-subtitle>Reactive path and params from useRouterState()</ion-card-subtitle>
|
|
27
|
+
</ion-card-header>
|
|
28
|
+
<ion-card-content>
|
|
29
|
+
<p><strong>Current path:</strong> ${() => routerState.path.value}</p>
|
|
30
|
+
<p><strong>Can go back:</strong> ${() => String(routerState.canGoBack.value)}</p>
|
|
31
|
+
<ion-button
|
|
32
|
+
expand="block"
|
|
33
|
+
color="danger"
|
|
34
|
+
@click=${() => {
|
|
35
|
+
authStore.logout();
|
|
36
|
+
router.replace("/login");
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
Sign out
|
|
40
|
+
</ion-button>
|
|
41
|
+
</ion-card-content>
|
|
42
|
+
</ion-card>
|
|
43
|
+
</ion-content>
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { html } from "@deijose/nix-js";
|
|
2
|
+
import { IonPage, IonBackButton } from "@deijose/nix-ionic";
|
|
3
|
+
import type { PageContext } from "@deijose/nix-ionic";
|
|
4
|
+
|
|
5
|
+
export class RouteDetailPage extends IonPage {
|
|
6
|
+
private routeId: string;
|
|
7
|
+
|
|
8
|
+
constructor(ctx: PageContext) {
|
|
9
|
+
super(ctx.lc);
|
|
10
|
+
this.routeId = ctx.params.id ?? "unknown";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override render() {
|
|
14
|
+
return html`
|
|
15
|
+
<ion-header>
|
|
16
|
+
<ion-toolbar>
|
|
17
|
+
<ion-buttons slot="start">${IonBackButton("/map")}</ion-buttons>
|
|
18
|
+
<ion-title>Route #${this.routeId}</ion-title>
|
|
19
|
+
</ion-toolbar>
|
|
20
|
+
</ion-header>
|
|
21
|
+
|
|
22
|
+
<ion-content class="ion-padding">
|
|
23
|
+
<ion-card>
|
|
24
|
+
<ion-card-header>
|
|
25
|
+
<ion-card-title>Route Detail</ion-card-title>
|
|
26
|
+
<ion-card-subtitle>Dynamic params + IonBackButton in one place</ion-card-subtitle>
|
|
27
|
+
</ion-card-header>
|
|
28
|
+
<ion-card-content>
|
|
29
|
+
Current route id: <strong>${this.routeId}</strong>
|
|
30
|
+
</ion-card-content>
|
|
31
|
+
</ion-card>
|
|
32
|
+
</ion-content>
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--ion-font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Roboto", sans-serif;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
* {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
ion-content {
|
|
10
|
+
--padding-bottom: 84px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.app-tab-bar {
|
|
14
|
+
--background: #ffffff;
|
|
15
|
+
--color: var(--ion-color-medium);
|
|
16
|
+
--color-selected: var(--ion-color-primary);
|
|
17
|
+
border-top: 1px solid rgba(0, 0, 0, 0.08);
|
|
18
|
+
box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.app-tab-bar ion-tab-button.tab-active {
|
|
22
|
+
font-weight: 600;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.app-tab-bar ion-tab-button ion-icon {
|
|
26
|
+
font-size: 1.25rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.login-page {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ion-card {
|
|
36
|
+
border-radius: 16px;
|
|
37
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": [
|
|
7
|
+
"ES2022",
|
|
8
|
+
"DOM",
|
|
9
|
+
"DOM.Iterable"
|
|
10
|
+
],
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"strict": true,
|
|
18
|
+
"noUnusedLocals": true,
|
|
19
|
+
"noUnusedParameters": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true
|
|
21
|
+
},
|
|
22
|
+
"include": [
|
|
23
|
+
"src"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<link rel="icon" href="/public/favicon.ico">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
+
<title>¡Bienvenido a Nix.js!</title>
|
|
9
|
+
<script type="importmap">
|
|
9
10
|
{
|
|
10
11
|
"imports": {
|
|
11
|
-
"@deijose/nix-js": "https://cdn.jsdelivr.net/npm/@deijose/nix-js@1.
|
|
12
|
+
"@deijose/nix-js": "https://cdn.jsdelivr.net/npm/@deijose/nix-js@1.9.0/+esm"
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
</script>
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
<link rel="stylesheet" href="./src/style.css">
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<div id="app"></div>
|
|
21
|
+
<script type="module" src="./src/main.js"></script>
|
|
22
|
+
</body>
|
|
17
23
|
|
|
18
|
-
<body>
|
|
19
|
-
<div id="app"></div>
|
|
20
|
-
<script type="module" src="./src/main.js"></script>
|
|
21
|
-
</body>
|
|
22
24
|
</html>
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<link rel="icon" href="/public/favicon.ico">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
+
<title>Nix.js Vanilla TS</title>
|
|
9
|
+
<script type="importmap">
|
|
10
10
|
{
|
|
11
11
|
"imports": {
|
|
12
|
-
"@deijose/nix-js": "https://cdn.jsdelivr.net/npm/@deijose/nix-js@1.
|
|
12
|
+
"@deijose/nix-js": "https://cdn.jsdelivr.net/npm/@deijose/nix-js@1.9.0/+esm"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
</script>
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
<link rel="stylesheet" href="./src/style.css">
|
|
17
|
+
</head>
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
<body>
|
|
20
|
+
<div id="app"></div>
|
|
21
|
+
<script type="module" src="./dist/main.js"></script>
|
|
22
|
+
</body>
|
|
23
23
|
|
|
24
24
|
</html>
|