create-switch-framework-app 0.1.0 → 0.2.0
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/README.md +25 -25
- package/bin/create-switch-framework-app.js +510 -502
- package/package.json +31 -31
- package/templates/electron/base/app/(tabs)/+not-found.js +157 -157
- package/templates/electron/base/app/(tabs)/_layout.js +57 -93
- package/templates/electron/base/app/(tabs)/explore.js +55 -44
- package/templates/electron/base/app/(tabs)/index.js +10 -24
- package/templates/electron/base/app/+not-found.js +148 -158
- package/templates/electron/base/app/_layout.js +24 -44
- package/templates/electron/base/app/index.js +16 -30
- package/templates/electron/base/assets/logo.svg +5 -5
- package/templates/electron/base/components/SwSplashScreen.js +1 -1
- package/templates/electron/base/components/SwStarterSplashScreen.js +130 -140
- package/templates/electron/base/components/SwTabBar.js +146 -153
- package/templates/electron/base/electron/electron-builder.json +19 -19
- package/templates/electron/base/electron/main.js +30 -30
- package/templates/electron/base/electron/preload.js +5 -5
- package/templates/electron/base/index.js +2 -3
- package/templates/electron/base/main.js +1 -1
- package/templates/electron/base/preload.js +1 -1
- package/templates/electron/base/server.js +27 -42
- package/templates/web/base/app/(tabs)/+not-found.js +157 -157
- package/templates/web/base/app/(tabs)/_layout.js +57 -93
- package/templates/web/base/app/(tabs)/explore.js +55 -44
- package/templates/web/base/app/(tabs)/index.js +10 -24
- package/templates/web/base/app/+not-found.js +148 -158
- package/templates/web/base/app/_layout.js +24 -44
- package/templates/web/base/app/index.js +16 -30
- package/templates/web/base/assets/logo.svg +5 -5
- package/templates/web/base/components/SwSplashScreen.js +1 -1
- package/templates/web/base/components/SwStarterSplashScreen.js +130 -140
- package/templates/web/base/components/SwTabBar.js +146 -153
- package/templates/web/base/index.js +2 -3
- package/templates/electron/base/app/(tabs)/register.js +0 -12
- package/templates/electron/base/app/register.js +0 -12
- package/templates/web/base/app/(tabs)/register.js +0 -12
- package/templates/web/base/app/register.js +0 -12
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
name: 'home',
|
|
3
|
-
path: '/home',
|
|
4
|
-
title: 'Home',
|
|
5
|
-
tag: 'sw-home-screen',
|
|
6
|
-
layout: 'tabs'
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export class SwHomeScreen extends HTMLElement {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
this.attachShadow({ mode: 'open' });
|
|
13
|
-
}
|
|
1
|
+
import { SwitchComponent } from 'switch-framework';
|
|
14
2
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
export class SwHomeScreen extends SwitchComponent {
|
|
4
|
+
static screenName = 'home';
|
|
5
|
+
static path = '/home';
|
|
6
|
+
static title = 'Home';
|
|
7
|
+
static tag = 'sw-home-screen';
|
|
8
|
+
static layout = 'tabs';
|
|
18
9
|
|
|
19
10
|
render() {
|
|
20
|
-
|
|
21
|
-
${this.styleSheet()}
|
|
11
|
+
return `
|
|
22
12
|
<div class="wrap">
|
|
23
13
|
<div class="spacer-top"></div>
|
|
24
14
|
|
|
25
15
|
<div class="hero">
|
|
26
16
|
<div class="logo-container">
|
|
27
|
-
<img class="logo" src="/assets/logo.svg" alt="
|
|
17
|
+
<img class="logo" src="/assets/logo.svg" alt="Switch Framework" />
|
|
28
18
|
</div>
|
|
29
19
|
<div class="title">Tabs View</div>
|
|
30
20
|
</div>
|
|
@@ -37,7 +27,7 @@ export class SwHomeScreen extends HTMLElement {
|
|
|
37
27
|
<div class="card">
|
|
38
28
|
<div class="row">
|
|
39
29
|
<div class="l">Try editing</div>
|
|
40
|
-
<div class="r">src/app/index.
|
|
30
|
+
<div class="r">src/app/(tabs)/index.js</div>
|
|
41
31
|
</div>
|
|
42
32
|
<div class="row">
|
|
43
33
|
<div class="l">Dev tools</div>
|
|
@@ -212,7 +202,3 @@ export class SwHomeScreen extends HTMLElement {
|
|
|
212
202
|
`;
|
|
213
203
|
}
|
|
214
204
|
}
|
|
215
|
-
|
|
216
|
-
if (!customElements.get('sw-home-screen')) {
|
|
217
|
-
customElements.define('sw-home-screen', SwHomeScreen);
|
|
218
|
-
}
|
|
@@ -1,158 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<div class="
|
|
38
|
-
|
|
39
|
-
<div class="
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
padding: 18px;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
font-weight: 1000;
|
|
93
|
-
font-size:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
font-weight:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
background: var(--surface_3);
|
|
150
|
-
}
|
|
151
|
-
</style>
|
|
152
|
-
`;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (!customElements.get('sw-user-not-found-screen')) {
|
|
157
|
-
customElements.define('sw-user-not-found-screen', SwUserNotFoundScreen);
|
|
158
|
-
}
|
|
1
|
+
import { SwitchComponent } from 'switch-framework';
|
|
2
|
+
import { navigate, goBack } from 'switch-framework/router';
|
|
3
|
+
|
|
4
|
+
export class SwUserNotFoundScreen extends SwitchComponent {
|
|
5
|
+
static screenName = '+not-found';
|
|
6
|
+
static path = '/+not-found';
|
|
7
|
+
static title = 'Not Found';
|
|
8
|
+
static tag = 'sw-user-not-found-screen';
|
|
9
|
+
static layout = 'stack';
|
|
10
|
+
|
|
11
|
+
static get observedAttributes() {
|
|
12
|
+
return ['path'];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
16
|
+
if (name === 'path' && oldVal !== newVal) {
|
|
17
|
+
this._renderToShadow();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
connected() {
|
|
22
|
+
this.shadowRoot.getElementById('home')?.addEventListener('click', () => {
|
|
23
|
+
navigate('home');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
this.shadowRoot.getElementById('back')?.addEventListener('click', () => {
|
|
27
|
+
goBack();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
render() {
|
|
32
|
+
const path = this.getAttribute('path') || (typeof window !== 'undefined' ? window.location.pathname : '') || '';
|
|
33
|
+
|
|
34
|
+
return `
|
|
35
|
+
<div class="wrap">
|
|
36
|
+
<div class="card">
|
|
37
|
+
<div class="code">404</div>
|
|
38
|
+
<div class="h">This screen does not exist</div>
|
|
39
|
+
<div class="p">No screen is registered for:</div>
|
|
40
|
+
<div class="path">${path}</div>
|
|
41
|
+
|
|
42
|
+
<div class="row">
|
|
43
|
+
<button class="btn" id="home">Go to Home</button>
|
|
44
|
+
<button class="btn secondary" id="back">Go Back</button>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
styleSheet() {
|
|
52
|
+
return `
|
|
53
|
+
<style>
|
|
54
|
+
:host {
|
|
55
|
+
display: block;
|
|
56
|
+
width: 100%;
|
|
57
|
+
min-height: 100dvh;
|
|
58
|
+
font-family: var(--font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
* {
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
font-family: inherit;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.wrap {
|
|
67
|
+
min-height: 100vh;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
padding: 18px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.card {
|
|
75
|
+
width: min(680px, 100%);
|
|
76
|
+
background: transparent;
|
|
77
|
+
border: none;
|
|
78
|
+
border-radius: 18px;
|
|
79
|
+
padding: 18px;
|
|
80
|
+
box-shadow: none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.code {
|
|
84
|
+
font-weight: 1000;
|
|
85
|
+
font-size: 44px;
|
|
86
|
+
line-height: 1;
|
|
87
|
+
color: var(--main_text, #000);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.h {
|
|
91
|
+
margin-top: 10px;
|
|
92
|
+
font-weight: 1000;
|
|
93
|
+
font-size: 20px;
|
|
94
|
+
color: var(--main_text, #000);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.p {
|
|
98
|
+
margin-top: 6px;
|
|
99
|
+
color: var(--sub_text, #666);
|
|
100
|
+
font-weight: 800;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.path {
|
|
104
|
+
margin-top: 10px;
|
|
105
|
+
padding: 10px 12px;
|
|
106
|
+
border-radius: 14px;
|
|
107
|
+
background: var(--surface_2, #f5f5f5);
|
|
108
|
+
border: 1px solid var(--border_light, #e5e5e5);
|
|
109
|
+
font-weight: 900;
|
|
110
|
+
color: var(--main_text, #000);
|
|
111
|
+
word-break: break-word;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.row {
|
|
115
|
+
margin-top: 14px;
|
|
116
|
+
display: flex;
|
|
117
|
+
gap: 10px;
|
|
118
|
+
flex-wrap: wrap;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.btn {
|
|
122
|
+
border: none;
|
|
123
|
+
background: linear-gradient(135deg, #0091ff 0%, #0073e6 100%);
|
|
124
|
+
color: #fff;
|
|
125
|
+
font-weight: 1000;
|
|
126
|
+
border-radius: 999px;
|
|
127
|
+
padding: 10px 14px;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.btn:hover {
|
|
132
|
+
opacity: 0.9;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.btn.secondary {
|
|
136
|
+
background: var(--surface_2, #f5f5f5);
|
|
137
|
+
color: var(--main_text, #000);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.btn.secondary:hover {
|
|
141
|
+
background: var(--surface_3, #eee);
|
|
142
|
+
}
|
|
143
|
+
</style>
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default SwUserNotFoundScreen;
|
|
@@ -1,50 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const screens = registerScreens({
|
|
22
|
-
stackScreens,
|
|
23
|
-
tabsLayout,
|
|
24
|
-
tabScreens,
|
|
25
|
-
validate: true
|
|
26
|
-
}).screens;
|
|
27
|
-
|
|
28
|
-
const layout = {
|
|
29
|
-
splash: 'sw-starter-splash',
|
|
30
|
-
initialRoute: 'index',
|
|
31
|
-
screens,
|
|
32
|
-
|
|
33
|
-
async init({ globalStates, renderSplashscreen }) {
|
|
1
|
+
import { StackLayout, createState, registerComponents } from 'switch-framework';
|
|
2
|
+
import { SwStarterSplashScreen } from '../components/SwStarterSplashScreen.js';
|
|
3
|
+
import { SwTabBar } from '../components/SwTabBar.js';
|
|
4
|
+
import { SwIndexScreen } from './index.js';
|
|
5
|
+
import NotFoundScreen from './+not-found.js';
|
|
6
|
+
import { SwTabsLayout } from './(tabs)/_layout.js';
|
|
7
|
+
|
|
8
|
+
registerComponents([SwStarterSplashScreen, SwTabBar]);
|
|
9
|
+
|
|
10
|
+
export class SwStackLayout extends StackLayout {
|
|
11
|
+
static tag = 'sw-stack-layout';
|
|
12
|
+
static stackScreens = [SwIndexScreen, NotFoundScreen];
|
|
13
|
+
static tabsLayout = SwTabsLayout;
|
|
14
|
+
static splash = 'sw-starter-splash';
|
|
15
|
+
static initialRoute = 'index';
|
|
16
|
+
|
|
17
|
+
static async init({ globalStates, renderSplashscreen }) {
|
|
34
18
|
renderSplashscreen('sw-starter-splash');
|
|
35
19
|
|
|
36
|
-
//
|
|
37
|
-
|
|
20
|
+
// Example: create app-level state
|
|
21
|
+
createState(0, 'example-counter');
|
|
38
22
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
23
|
+
// Simulate async init (e.g. load config, auth check)
|
|
24
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
42
25
|
|
|
43
|
-
return {
|
|
44
|
-
splash: 'sw-starter-splash',
|
|
45
|
-
initialRoute: 'index'
|
|
46
|
-
};
|
|
26
|
+
return { splash: 'sw-starter-splash', initialRoute: 'index' };
|
|
47
27
|
}
|
|
48
|
-
}
|
|
28
|
+
}
|
|
49
29
|
|
|
50
|
-
export default
|
|
30
|
+
export default SwStackLayout.getAppLayout();
|
|
@@ -1,37 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
async connectedCallback() {
|
|
16
|
-
this.render();
|
|
17
|
-
|
|
18
|
-
const replace = globalStates?.getState ? globalStates.getState('replace') : null;
|
|
19
|
-
const redirect = globalStates?.getState ? globalStates.getState('redirect') : null;
|
|
20
|
-
|
|
21
|
-
this.shadowRoot.querySelector('#go_home').addEventListener('click', () => {
|
|
22
|
-
if (typeof replace === 'function') return replace('home');
|
|
1
|
+
import { SwitchComponent } from 'switch-framework';
|
|
2
|
+
import { navigate } from 'switch-framework/router';
|
|
3
|
+
|
|
4
|
+
export class SwIndexScreen extends SwitchComponent {
|
|
5
|
+
static screenName = 'index';
|
|
6
|
+
static path = '/';
|
|
7
|
+
static title = 'Welcome';
|
|
8
|
+
static tag = 'sw-index-screen';
|
|
9
|
+
static layout = 'stack';
|
|
10
|
+
|
|
11
|
+
connected() {
|
|
12
|
+
this.shadowRoot.querySelector('#go_home')?.addEventListener('click', () => {
|
|
13
|
+
navigate('home');
|
|
23
14
|
});
|
|
24
15
|
}
|
|
25
16
|
|
|
26
17
|
render() {
|
|
27
|
-
|
|
28
|
-
${this.styleSheet()}
|
|
18
|
+
return `
|
|
29
19
|
<div class="wrap">
|
|
30
20
|
<div class="spacer-top"></div>
|
|
31
21
|
|
|
32
22
|
<div class="hero">
|
|
33
23
|
<div class="logo-container">
|
|
34
|
-
<img class="logo" src="/assets/logo.svg" alt="
|
|
24
|
+
<img class="logo" src="/assets/logo.svg" alt="Switch Framework" />
|
|
35
25
|
</div>
|
|
36
26
|
<div class="title">Introducing<br>Switch Framework</div>
|
|
37
27
|
</div>
|
|
@@ -44,7 +34,7 @@ export class SwIndexScreen extends HTMLElement {
|
|
|
44
34
|
<div class="card">
|
|
45
35
|
<div class="row">
|
|
46
36
|
<div class="l">Try editing</div>
|
|
47
|
-
<div class="r">src/app/index.
|
|
37
|
+
<div class="r">src/app/index.js</div>
|
|
48
38
|
</div>
|
|
49
39
|
<div class="row">
|
|
50
40
|
<div class="l">Dev tools</div>
|
|
@@ -259,7 +249,3 @@ export class SwIndexScreen extends HTMLElement {
|
|
|
259
249
|
`;
|
|
260
250
|
}
|
|
261
251
|
}
|
|
262
|
-
|
|
263
|
-
if (!customElements.get('sw-index-screen')) {
|
|
264
|
-
customElements.define('sw-index-screen', SwIndexScreen);
|
|
265
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<svg width="160" height="160" viewBox="0 0 160 160" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<rect x="8" y="8" width="144" height="144" rx="36" fill="#E60023"/>
|
|
3
|
-
<path d="M53 59C53 49.6112 60.6112 42 70 42H90C99.3888 42 107 49.6112 107 59V63C107 72.3888 99.3888 80 90 80H78C72.4772 80 68 84.4772 68 90V94C68 103.389 60.3888 111 51 111H50" stroke="white" stroke-width="12" stroke-linecap="round"/>
|
|
4
|
-
<path d="M110 111H94" stroke="white" stroke-width="12" stroke-linecap="round"/>
|
|
5
|
-
</svg>
|
|
1
|
+
<svg width="160" height="160" viewBox="0 0 160 160" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect x="8" y="8" width="144" height="144" rx="36" fill="#E60023"/>
|
|
3
|
+
<path d="M53 59C53 49.6112 60.6112 42 70 42H90C99.3888 42 107 49.6112 107 59V63C107 72.3888 99.3888 80 90 80H78C72.4772 80 68 84.4772 68 90V94C68 103.389 60.3888 111 51 111H50" stroke="white" stroke-width="12" stroke-linecap="round"/>
|
|
4
|
+
<path d="M110 111H94" stroke="white" stroke-width="12" stroke-linecap="round"/>
|
|
5
|
+
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { SwStarterSplashScreen as SwSplashScreen } from './SwStarterSplashScreen.js';
|
|
1
|
+
export { SwStarterSplashScreen as SwSplashScreen } from './SwStarterSplashScreen.js';
|