enzostvs HF Staff commited on
Commit
821597b
·
1 Parent(s): 42f847d

improve UI responsive

Browse files
src/lib/components/flow/actions/PanelCanvasActions.svelte CHANGED
@@ -5,7 +5,6 @@
5
  import { Button } from '$lib/components/ui/button';
6
  import { viewState } from '$lib/state/view.svelte';
7
  import { useSvelteFlow } from '@xyflow/svelte';
8
- import * as Tooltip from '$lib/components/ui/tooltip/index.js';
9
 
10
  const { fitView, zoomIn, zoomOut, getZoom } = useSvelteFlow();
11
 
@@ -18,7 +17,10 @@
18
  }
19
  </script>
20
 
21
- <Panel position="bottom-center" class="flex items-center justify-start gap-2 p-1 lg:p-2">
 
 
 
22
  <div
23
  class="inline-flex w-fit flex-row gap-0.5 rounded-lg border border-border bg-background/30 p-1 backdrop-blur-sm dark:bg-gray-900/30"
24
  >
 
5
  import { Button } from '$lib/components/ui/button';
6
  import { viewState } from '$lib/state/view.svelte';
7
  import { useSvelteFlow } from '@xyflow/svelte';
 
8
 
9
  const { fitView, zoomIn, zoomOut, getZoom } = useSvelteFlow();
10
 
 
17
  }
18
  </script>
19
 
20
+ <Panel
21
+ position="bottom-center"
22
+ class="flex items-center justify-start gap-2 p-1 max-lg:hidden lg:p-2"
23
+ >
24
  <div
25
  class="inline-flex w-fit flex-row gap-0.5 rounded-lg border border-border bg-background/30 p-1 backdrop-blur-sm dark:bg-gray-900/30"
26
  >
src/lib/components/flow/actions/PanelRightActions.svelte CHANGED
@@ -1,6 +1,6 @@
1
  <script lang="ts">
2
- import { Contrast, CreditCard, Monitor, Moon, RefreshCcw, Sun } from '@lucide/svelte';
3
- import { Panel, useSvelteFlow } from '@xyflow/svelte';
4
  import { setMode } from 'mode-watcher';
5
 
6
  import { Button } from '$lib/components/ui/button';
@@ -11,35 +11,12 @@
11
  import BillingManagementModal from '$lib/components/billing/BillingManagementModal.svelte';
12
  import InstructionsModal from './InstructionsModal.svelte';
13
  import { breakpointsState } from '$lib/state/breakpoints.svelte';
14
-
15
- let { canReset }: { canReset: boolean } = $props();
16
-
17
- const { getNodes } = useSvelteFlow();
18
- let showResetButton = $derived(getNodes().length > 1);
19
-
20
- function handleReset() {
21
- if (!canReset) return;
22
- const ok = confirm('Are you sure you want to reset the flow?');
23
- if (ok) {
24
- location.reload();
25
- }
26
- }
27
  </script>
28
 
