From de5ce3d2a1ece81812fbf0aa80754a7a8921da54 Mon Sep 17 00:00:00 2001 From: dafuga Date: Thu, 24 Oct 2024 17:22:12 -0700 Subject: [PATCH 1/4] chore: added Tooltip component --- src/lib/components/tooltip/tooltip.svelte | 46 ++++++++++++++++ .../(dev)/debug/components/+page.svelte | 7 ++- .../debug/components/sections/tooltips.svelte | 52 +++++++++++++++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 src/lib/components/tooltip/tooltip.svelte create mode 100644 src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte diff --git a/src/lib/components/tooltip/tooltip.svelte b/src/lib/components/tooltip/tooltip.svelte new file mode 100644 index 00000000..2229a848 --- /dev/null +++ b/src/lib/components/tooltip/tooltip.svelte @@ -0,0 +1,46 @@ + + + + {#if children} + {@render children()} + {/if} + + +{#if $open} +
+ {#if icon} + {@const IconComponent = icon} + + + + + {/if} + {content} +
+{/if} diff --git a/src/routes/[network]/(dev)/debug/components/+page.svelte b/src/routes/[network]/(dev)/debug/components/+page.svelte index bbe7105a..4a7c3a94 100644 --- a/src/routes/[network]/(dev)/debug/components/+page.svelte +++ b/src/routes/[network]/(dev)/debug/components/+page.svelte @@ -11,11 +11,12 @@ import Progress from './sections/progress.svelte'; import Tables from './sections/tables.svelte'; import Charts from './sections/charts.svelte'; + import Tooltips from './sections/tooltips.svelte';

Design System

- +
@@ -57,4 +58,8 @@
+ +
+ +
diff --git a/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte b/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte new file mode 100644 index 00000000..fb22c6bb --- /dev/null +++ b/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte @@ -0,0 +1,52 @@ + + + +
+

Tooltips

+

Tooltips provide additional information when hovering over an element.

+
+ +
+ + Small tooltip + +
+ +
+ + Medium tooltip + +
+ +
+ + Large tooltip + +
+ +
+ + Tooltip with icon + +
+ +
+ + Slowly appearing tooltip + +
+
From a5439d21228afb23c7b50bdc9e53c43df83813a8 Mon Sep 17 00:00:00 2001 From: dafuga Date: Thu, 24 Oct 2024 17:29:05 -0700 Subject: [PATCH 2/4] enhancement: adding ability to set the open and close delay --- src/lib/components/tooltip/tooltip.svelte | 19 ++++++++++++++----- .../debug/components/sections/tooltips.svelte | 12 +++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/lib/components/tooltip/tooltip.svelte b/src/lib/components/tooltip/tooltip.svelte index 2229a848..6082268c 100644 --- a/src/lib/components/tooltip/tooltip.svelte +++ b/src/lib/components/tooltip/tooltip.svelte @@ -8,17 +8,26 @@ content: string; children?: Snippet; icon?: typeof Icon; - duration?: number; + fadeDuration?: number; + openDelay?: number; + closeDelay?: number; } - const { content, children, icon, duration = 50 }: Props = $props(); + const { + content, + children, + icon, + fadeDuration = 50, + openDelay = 300, + closeDelay = 300 + }: Props = $props(); const { elements: { trigger, content: tooltipContent }, states: { open } } = createTooltip({ - openDelay: 300, - closeDelay: 300 + openDelay, + closeDelay }); @@ -31,7 +40,7 @@ {#if $open}
{#if icon} diff --git a/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte b/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte index fb22c6bb..bb8b359f 100644 --- a/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte +++ b/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte @@ -41,10 +41,20 @@
+
+ + Slow open and close tooltip + +
+
Slowly appearing tooltip From 5ca6d58326b83f7cfd083e6917f3177131a8bcb9 Mon Sep 17 00:00:00 2001 From: dafuga Date: Fri, 25 Oct 2024 13:04:32 -0700 Subject: [PATCH 3/4] chore: adding extra tooltip example --- .../debug/components/sections/tooltips.svelte | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte b/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte index bb8b359f..91001bad 100644 --- a/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte +++ b/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte @@ -10,13 +10,13 @@

Tooltips provide additional information when hovering over an element.

-
+
Small tooltip
-
+
@@ -24,7 +24,7 @@
-
+
@@ -32,7 +32,7 @@
-
+
-
+
-
+
Slowly appearing tooltip
+ +
+ + + + + +
From 25384998ce52d346197d93886b8ad19b673a9638 Mon Sep 17 00:00:00 2001 From: dafuga Date: Fri, 25 Oct 2024 13:08:43 -0700 Subject: [PATCH 4/4] enhancement: defaulting to info icon --- src/lib/components/tooltip/tooltip.svelte | 4 ++-- .../(dev)/debug/components/sections/tooltips.svelte | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/components/tooltip/tooltip.svelte b/src/lib/components/tooltip/tooltip.svelte index 6082268c..360c8da0 100644 --- a/src/lib/components/tooltip/tooltip.svelte +++ b/src/lib/components/tooltip/tooltip.svelte @@ -2,7 +2,7 @@ import { createTooltip, melt } from '@melt-ui/svelte'; import { fade } from 'svelte/transition'; import { type Snippet } from 'svelte'; - import type { Icon } from 'lucide-svelte'; + import { Info, type Icon } from 'lucide-svelte'; interface Props { content: string; @@ -16,7 +16,7 @@ const { content, children, - icon, + icon = Info, fadeDuration = 50, openDelay = 300, closeDelay = 300 diff --git a/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte b/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte index 91001bad..1cf4de39 100644 --- a/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte +++ b/src/routes/[network]/(dev)/debug/components/sections/tooltips.svelte @@ -1,5 +1,5 @@ @@ -35,9 +35,9 @@
- Tooltip with icon + Tooltip with custom icon