/
+page.svelte
166 lines (155 loc) 路 4.78 KB
/
+page.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
98
99
100
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<script lang="ts">
import "../style.css"
import { WindowControls, WindowTitlebar } from "$lib"
import ThemeSwitch from "./theme-switch.svelte"
const platforms = ["windows", "macos", "gnome"]
const menuItems = ["File", "Edit", "View", "Account", "Theme"]
</script>
<svelte:head>
<title>Demo-Svelte</title>
</svelte:head>
<div
class="h-screen overflow-auto bg-slate-200 text-black/90 dark:bg-slate-900 dark:text-white"
>
<div class="flex w-[960px] flex-col space-y-3 px-14 py-6">
<ThemeSwitch />
<span class="w-fit rounded bg-orange-200/20 px-2 font-mono"
>@tauri-controls/svelte</span
>
<span
class="w-fit border-b border-slate-400 pb-1 pr-10 dark:border-slate-600 text-lg font-semibold"
>
WindowControls
</span>
<!-- OnlyControls -->
<div
class="flex w-fit space-x-3 rounded-xl border border-dashed border-slate-400 p-3 shadow dark:border-slate-600"
>
{#each platforms as platform}
<WindowControls {platform} />
{/each}
</div>
<!-- OnlyControls Snap -->
justify=true:
<div class="flex border" data-tauri-drag-region>
<WindowControls platform="windows" justify={true} />
</div>
<div class="flex border" data-tauri-drag-region>
<WindowControls platform="macos" justify={true} />
</div>
<span
class="w-fit border-b border-slate-400 pb-1 pr-10 dark:border-slate-600 text-lg font-semibold"
>
WindowTitlebar
</span>
<WindowTitlebar>content</WindowTitlebar>
<!-- Icon+Title+Controls -->
{#each platforms as platform}
<WindowTitlebar
controlsOrder="platform"
class="h-10 rounded-t-lg border border-dashed border-slate-400 bg-white shadow dark:border-slate-600 dark:bg-slate-800"
windowControlsProps={{ platform: platform, class: "" }}
>
<div
class="flex h-full w-full items-center justify-center"
data-tauri-drag-region
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-sailboat mr-2 text-sky-600/70 dark:text-sky-300/70"
>
<path d="M22 18H2a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4Z" />
<path d="M21 14 10 2 3 14h18Z" />
<path d="M10 2v16" />
</svg>
Title
</div>
</WindowTitlebar>
{/each}
<!-- Icon+Menu+Title+Controls -->
{#each platforms as platform}
<WindowTitlebar
controlsOrder="platform"
class="h-10 rounded-t-lg bg-white shadow dark:bg-slate-800"
windowControlsProps={{
platform: platform
}}
data-tauri-drag-region
>
<div class="ml-3 flex items-center" data-tauri-drag-region>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-sailboat mr-2 text-sky-600/70 dark:text-sky-300/70"
>
<path d="M22 18H2a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4Z" />
<path d="M21 14 10 2 3 14h18Z" />
<path d="M10 2v16" />
</svg>
<div
class="flex flex-row space-x-2 whitespace-nowrap rounded-md px-2 py-1 shadow"
>
{#each menuItems as x (x)}
<span>{x}</span>
{/each}
</div>
</div>
<div
class="flex w-full items-center justify-center"
data-tauri-drag-region
>
Title
</div>
</WindowTitlebar>
{/each}
<WindowTitlebar
controlsOrder="right"
windowControlsProps={{
platform: "macos",
class: "bg-rose-700 rounded-full p-2"
}}
>
<div
class="flex items-center justify-center rounded-full bg-sky-500 px-2"
>
titlebar content without w-full (macos but on the right side)
</div>
</WindowTitlebar>
<WindowTitlebar
controlsOrder="left"
windowControlsProps={{
platform: "windows",
class: "bg-rose-700 rounded-full overflow-hidden"
}}
>
<div
class="flex items-center justify-center rounded-full bg-sky-500 px-2"
>
titlebar content without w-full (windows but on the left side)
</div>
</WindowTitlebar>
</div>
</div>
<style lang="postcss">
:global(html.dark) {
background-color: theme(colors.sky.950);
}
:global(html) {
background-color: theme(colors.slate.50);
}
</style>