11/* eslint-disable no-unused-vars */
2- " use client" ;
2+ ' use client' ;
33
4- import type { SearchResponseFacet } from "@sitecore-search/react" ;
5- import {
6- AccordionFacets ,
7- SearchResultsAccordionFacets ,
8- } from "@sitecore-search/ui" ;
9- import {
10- Accordion ,
11- AccordionContent ,
12- AccordionItem ,
13- AccordionTrigger ,
14- } from "@src/components/ui/accordion" ;
15- import { Button } from "@src/components/ui/button" ;
16- import { Card , CardContent , CardHeader } from "@src/components/ui/card" ;
17- import { Checkbox } from "@src/components/ui/checkbox" ;
18- import { useState } from "react" ;
4+ import type { FacetChoiceChangedPayload , SearchResponseFacet } from '@sitecore-search/react' ;
5+ import { AccordionFacets , SearchResultsAccordionFacets } from '@sitecore-search/ui' ;
6+ import { Accordion , AccordionContent , AccordionItem , AccordionTrigger } from '@src/components/ui/accordion' ;
7+ import { Button } from '@src/components/ui/button' ;
8+ import { Checkbox } from '@src/components/ui/checkbox' ;
9+ import { useState } from 'react' ;
10+ import { Separator } from '../../ui/separator' ;
1911
2012export interface SearchFacetsType {
2113 onFacetClick : ( facet : any ) => void ;
@@ -50,19 +42,14 @@ export const MobileFacets = (props: SearchFacetsType) => {
5042 const { onFacetClick, facets } = props ;
5143
5244 return (
53- < SearchResultsAccordionFacets
54- defaultFacetTypesExpandedList = { facets . map ( ( x ) => x . name ) }
55- onFacetValueClick = { onFacetClick }
56- >
45+ < SearchResultsAccordionFacets defaultFacetTypesExpandedList = { facets . map ( ( x ) => x . name ) } onFacetValueClick = { onFacetClick } >
5746 { facets . map ( ( facet ) => (
5847 < Accordion key = { facet . name } type = "single" collapsible >
5948 < AccordionItem value = { facet . name } >
6049 < AccordionFacets . Facet facetId = { facet . name } >
6150 < AccordionFacets . Content >
6251 < AccordionTrigger >
63- < span className = "text-sm uppercase tracking-wide text-muted-foreground" >
64- { facet . label }
65- </ span >
52+ < span className = "text-sm uppercase tracking-wide text-muted-foreground" > { facet . label } </ span >
6653 </ AccordionTrigger >
6754 < AccordionContent >
6855 < AccordionFacets . ValueList asChild >
@@ -77,16 +64,10 @@ export const MobileFacets = (props: SearchFacetsType) => {
7764 } }
7865 >
7966 < div className = "flex items-center gap-2" >
80- < Checkbox
81- asChild
82- aria-labelledby = { `facet-label-${ facet . name } -${ v . id } ` }
83- >
67+ < Checkbox asChild aria-labelledby = { `facet-label-${ facet . name } -${ v . id } ` } >
8468 < AccordionFacets . ItemCheckbox />
8569 </ Checkbox >
86- < span
87- id = { `facet-label-${ facet . name } -${ v . id } ` }
88- className = "text-sm"
89- >
70+ < span id = { `facet-label-${ facet . name } -${ v . id } ` } className = "text-sm" >
9071 { v . text } { v . count && `(${ v . count } )` }
9172 </ span >
9273 </ div >
@@ -108,58 +89,44 @@ export const Facets = (props: SearchFacetsType) => {
10889 const { onFacetClick, facets } = props ;
10990
11091 return (
111- < SearchResultsAccordionFacets
112- defaultFacetTypesExpandedList = { facets . map ( ( x ) => x . name ) }
113- onFacetValueClick = { onFacetClick }
114- >
92+ < SearchResultsAccordionFacets defaultFacetTypesExpandedList = { facets . map ( ( x ) => x . name ) } onFacetValueClick = { ( e ) => onFacetClick ( e as FacetChoiceChangedPayload ) } >
11593 { facets . map ( ( facet ) => (
116- < Card className = "bg-muted mb-4" key = { facet . name } >
117- < AccordionFacets . Facet facetId = { facet . name } >
118- < AccordionFacets . Header >
119- < CardHeader >
120- < AccordionFacets . Trigger >
121- < p className = "text-sm uppercase tracking-wide text-muted-foreground" >
122- { facet . label }
123- </ p >
124- </ AccordionFacets . Trigger >
125- </ CardHeader >
94+ < div key = { facet . name } >
95+ < AccordionFacets . Facet key = { facet . name } facetId = { facet . name } className = "w-full" >
96+ < AccordionFacets . Header className = "mb-4 font-heading" >
97+ < AccordionFacets . Trigger className = "flex w-full text-lg font-bold text-left uppercase group" >
98+ < div className = "capitalize grow" > { facet . label } </ div >
99+ < div className = "inline-flex ml-8 w-4 h-4 group-data-[state=open]:rotate-180" >
100+ < svg fill = "none" stroke = "currentColor" strokeWidth = "1.5" viewBox = "0 0 24 24" xmlns = "http://www.w3.org/2000/svg" aria-hidden = "true" >
101+ < path strokeLinecap = "round" strokeLinejoin = "round" d = "M19.5 8.25l-7.5 7.5-7.5-7.5" > </ path >
102+ </ svg >
103+ </ div >
104+ </ AccordionFacets . Trigger >
126105 </ AccordionFacets . Header >
127-
128106 < AccordionFacets . Content >
129- < CardContent >
130- < AccordionFacets . ValueList asChild >
131- < div className = "flex flex-col gap-2" >
132- { facet . value . map ( ( v , index ) => (
133- < AccordionFacets . Item
134- asChild
135- key = { v . id }
136- { ...{
137- index,
138- facetValueId : v . id ,
139- } }
140- >
141- < div className = "flex items-center gap-2" >
142- < Checkbox
143- asChild
144- aria-labelledby = { `facet-desktop-label-${ facet . name } -${ v . id } ` }
145- >
146- < AccordionFacets . ItemCheckbox />
147- </ Checkbox >
148- < span
149- id = { `facet-desktop-label-${ facet . name } -${ v . id } ` }
150- className = "text-sm"
151- >
152- { v . text } { v . count && `(${ v . count } )` }
153- </ span >
154- </ div >
155- </ AccordionFacets . Item >
156- ) ) }
157- </ div >
158- </ AccordionFacets . ValueList >
159- </ CardContent >
107+ < AccordionFacets . ValueList className = "not-prose px-0 py-0" >
108+ { facet . value . map ( ( v , index ) => (
109+ < AccordionFacets . Item
110+ className = "pr-2 my-2 flex capitalize items-center"
111+ key = { v . id }
112+ { ...{
113+ index,
114+ facetValueId : v . id ,
115+ } }
116+ >
117+ < AccordionFacets . ItemCheckbox asChild className = "align-middle data-[state=checked]:bg-violet-800 data-[state=checked]:border-violet-800" >
118+ < Checkbox className = "bg-white data-[state=checked]:bg-violet-800 data-[state=checked]:border-violet-800" />
119+ </ AccordionFacets . ItemCheckbox >
120+ < AccordionFacets . ItemLabel className = "overflow-hidden ml-2 text-sm whitespace-nowrap cursor-pointer text-ellipsis" title = { `${ v . text } ${ v . count ? ` (${ v . count } )` : '' } ` } >
121+ { v . text } { v . count && `(${ v . count } )` }
122+ </ AccordionFacets . ItemLabel >
123+ </ AccordionFacets . Item >
124+ ) ) }
125+ </ AccordionFacets . ValueList >
160126 </ AccordionFacets . Content >
161127 </ AccordionFacets . Facet >
162- </ Card >
128+ < Separator className = "my-4" />
129+ </ div >
163130 ) ) }
164131 </ SearchResultsAccordionFacets >
165132 ) ;
0 commit comments