mirror of
https://github.com/block/buzz.git
synced 2026-10-30 22:11:36 +00:00
Signed-off-by: Taylor Ho <taylorkmho@gmail.com> Co-authored-by: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
28 lines
688 B
TypeScript
28 lines
688 B
TypeScript
import * as React from "react";
|
|
|
|
const MainInsetContext =
|
|
React.createContext<React.RefObject<HTMLElement | null> | null>(null);
|
|
|
|
export function MainInsetProvider({
|
|
children,
|
|
mainInsetRef,
|
|
}: {
|
|
children: React.ReactNode;
|
|
mainInsetRef: React.RefObject<HTMLElement | null>;
|
|
}) {
|
|
return (
|
|
<MainInsetContext.Provider value={mainInsetRef}>
|
|
{children}
|
|
</MainInsetContext.Provider>
|
|
);
|
|
}
|
|
|
|
/** Ref to the app `<main>` inset element where shared chrome CSS vars live. */
|
|
export function useMainInsetRef() {
|
|
const ref = React.useContext(MainInsetContext);
|
|
if (!ref) {
|
|
throw new Error("useMainInsetRef must be used within MainInsetProvider");
|
|
}
|
|
return ref;
|
|
}
|