forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

quick-actions.ts20 lines, 843 bytesHistoryRawDownload
1import { createSignal, onCleanup } from "solid-js";
2
3// Surfaces that dock something at the bottom of a phone screen — the study
4// chat's composer, the message compose sheet — put the floating action button
5// away while they are up, the same way the shell's own overlays do. A count
6// rather than a flag, so two holders never release each other's hold.
7const [holds, setHolds] = createSignal(0);
8
9export const quickActionsSuppressed = () => holds() > 0;
10
11/**
12 * Hide the phone quick-action button until the calling owner (component or
13 * effect run) is disposed. Call it from a component body to hide for the
14 * component's lifetime, or inside a `createEffect` branch to hide while a
15 * condition holds.
16 */
17export function suppressQuickActions() {
18 setHolds((count) => count + 1);
19 onCleanup(() => setHolds((count) => count - 1));
20}