From 7cb055a79f9573d600d04d3c4a6510ce538333b1 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 15 Sep 2025 04:03:19 -0700 Subject: [PATCH] Add tooltip support with bits-ui --- src/app.scss | 8 +++- src/lib/components/reps/GridRep.svelte | 42 +++++++++++------- src/lib/components/ui/Tooltip.svelte | 59 ++++++++++++++++++++++++++ src/routes/+layout.svelte | 18 ++++---- src/themes/_tooltip.scss | 17 ++++++++ 5 files changed, 119 insertions(+), 25 deletions(-) create mode 100644 src/lib/components/ui/Tooltip.svelte create mode 100644 src/themes/_tooltip.scss diff --git a/src/app.scss b/src/app.scss index 18094c3d..abc81431 100644 --- a/src/app.scss +++ b/src/app.scss @@ -1,6 +1,11 @@ // Import themes @use 'themes/themes'; @use 'themes/spacing'; +@use 'themes/tooltip'; + +:root { + --main-max-width: 820px; // Default max-width for main content +} html { background-color: var(--background); @@ -28,10 +33,11 @@ ul { } main { - max-width: 820px; + max-width: var(--main-max-width); margin: 0 auto; padding: 0 spacing.$unit-2x; width: 100%; + transition: max-width 0.3s ease; // Responsive padding for smaller screens @media (max-width: 768px) { diff --git a/src/lib/components/reps/GridRep.svelte b/src/lib/components/reps/GridRep.svelte index c2329c11..0bf00a47 100644 --- a/src/lib/components/reps/GridRep.svelte +++ b/src/lib/components/reps/GridRep.svelte @@ -1,15 +1,16 @@ + + + + {#snippet child({ props })} + + {@render children()} + + {/snippet} + + + {content} + + + + \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 8e1788ac..05e5e67a 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -4,14 +4,12 @@ import '$src/app.scss' import Navigation from '$lib/components/Navigation.svelte' + import { Tooltip } from 'bits-ui' // Get `data` and `children` from the router via $props() + // Use a more flexible type that allows additional properties from child pages const { data, children } = $props<{ - data: { - isAuthenticated: boolean - account: { username: string; userId: string; role: number } | null - currentUser: unknown | null - } + data: any // Allow any data to pass through from child pages children: () => any }>() @@ -20,7 +18,9 @@ -
- - {@render children?.()} -
+ +
+ + {@render children?.()} +
+
diff --git a/src/themes/_tooltip.scss b/src/themes/_tooltip.scss new file mode 100644 index 00000000..795c37b5 --- /dev/null +++ b/src/themes/_tooltip.scss @@ -0,0 +1,17 @@ +@use 'layout'; +@use 'typography'; +@use 'spacing'; + +// Global tooltip styles for bits-ui +[data-tooltip-content] { + background: var(--tooltip-bg, #2a2a2a); + color: var(--tooltip-text, white); + padding: spacing.$unit-half spacing.$unit; + border-radius: layout.$item-corner-small; + font-size: typography.$font-small; + font-weight: typography.$medium; + z-index: 1000; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); + max-width: 250px; + line-height: 1.4; +} \ No newline at end of file