()
| 17 | }>; |
| 18 | |
| 19 | export function AppBackground() { |
| 20 | const bgRef = useRef<HTMLDivElement>(null); |
| 21 | const tabId = useAtomValue(atoms.staticTabId); |
| 22 | const [tabData] = useWaveObjectValue<Tab>(WOS.makeORef("tab", tabId)); |
| 23 | const env = useWaveEnv<AppBgEnv>(); |
| 24 | const tabBg = useAtomValue(env.getTabMetaKeyAtom(tabId, "tab:background")); |
| 25 | const configBg = useAtomValue(env.getConfigBackgroundAtom(tabBg)); |
| 26 | const resolvedMeta: Omit<BackgroundConfigType, "display:name"> = tabBg && configBg ? configBg : tabData?.meta; |
| 27 | const style: CSSProperties = computeBgStyleFromMeta(resolvedMeta, 0.5) ?? {}; |
| 28 | const getAvgColor = useCallback( |
| 29 | debounce(30, () => { |
| 30 | if ( |
| 31 | bgRef.current && |
| 32 | PLATFORM !== PlatformMacOS && |
| 33 | bgRef.current && |
| 34 | "windowControlsOverlay" in window.navigator |
| 35 | ) { |
| 36 | const titlebarRect: Dimensions = (window.navigator.windowControlsOverlay as any).getTitlebarAreaRect(); |
| 37 | const bgRect = bgRef.current.getBoundingClientRect(); |
| 38 | if (titlebarRect && bgRect) { |
| 39 | const windowControlsLeft = titlebarRect.width - titlebarRect.height; |
| 40 | const windowControlsRect: Dimensions = { |
| 41 | top: titlebarRect.top, |
| 42 | left: windowControlsLeft, |
| 43 | height: titlebarRect.height, |
| 44 | width: bgRect.width - bgRect.left - windowControlsLeft, |
| 45 | }; |
| 46 | getApi().updateWindowControlsOverlay(windowControlsRect); |
| 47 | } |
| 48 | } |
| 49 | }), |
| 50 | [bgRef, style] |
| 51 | ); |
| 52 | useLayoutEffect(getAvgColor, [getAvgColor]); |
| 53 | useResizeObserver(bgRef, getAvgColor); |
| 54 | |
| 55 | return ( |
| 56 | <div |
| 57 | ref={bgRef} |
| 58 | className="pointer-events-none absolute top-0 left-0 w-full h-full z-[var(--zindex-app-background)]" |
| 59 | style={style} |
| 60 | /> |
| 61 | ); |
| 62 | } |
nothing calls this directly
no test coverage detected