Skip to content

Commit 92d68d2

Browse files
feat(sync)[ui]: add dark mode and initla placeholder nodes
1 parent 11eca52 commit 92d68d2

3 files changed

Lines changed: 40 additions & 17 deletions

File tree

apps/app/src/components/general/app_settings/sync/devices_lister/index.svelte

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
<script lang="ts">
2-
import { PLATFORM_TYPE_MAP } from '@/lib/states';
32
import { invoke } from '@tauri-apps/api/core';
43
import { listen } from '@tauri-apps/api/event';
54
import { onMount } from 'svelte';
6-
7-
type DiscoveredDevice = {
8-
name: String;
9-
ip: String;
10-
host_name_2: String;
11-
os: keyof typeof PLATFORM_TYPE_MAP;
12-
};
13-
14-
let devices = $state<Record<string, DiscoveredDevice>>({});
5+
import { devices, type DiscoveredDevice } from '../states.svelte';
6+
import { PLATFORM_TYPE_MAP } from '@/lib/states';
157
168
onMount(async () => {
179
await invoke('join_scan_local_network');
1810
listen(
1911
'device_found',
20-
(data) => (devices = data.payload as Record<string, DiscoveredDevice>)
12+
(data) =>
13+
(devices.data = data.payload as Record<string, DiscoveredDevice>)
2114
);
2215
});
2316
</script>
2417

2518
<ul class="list bg-base-100 rounded-box shadow-md">
26-
{#each Object.values(devices) as device}
19+
{#each Object.values(devices.data) as device}
2720
<li class="list-row">
2821
<div>
2922
<div
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { PLATFORM_TYPE_MAP } from '@/lib/states';
2+
3+
export type DiscoveredDevice = {
4+
name: String;
5+
ip: String;
6+
host_name_2: String;
7+
os: keyof typeof PLATFORM_TYPE_MAP;
8+
};
9+
10+
export let devices = $state<{ data: Record<string, DiscoveredDevice> }>({
11+
data: {},
12+
});
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
<script lang="ts">
2-
import { SvelteFlow, Background } from '@xyflow/svelte';
2+
import { SvelteFlow, Background, Position } from '@xyflow/svelte';
33
import '@xyflow/svelte/dist/style.css';
4+
// let nodes = $state.raw([
5+
// { id: '1', position: { x: 0, y: 0 }, data: { label: '1' } },
6+
// { id: '2', position: { x: 0, y: 100 }, data: { label: '2' } },
7+
// ]);
48
let nodes = $state.raw([
5-
{ id: '1', position: { x: 0, y: 0 }, data: { label: '1' } },
6-
{ id: '2', position: { x: 0, y: 100 }, data: { label: '2' } },
9+
...Array.from({ length: 4 }, (_, i) => ({
10+
id: i.toString(),
11+
position: { x: i * 400, y: 0 },
12+
data: { label: `${i}th Device` },
13+
style:
14+
'background-color: oklch(.293 .066 243.157/20%); width: 230px; height: 300px;',
15+
type: 'group',
16+
class: 'light',
17+
})),
18+
...Array.from({ length: 12 }, (_, i) => ({
19+
id: i.toString() + 'node',
20+
position: { x: 40 + (i % 4) * 400, y: 30 + Math.floor(i / 4) * 50 },
21+
data: { label: `Workspace ${i}` },
22+
sourcePosition: Position.Right,
23+
targetPosition: Position.Left,
24+
})),
725
]);
826
927
let edges = $state.raw([{ id: 'e1-2', source: '1', target: '2' }]);
1028
</script>
1129

12-
<div class="w-full h-100">
13-
<SvelteFlow bind:nodes bind:edges fitView>
30+
<div class="w-full h-100 rounded-box overflow-hidden">
31+
<SvelteFlow bind:nodes bind:edges fitView colorMode="dark">
1432
<Background />
1533
</SvelteFlow>
1634
</div>

0 commit comments

Comments
 (0)