2026-06-11 21:30:25 +02:00
|
|
|
import { useRef, useState, useSyncExternalStore } from "react";
|
|
|
|
|
import { createPortal } from "react-dom";
|
feat(ui): liquid-glass design system, settings polish, hints, notif fixes
- Add a theme-aware glass surface system (.glass/.glass-card + ambient backdrop,
performance-mode opt-out) and apply it across panels, popovers, toasts, cards,
sidebar widgets, channel rows, video cards and login.
- SettingsPanel: slide in/out animation, glass styling, wrapping pill tabs (no
horizontal scrollbar) with a prominent active state.
- Notifications: auto-dismiss can be switched off (stays until closed); the test
notification now also triggers the alert sound; resume a suspended AudioContext.
- Add an app-wide, toggleable hint/tooltip system (lib/hints + Tooltip) and wire
hints across the settings and channel-manager surfaces; persisted per account.
2026-06-11 21:08:35 +02:00
|
|
|
import { hintsEnabled, subscribeHints } from "../lib/hints";
|
|
|
|
|
|
2026-06-11 21:30:25 +02:00
|
|
|
type Side = "top" | "bottom";
|
|
|
|
|
type Coords = { left: number; top: number; placement: Side };
|
feat(ui): liquid-glass design system, settings polish, hints, notif fixes
- Add a theme-aware glass surface system (.glass/.glass-card + ambient backdrop,
performance-mode opt-out) and apply it across panels, popovers, toasts, cards,
sidebar widgets, channel rows, video cards and login.
- SettingsPanel: slide in/out animation, glass styling, wrapping pill tabs (no
horizontal scrollbar) with a prominent active state.
- Notifications: auto-dismiss can be switched off (stays until closed); the test
notification now also triggers the alert sound; resume a suspended AudioContext.
- Add an app-wide, toggleable hint/tooltip system (lib/hints + Tooltip) and wire
hints across the settings and channel-manager surfaces; persisted per account.
2026-06-11 21:08:35 +02:00
|
|
|
|
|
|
|
|
/** Wrap any element to show a short glass hint caption on hover — but only while the
|
2026-06-11 21:30:25 +02:00
|
|
|
* app-wide hints toggle (Settings → Appearance) is on. Rendered in a portal with
|
|
|
|
|
* fixed positioning so it is never clipped by an overflow/stacking ancestor. */
|
feat(ui): liquid-glass design system, settings polish, hints, notif fixes
- Add a theme-aware glass surface system (.glass/.glass-card + ambient backdrop,
performance-mode opt-out) and apply it across panels, popovers, toasts, cards,
sidebar widgets, channel rows, video cards and login.
- SettingsPanel: slide in/out animation, glass styling, wrapping pill tabs (no
horizontal scrollbar) with a prominent active state.
- Notifications: auto-dismiss can be switched off (stays until closed); the test
notification now also triggers the alert sound; resume a suspended AudioContext.
- Add an app-wide, toggleable hint/tooltip system (lib/hints + Tooltip) and wire
hints across the settings and channel-manager surfaces; persisted per account.
2026-06-11 21:08:35 +02:00
|
|
|
export default function Tooltip({
|
|
|
|
|
hint,
|
|
|
|
|
side = "top",
|
|
|
|
|
children,
|
|
|
|
|
}: {
|
|
|
|
|
hint: string;
|
|
|
|
|
side?: Side;
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
}) {
|
|
|
|
|
const enabled = useSyncExternalStore(subscribeHints, hintsEnabled, hintsEnabled);
|
2026-06-11 21:30:25 +02:00
|
|
|
const ref = useRef<HTMLSpanElement>(null);
|
|
|
|
|
const [coords, setCoords] = useState<Coords | null>(null);
|
|
|
|
|
|
|
|
|
|
function show() {
|
|
|
|
|
const el = ref.current;
|
|
|
|
|
if (!el) return;
|
|
|
|
|
const r = el.getBoundingClientRect();
|
|
|
|
|
// Prefer the requested side; flip to bottom if there's no room above.
|
|
|
|
|
const placement: Side = side === "bottom" || r.top < 90 ? "bottom" : "top";
|
|
|
|
|
setCoords({
|
|
|
|
|
left: Math.min(Math.max(r.left + r.width / 2, 92), window.innerWidth - 92),
|
|
|
|
|
top: placement === "top" ? r.top - 8 : r.bottom + 8,
|
|
|
|
|
placement,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function hide() {
|
|
|
|
|
setCoords(null);
|
|
|
|
|
}
|
feat(ui): liquid-glass design system, settings polish, hints, notif fixes
- Add a theme-aware glass surface system (.glass/.glass-card + ambient backdrop,
performance-mode opt-out) and apply it across panels, popovers, toasts, cards,
sidebar widgets, channel rows, video cards and login.
- SettingsPanel: slide in/out animation, glass styling, wrapping pill tabs (no
horizontal scrollbar) with a prominent active state.
- Notifications: auto-dismiss can be switched off (stays until closed); the test
notification now also triggers the alert sound; resume a suspended AudioContext.
- Add an app-wide, toggleable hint/tooltip system (lib/hints + Tooltip) and wire
hints across the settings and channel-manager surfaces; persisted per account.
2026-06-11 21:08:35 +02:00
|
|
|
|
2026-06-11 21:30:25 +02:00
|
|
|
if (!enabled || !hint) return <>{children}</>;
|
feat(ui): liquid-glass design system, settings polish, hints, notif fixes
- Add a theme-aware glass surface system (.glass/.glass-card + ambient backdrop,
performance-mode opt-out) and apply it across panels, popovers, toasts, cards,
sidebar widgets, channel rows, video cards and login.
- SettingsPanel: slide in/out animation, glass styling, wrapping pill tabs (no
horizontal scrollbar) with a prominent active state.
- Notifications: auto-dismiss can be switched off (stays until closed); the test
notification now also triggers the alert sound; resume a suspended AudioContext.
- Add an app-wide, toggleable hint/tooltip system (lib/hints + Tooltip) and wire
hints across the settings and channel-manager surfaces; persisted per account.
2026-06-11 21:08:35 +02:00
|
|
|
|
|
|
|
|
return (
|
2026-06-11 21:30:25 +02:00
|
|
|
<span
|
|
|
|
|
ref={ref}
|
|
|
|
|
onMouseEnter={show}
|
|
|
|
|
onMouseLeave={hide}
|
|
|
|
|
onFocus={show}
|
|
|
|
|
onBlur={hide}
|
|
|
|
|
className="inline-flex"
|
|
|
|
|
>
|
feat(ui): liquid-glass design system, settings polish, hints, notif fixes
- Add a theme-aware glass surface system (.glass/.glass-card + ambient backdrop,
performance-mode opt-out) and apply it across panels, popovers, toasts, cards,
sidebar widgets, channel rows, video cards and login.
- SettingsPanel: slide in/out animation, glass styling, wrapping pill tabs (no
horizontal scrollbar) with a prominent active state.
- Notifications: auto-dismiss can be switched off (stays until closed); the test
notification now also triggers the alert sound; resume a suspended AudioContext.
- Add an app-wide, toggleable hint/tooltip system (lib/hints + Tooltip) and wire
hints across the settings and channel-manager surfaces; persisted per account.
2026-06-11 21:08:35 +02:00
|
|
|
{children}
|
2026-06-11 21:30:25 +02:00
|
|
|
{coords &&
|
|
|
|
|
createPortal(
|
|
|
|
|
<div
|
|
|
|
|
role="tooltip"
|
|
|
|
|
style={{
|
|
|
|
|
position: "fixed",
|
|
|
|
|
left: coords.left,
|
|
|
|
|
top: coords.top,
|
|
|
|
|
transform: `translateX(-50%) translateY(${coords.placement === "top" ? "-100%" : "0"})`,
|
|
|
|
|
}}
|
|
|
|
|
className="glass pointer-events-none z-[100] w-max max-w-[240px] px-2.5 py-1.5 rounded-lg text-xs leading-snug text-fg font-normal normal-case tracking-normal animate-[fadeIn_0.12s_ease]"
|
|
|
|
|
>
|
|
|
|
|
{hint}
|
|
|
|
|
</div>,
|
|
|
|
|
document.body
|
|
|
|
|
)}
|
feat(ui): liquid-glass design system, settings polish, hints, notif fixes
- Add a theme-aware glass surface system (.glass/.glass-card + ambient backdrop,
performance-mode opt-out) and apply it across panels, popovers, toasts, cards,
sidebar widgets, channel rows, video cards and login.
- SettingsPanel: slide in/out animation, glass styling, wrapping pill tabs (no
horizontal scrollbar) with a prominent active state.
- Notifications: auto-dismiss can be switched off (stays until closed); the test
notification now also triggers the alert sound; resume a suspended AudioContext.
- Add an app-wide, toggleable hint/tooltip system (lib/hints + Tooltip) and wire
hints across the settings and channel-manager surfaces; persisted per account.
2026-06-11 21:08:35 +02:00
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|