29
- <Panel position="top-right" class="flex items-center justify-end gap-2 p-1 lg:p-2">
30
- {#if showResetButton}
31
- <Button
32
- variant="outline"
33
- size={breakpointsState.isMobile ? 'icon-sm' : 'default'}
34
- class=""
35
- onclick={handleReset}
36
- >
37
- <RefreshCcw />
38
- {#if !breakpointsState.isMobile}
39
- Start new chat
40
- {/if}
41
- </Button>
42
- {/if}
43
  <InstructionsModal />
44
  <DropdownMenu.Root>
45
  <DropdownMenu.Trigger>
 
1
  <script lang="ts">
2
+ import { Contrast, CreditCard, Monitor, Moon, Sun } from '@lucide/svelte';
3
+ import { Panel } from '@xyflow/svelte';
4
  import { setMode } from 'mode-watcher';
5
 
6
  import { Button } from '$lib/components/ui/button';
 
11
  import BillingManagementModal from '$lib/components/billing/BillingManagementModal.svelte';
12
  import InstructionsModal from './InstructionsModal.svelte';
13
  import { breakpointsState } from '$lib/state/breakpoints.svelte';
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  </script>
15
 
16
+ <Panel
17
+ position={breakpointsState.isMobile ? 'bottom-right' : 'top-right'}
18
+ class="flex items-center justify-end gap-2 p-1 lg:p-2"
19
+ >
 
 
 
 
 
 
 
 
 
 
20
  <InstructionsModal />
21
  <DropdownMenu.Root>
22
  <DropdownMenu.Trigger>
src/lib/components/flow/actions/ResetPanel.svelte ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import { RefreshCcw } from '@lucide/svelte';
3
+ import { Panel, useSvelteFlow } from '@xyflow/svelte';
4
+
5
+ import { Button } from '$lib/components/ui/button';
6
+ import { breakpointsState } from '$lib/state/breakpoints.svelte';
7
+
8
+ const { getNodes } = useSvelteFlow();
9
+ let showResetButton = $derived(getNodes().length > 1);
10
+
11
+ function handleReset() {
12
+ const ok = confirm('Are you sure you want to reset the flow?');
13
+ if (ok) {
14
+ location.reload();
15
+ }
16
+ }
17
+ </script>
18
+
19
+ <Panel
20
+ position={breakpointsState.isMobile ? 'bottom-left' : 'top-left'}
21
+ class="flex items-center justify-end gap-2 p-1 lg:p-2"
22
+ >
23
+ {#if showResetButton}
24
+ <Button
25
+ variant="outline"
26
+ size={breakpointsState.isMobile ? 'icon-sm' : 'default'}
27
+ class=""
28
+ onclick={handleReset}
29
+ >
30
+ <RefreshCcw />
31
+ {#if !breakpointsState.isMobile}
32
+ Clear flow
33
+ {/if}
34
+ </Button>
35
+ {/if}
36
+ </Panel>
src/routes/+page.svelte CHANGED
@@ -7,7 +7,8 @@
7
  BackgroundVariant,
8
  PanOnScrollMode,
9
  type Node,
10
- type Edge
 
11
  } from '@xyflow/svelte';
12
  import '@xyflow/svelte/dist/style.css';
13
  import { mode } from 'mode-watcher';
@@ -23,6 +24,7 @@
23
  import ContextMenuComponent from '$lib/components/flow/actions/ContextMenu.svelte';
24
  import { getNodesAssociatedWith } from '$lib/helpers/getNodesAssociatedWith';
25
  import { breakpointsState } from '$lib/state/breakpoints.svelte';
 
26
 
27
  const nodeTypes = {
28
  user: User,
@@ -134,8 +136,8 @@
134
  patternColor={mode.current === 'dark' ? 'rgba(255, 255, 255, 0.04)' : 'rgba(0, 0, 0, 0.04)'}
135
  class="bg-background!"
136
  />
137
- <!-- <PanelLeftMenu /> -->
138
- <PanelRightActions canReset={nodes.length > 1} />
139
  <PanelCanvasActions />
140
  </SvelteFlow>
141
  </div>
 
7
  BackgroundVariant,
8
  PanOnScrollMode,
9
  type Node,
10
+ type Edge,
11
+ Panel
12
  } from '@xyflow/svelte';
13
  import '@xyflow/svelte/dist/style.css';
14
  import { mode } from 'mode-watcher';
 
24
  import ContextMenuComponent from '$lib/components/flow/actions/ContextMenu.svelte';
25
  import { getNodesAssociatedWith } from '$lib/helpers/getNodesAssociatedWith';
26
  import { breakpointsState } from '$lib/state/breakpoints.svelte';
27
+ import ResetPanel from '$lib/components/flow/actions/ResetPanel.svelte';
28
 
29
  const nodeTypes = {
30
  user: User,
 
136
  patternColor={mode.current === 'dark' ? 'rgba(255, 255, 255, 0.04)' : 'rgba(0, 0, 0, 0.04)'}
137
  class="bg-background!"
138
  />
139
+ <ResetPanel />
140
+ <PanelRightActions />
141
  <PanelCanvasActions />
142
  </SvelteFlow>
143
  </div>