From 1df1da95ce8386904febadf42e0805085e4254b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Sun, 20 Apr 2025 21:29:18 +0200 Subject: [PATCH] Changed the styles of the visualization page, moved the settings --- src/app.css | 10 +- src/lib/components/EventLimitControl.svelte | 6 +- .../components/EventRenderLevelLimit.svelte | 6 +- src/lib/navigator/EventNetwork/Legend.svelte | 119 +++++++++++------- .../navigator/EventNetwork/Settings.svelte | 52 ++++++++ src/lib/navigator/EventNetwork/index.svelte | 38 ++++-- src/routes/visualize/+page.svelte | 55 +------- src/styles/visualize.css | 13 +- 8 files changed, 173 insertions(+), 126 deletions(-) create mode 100644 src/lib/navigator/EventNetwork/Settings.svelte diff --git a/src/app.css b/src/app.css index 235f36b..314408a 100644 --- a/src/app.css +++ b/src/app.css @@ -206,8 +206,9 @@ @layer components { /* Legend */ .leather-legend { - @apply flex-shrink-0 p-4 bg-primary-0 dark:bg-primary-1000 rounded-lg shadow - border border-gray-200 dark:border-gray-800; + @apply relative m-4 sm:m-0 sm:absolute sm:top-1 sm:left-1 flex-shrink-0 p-2 rounded; + @apply shadow-none text-primary-1000 border border-s-4 bg-highlight border-primary-200 has-[:hover]:border-primary-700; + @apply dark:bg-primary-1000 dark:border-primary-800 dark:has-[:hover]:bg-primary-950 dark:has-[:hover]:border-primary-500; } /* Tooltip */ @@ -219,8 +220,7 @@ z-index: 1000; } - /* Heading for leather components */ - h3.h-leather { - @apply text-gray-800 dark:text-gray-200 text-lg font-bold mb-2; + .leather-legend button { + @apply dark:text-white; } } diff --git a/src/lib/components/EventLimitControl.svelte b/src/lib/components/EventLimitControl.svelte index aafd91f..d8c28be 100644 --- a/src/lib/components/EventLimitControl.svelte +++ b/src/lib/components/EventLimitControl.svelte @@ -30,7 +30,7 @@
- diff --git a/src/lib/components/EventRenderLevelLimit.svelte b/src/lib/components/EventRenderLevelLimit.svelte index bbfdc87..3a7d8a8 100644 --- a/src/lib/components/EventRenderLevelLimit.svelte +++ b/src/lib/components/EventRenderLevelLimit.svelte @@ -29,16 +29,16 @@
- - + + + -
-

Legend

-
    - -
  • -
    - - I - -
    - Index events (kind 30040) - Each with a unique pastel color -
  • - - -
  • -
    - - C - -
    - Content events (kinds 30041, 30818) - Publication sections -
  • - - -
  • - - - - Arrows indicate reading/sequence order -
  • -
-
+
+
+

Legend

