From 4ab02ac717b62e39aa88acd814b535911043b3b3 Mon Sep 17 00:00:00 2001 From: Sofi Bel <91890402+sofi-bel@users.noreply.github.com> Date: Thu, 9 Apr 2026 13:51:21 +0300 Subject: [PATCH] UI(PG): filter card polish & sort select fixes Refs ENG-83 --- .../pg/components/PgAlgoliaFacetsActive.tsx | 2 +- .../pg/components/PgAlgoliaFilterCard.tsx | 38 +++++++------------ .../src/sites/pg/components/PgAlgoliaList.tsx | 13 ++----- .../pg/components/PgAlgoliaListSkeleton.tsx | 2 +- .../pg/components/PgAlgoliaSortSelect.tsx | 13 ++++--- 5 files changed, 26 insertions(+), 42 deletions(-) diff --git a/client/src/sites/pg/components/PgAlgoliaFacetsActive.tsx b/client/src/sites/pg/components/PgAlgoliaFacetsActive.tsx index f7318402..a9cc76a0 100644 --- a/client/src/sites/pg/components/PgAlgoliaFacetsActive.tsx +++ b/client/src/sites/pg/components/PgAlgoliaFacetsActive.tsx @@ -19,7 +19,7 @@ const tagStyle = { fontSize: "sm", color: "#908989", cursor: "pointer", - css: { "&:hover .close-icon": { color: "red" } }, + css: { "&:hover .close-icon": { color: "brand.black" } }, } as const; export type FacetsActiveConfig = { diff --git a/client/src/sites/pg/components/PgAlgoliaFilterCard.tsx b/client/src/sites/pg/components/PgAlgoliaFilterCard.tsx index fa7e13a2..9bfc40f7 100644 --- a/client/src/sites/pg/components/PgAlgoliaFilterCard.tsx +++ b/client/src/sites/pg/components/PgAlgoliaFilterCard.tsx @@ -1,5 +1,5 @@ import { Box, Collapsible, Flex, HStack, Icon, Stack } from "@chakra-ui/react"; -import React, { useEffect, useRef, type ReactNode, type RefObject } from "react"; +import { useEffect, useRef, type ReactNode } from "react"; import { LuChevronDown, LuSquareX } from "react-icons/lu"; import { useClearRefinements } from "react-instantsearch"; import { @@ -8,42 +8,32 @@ import { } from "@/sites/pg/components/PgAlgoliaFacetsActive"; import { useStateValtio } from "@neuronhub/shared/utils/useStateValtio"; -export function PgFilterCardWithSplitBg(props: { - children: ReactNode; - isOpenRef: RefObject; -}) { - const rootRef = useRef(null); +export function PgFilterCardWithSplitBg(props: { children: ReactNode }) { + const rootRef = useRef(null); useEffect(() => { - const rootElement = rootRef.current; - if (!rootElement) { - return; - } - const observer = new ResizeObserver(() => { - if (!props.isOpenRef.current) { + function measureSplitHeight() { + const rootElement = rootRef.current; + if (rootElement) { rootElement.style.setProperty("--split-bg-h", `${rootElement.offsetHeight / 2}px`); } - }); - observer.observe(rootElement); - return () => observer.disconnect(); + } + measureSplitHeight(); + window.addEventListener("resize", measureSplitHeight); + return () => window.removeEventListener("resize", measureSplitHeight); }, []); return ( - + - - {props.children} + {props.children} ); } @@ -75,7 +65,6 @@ export function PgMobileCollapsible(props: { cta?: ReactNode; facetsTopbar: ReactNode; facetsActive: FacetsActiveConfig; - onOpenChange?: (open: boolean) => void; }) { const state = useStateValtio({ isOpen: false }); @@ -84,7 +73,6 @@ export function PgMobileCollapsible(props: { open={state.snap.isOpen} onOpenChange={details => { state.mutable.isOpen = details.open; - props.onOpenChange?.(details.open); }} > {!state.snap.isOpen && ( diff --git a/client/src/sites/pg/components/PgAlgoliaList.tsx b/client/src/sites/pg/components/PgAlgoliaList.tsx index 2f0f7334..8422c5ad 100644 --- a/client/src/sites/pg/components/PgAlgoliaList.tsx +++ b/client/src/sites/pg/components/PgAlgoliaList.tsx @@ -1,5 +1,5 @@ import { Box, Grid, HStack, Stack } from "@chakra-ui/react"; -import { useRef, type ReactNode } from "react"; +import { type ReactNode } from "react"; import { InstantSearch } from "react-instantsearch"; import type { ID } from "@/gql-tada"; import type { FacetsActiveConfig } from "@/sites/pg/components/PgAlgoliaFacetsActive"; @@ -33,8 +33,6 @@ export function PgAlgoliaList(props: }) { const algolia = useAlgoliaSearchClient(); - const pgFilterCardIsOpenRef = useRef(false); - const indexName = algolia[props.index]; if (algolia.loading || !algolia.client || !indexName) { @@ -71,7 +69,7 @@ export function PgAlgoliaList(props: {props.children} - + {/* Mobile */} (props: cta={props.ctaMobile ?? props.cta} facetsTopbar={props.facetsTopbar} facetsActive={props.facetsActive} - onOpenChange={open => { - pgFilterCardIsOpenRef.current = open; - }} /> @@ -120,9 +115,9 @@ export function PgAlgoliaList(props: {props.cta} - - {props.facetsTopbar} + + diff --git a/client/src/sites/pg/components/PgAlgoliaListSkeleton.tsx b/client/src/sites/pg/components/PgAlgoliaListSkeleton.tsx index bc664d5e..c5d70a44 100644 --- a/client/src/sites/pg/components/PgAlgoliaListSkeleton.tsx +++ b/client/src/sites/pg/components/PgAlgoliaListSkeleton.tsx @@ -6,7 +6,7 @@ import { PgJobCardSkeletons } from "@/sites/pg/components/PgAlgoliaInfiniteHits" export function PgAlgoliaListSkeleton() { return ( - + - + @@ -37,8 +37,9 @@ export function PgAlgoliaSortSelect(props: { items: Array<{ value: string; label borderWidth="1px" borderRadius="sm" p="3" - w="fit-content" + w="var(--select-trigger-width)" minW="unset" + css={{ "& [role='option']": { paddingInline: "0", justifyContent: "flex-start" } }} > {collection.items.map(item => (