Skip to content

Commit 9bba20f

Browse files
committed
feat: modal added
1 parent d9f985d commit 9bba20f

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

infrastructure/control-panel/src/routes/example/+page.svelte

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import { onMount } from 'svelte';
33
import '@xyflow/svelte/dist/style.css';
44
import type { Node, Edge, NodeTypes } from '@xyflow/svelte';
5-
65
import {Logs, VaultNode} from '$lib/fragments';
76
import { HugeiconsIcon } from '@hugeicons/svelte';
87
import { PauseFreeIcons, PlayFreeIcons } from '@hugeicons/core-free-icons';
9-
import {ButtonAction} from '$lib/ui';
8+
import {ButtonAction, Checkbox} from '$lib/ui';
9+
import { Modal } from 'flowbite-svelte';
1010
1111
1212
let SvelteFlowComponent: typeof import('@xyflow/svelte').SvelteFlow | null = $state(null);
@@ -16,7 +16,8 @@
1616
};
1717
1818
let isPaused = $state(false);
19-
let modal: HTMLDialogElement | undefined = $state();
19+
let isModalOpen= $state(false);
20+
let selectedVaults = $state([]);
2021
2122
let nodes: Node[] = $state([
2223
{
@@ -117,7 +118,14 @@
117118
from: 'Pic'
118119
}
119120
];
120-
121+
122+
let vaults = [
123+
{ id: 'vault-1', name: 'Personal Documents', sublabel: 'Important files' },
124+
{ id: 'vault-2', name: 'Family Photos', sublabel: 'Cherished memories' },
125+
{ id: 'vault-3', name: 'Work Projects', sublabel: 'Current tasks and files' },
126+
{ id: 'vault-4', name: 'Archived Data', sublabel: 'Old projects and backups' },
127+
];
128+
121129
onMount(async () => {
122130
const mod = await import('@xyflow/svelte');
123131
SvelteFlowComponent = mod.SvelteFlow;
@@ -129,7 +137,7 @@
129137
<div class="w-full flex justify-between items-center p-4 bg-white shadow-sm z-10">
130138
<h4 class="text-xl text-gray-800 font-semibold">Live Monitoring</h4>
131139
<div class="flex gap-2">
132-
<ButtonAction class="w-[max-content]" variant="soft" size="sm" callback={() => {modal?.show()}}>Add Vault</ButtonAction>
140+
<ButtonAction class="w-[max-content]" variant="soft" size="sm" callback={() => {isModalOpen = !isModalOpen}}>Add Vault</ButtonAction>
133141
<button
134142
onclick={() => isPaused = !isPaused}
135143
class="px-4 py-2 flex items-center gap-2 text-base font-geist font-medium text-gray-700 bg-white border border-[#e5e5e5] rounded-full shadow-md hover:bg-gray-50 transition-colors"
@@ -157,9 +165,26 @@
157165
<div class="flex-grow flex justify-center items-center text-gray-700">Loading flow chart...</div>
158166
{/if}
159167
</div>
160-
<Logs class="w-[40%]" {events} bind:activeEventIndex={currentSelectedEventIndex} />
168+
<Logs class="w-[40%]" {events} bind:activeEventIndex={currentSelectedEventIndex}/>
161169
</section>
162170

171+
<Modal bind:open={isModalOpen} class="absolute top-[50%] start-[50%] translate-x-[-50%] translate-y-[-50%] max-w-[30vw] w-full p-4" closeBtnClass="fixed end-4 top-4">
172+
<h4 class="text-primary mb-2">Search vaults</h4>
173+
<input type="search" value="" placeholder="Please search to vaults to add" class="w-full border-transparent outline-transparent bg-gray rounded-4xl py-3 px-4 font-geist text-black text-base">
174+
175+
<ul class="mt-4">
176+
{#each vaults as vault (vault.id)}
177+
<li class="flex items-center gap-4 px-4 py-1 mb-2 rounded-2xl bg-gray hover:bg-gray-200">
178+
<input id={vault.id} type="checkbox" value={vault.id} bind:group={selectedVaults}>
179+
180+
<label for={vault.id} class="cursor-pointer">
181+
<p>{vault.name}</p>
182+
<p class="small">{vault.sublabel}</p>
183+
</label>
184+
</li>
185+
{/each}
186+
</ul>
187+
</Modal>
163188

164189
<style>
165190
/*

0 commit comments

Comments
 (0)