-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIndex.svelte
97 lines (87 loc) · 1.67 KB
/
Index.svelte
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
38
39
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<script>
import Router, { push } from "svelte-spa-router";
import { wrap } from "svelte-spa-router/wrap";
import { links } from "../demos/routes.js";
import { links as localLinks } from "./routes.js";
import {
Material,
Willow,
WillowDark,
Globals,
Locale,
popupContainer,
} from "wx-svelte-core";
const defRoute = links[0][0].replace(/\/:skin$/, "/willow");
const routes = {
"/": wrap({
component: {},
conditions: () => {
push(defRoute);
return false;
},
}),
};
let skin = $state("willow");
function onRouteChange(path) {
const parts = path.split("/");
skin = parts[2];
}
const allLinks = [...localLinks, ...links];
allLinks.forEach(a => {
const [path, , component] = a;
routes[path] = wrap({
component,
userData: a,
conditions: x => {
onRouteChange(x.location);
return true;
},
});
});
</script>
<Willow />
<WillowDark />
<Material />
<div class="wx-{skin}-theme content" use:popupContainer>
<Locale>
<Globals>
<Router {routes} />
</Globals>
</Locale>
</div>
<style>
.content {
height: 100%;
width: 100%;
overflow: hidden;
padding: 0;
margin: 0;
}
.content :global(h4) {
font-size: 16px;
font-weight: 300;
margin-bottom: 12px;
border-bottom: var(--wx-border);
}
.content :global(h3) {
font-size: 18px;
margin: 12px 0;
font-weight: normal;
}
.content :global(.demo-box) {
margin: 20px;
}
.content :global(.demo-box + .demo-box) {
margin-top: 40px;
}
.content :global(.demo-code) {
font-family: monospace;
line-height: 30px;
}
.content :global(.demo-status) {
height: 30px;
line-height: 30px;
background: rgba(0, 0, 0, 0.15);
padding-left: 10px;
}
</style>