11import { Box , Collapsible , Flex , HStack , Icon , Stack } from "@chakra-ui/react" ;
2- import React , { useEffect , useRef , type ReactNode , type RefObject } from "react" ;
2+ import { useEffect , useRef , type ReactNode } from "react" ;
33import { LuChevronDown , LuSquareX } from "react-icons/lu" ;
44import { useClearRefinements } from "react-instantsearch" ;
55import {
@@ -8,42 +8,32 @@ import {
88} from "@/sites/pg/components/PgAlgoliaFacetsActive" ;
99import { useStateValtio } from "@neuronhub/shared/utils/useStateValtio" ;
1010
11- export function PgFilterCardWithSplitBg ( props : {
12- children : ReactNode ;
13- isOpenRef : RefObject < boolean > ;
14- } ) {
15- const rootRef = useRef < HTMLDivElement > ( null ) ;
11+ export function PgFilterCardWithSplitBg ( props : { children : ReactNode } ) {
12+ const rootRef = useRef < HTMLDivElement | null > ( null ) ;
1613
1714 useEffect ( ( ) => {
18- const rootElement = rootRef . current ;
19- if ( ! rootElement ) {
20- return ;
21- }
22- const observer = new ResizeObserver ( ( ) => {
23- if ( ! props . isOpenRef . current ) {
15+ function measureSplitHeight ( ) {
16+ const rootElement = rootRef . current ;
17+ if ( rootElement ) {
2418 rootElement . style . setProperty ( "--split-bg-h" , `${ rootElement . offsetHeight / 2 } px` ) ;
2519 }
26- } ) ;
27- observer . observe ( rootElement ) ;
28- return ( ) => observer . disconnect ( ) ;
20+ }
21+ measureSplitHeight ( ) ;
22+ window . addEventListener ( "resize" , measureSplitHeight ) ;
23+ return ( ) => window . removeEventListener ( "resize" , measureSplitHeight ) ;
2924 } , [ ] ) ;
3025
3126 return (
32- < Box
33- position = "relative"
34- ref = { rootRef }
35- style = { { "--split-bg-h" : "50%" } as React . CSSProperties }
36- >
27+ < Box ref = { rootRef } pos = "relative" >
3728 < Box
38- position = "absolute"
29+ pos = "absolute"
3930 top = "0"
4031 left = "-9999px"
4132 right = "-9999px"
4233 h = "var(--split-bg-h)"
4334 bg = "brand.green"
4435 />
45- < Box position = "absolute" top = "var(--split-bg-h)" left = "-9999px" right = "-9999px" bg = "bg" />
46- < Box position = "relative" > { props . children } </ Box >
36+ < Box pos = "relative" > { props . children } </ Box >
4737 </ Box >
4838 ) ;
4939}
@@ -75,7 +65,6 @@ export function PgMobileCollapsible(props: {
7565 cta ?: ReactNode ;
7666 facetsTopbar : ReactNode ;
7767 facetsActive : FacetsActiveConfig ;
78- onOpenChange ?: ( open : boolean ) => void ;
7968} ) {
8069 const state = useStateValtio ( { isOpen : false } ) ;
8170
@@ -84,7 +73,6 @@ export function PgMobileCollapsible(props: {
8473 open = { state . snap . isOpen }
8574 onOpenChange = { details => {
8675 state . mutable . isOpen = details . open ;
87- props . onOpenChange ?.( details . open ) ;
8876 } }
8977 >
9078 { ! state . snap . isOpen && (
0 commit comments