+ +
+ {#if expanded} +
    + +
  • +
    + + I + +
    + Index events (kind 30040) - Each with a unique pastel color +
  • + + +
  • +
    + + C + +
    + Content events (kinds 30041, 30818) - Publication sections +
  • + + +
  • + + + + Arrows indicate reading/sequence order +
  • +
+ {/if} +
diff --git a/src/lib/navigator/EventNetwork/Settings.svelte b/src/lib/navigator/EventNetwork/Settings.svelte new file mode 100644 index 0000000..390931c --- /dev/null +++ b/src/lib/navigator/EventNetwork/Settings.svelte @@ -0,0 +1,52 @@ + + + +
+
+

Settings

+ +
+ + {#if expanded} +
+ + Showing {count} events from {$networkFetchLimit} headers + + + +
+ {/if} +
diff --git a/src/lib/navigator/EventNetwork/index.svelte b/src/lib/navigator/EventNetwork/index.svelte index d43719a..7742475 100644 --- a/src/lib/navigator/EventNetwork/index.svelte +++ b/src/lib/navigator/EventNetwork/index.svelte @@ -21,6 +21,8 @@ import Legend from "./Legend.svelte"; import NodeTooltip from "./NodeTooltip.svelte"; import type { NetworkNode, NetworkLink } from "./types"; + import Settings from "./Settings.svelte"; + import {Button} from 'flowbite-svelte'; // Type alias for D3 selections type Selection = any; @@ -43,7 +45,7 @@ } // Component props - let { events = [] } = $props<{ events?: NDKEvent[] }>(); + let { events = [], onupdate } = $props<{ events?: NDKEvent[], onupdate: () => void }>(); // Error state let errorMessage = $state(null); @@ -498,6 +500,17 @@ ); } } + + /** + * Legend interactions + */ + let graphInteracted = $state(false); + + function handleGraphClick() { + if (!graphInteracted) { + graphInteracted = true; + } + }
@@ -514,15 +527,23 @@
{/if} -
+
+ + + + + + +
- - - +
@@ -568,5 +589,4 @@ /> {/if} -
diff --git a/src/routes/visualize/+page.svelte b/src/routes/visualize/+page.svelte index 39eaa06..142eeb5 100644 --- a/src/routes/visualize/+page.svelte +++ b/src/routes/visualize/+page.svelte @@ -10,13 +10,10 @@ import { ndkInstance } from "$lib/ndk"; import type { NDKEvent } from "@nostr-dev-kit/ndk"; import { filterValidIndexEvents } from "$lib/utils"; - import EventLimitControl from "$lib/components/EventLimitControl.svelte"; - import EventRenderLevelLimit from "$lib/components/EventRenderLevelLimit.svelte"; import { networkFetchLimit } from "$lib/state"; - import { fly } from "svelte/transition"; - import { quintOut } from "svelte/easing"; import { CogSolid } from "flowbite-svelte-icons"; import { Button } from "flowbite-svelte"; + import Settings from "$lib/navigator/EventNetwork/Settings.svelte"; // Configuration const DEBUG = false; // Set to true to enable debug logging @@ -110,12 +107,6 @@ } } - /** - * Handles updates to visualization settings - */ - function handleLimitUpdate() { - fetchEvents(); - } // Fetch events when component mounts onMount(() => { @@ -127,44 +118,8 @@
-

Publication Network

- - - {#if !loading && !error} - - {/if} +

Publication Network

- - - {#if !loading && !error && showSettings} -
-
-

- Visualization Settings -

- -
- - Showing {events.length} events from {$networkFetchLimit} headers - - - -
-
-
- {/if} - {#if loading}
@@ -206,9 +161,7 @@
{:else} -
- - -
+ + {/if}
diff --git a/src/styles/visualize.css b/src/styles/visualize.css index ef7f33b..1ff732d 100644 --- a/src/styles/visualize.css +++ b/src/styles/visualize.css @@ -1,7 +1,7 @@ @layer components { /* Legend styles - specific to visualization */ .legend-list { - @apply list-disc pl-5 space-y-2 text-gray-800 dark:text-gray-300; + @apply list-disc mt-2 space-y-2 text-gray-800 dark:text-gray-300; } .legend-item { @@ -39,15 +39,16 @@ /* Network visualization styles - specific to visualization */ .network-container { - @apply flex flex-col w-full h-[calc(100vh-120px)] min-h-[400px] max-h-[900px] p-4 gap-4; + @apply flex flex-col w-full h-[calc(100vh-138px)] min-h-[400px] max-h-[900px]; } .network-svg-container { - @apply relative; + @apply relative sm:h-[100%]; } .network-svg { - @apply w-full h-full border border-gray-300 dark:border-gray-700 rounded; + @apply w-full sm:h-[100%] border; + @apply border border-primary-200 has-[:hover]:border-primary-700 dark:bg-primary-1000 dark:border-primary-800 dark:has-[:hover]:bg-primary-950 dark:has-[:hover]:border-primary-500 rounded; } .network-error { @@ -72,9 +73,7 @@ } .network-control-button { - @apply bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 - shadow-md hover:shadow-lg transition-shadow duration-200 - border border-gray-300 dark:border-gray-700; + @apply bg-white; } /* Tooltip styles - specific to visualization tooltips */