@@ -36,6 +36,24 @@ import {
3636import { categoryTabStyles } from '@/data/categoryStyles' ;
3737import { CACHE_KEY , getCachedTerms } from '@/lib/ai/explainCache' ;
3838
39+ type QaItemStyle = CSSProperties & {
40+ '--qa-accent' : string ;
41+ '--qa-accent-soft' : string ;
42+ } ;
43+
44+ function normalizeCachedTerm ( term : string ) : string {
45+ return term . toLowerCase ( ) . trim ( ) ;
46+ }
47+
48+ function hexToRgba ( hex : string , alpha : number ) : string {
49+ const normalized = hex . replace ( '#' , '' ) ;
50+ if ( normalized . length !== 6 ) return `rgba(0, 0, 0, ${ alpha } )` ;
51+ const r = parseInt ( normalized . slice ( 0 , 2 ) , 16 ) ;
52+ const g = parseInt ( normalized . slice ( 2 , 4 ) , 16 ) ;
53+ const b = parseInt ( normalized . slice ( 4 , 6 ) , 16 ) ;
54+ return `rgba(${ r } , ${ g } , ${ b } , ${ alpha } )` ;
55+ }
56+
3957function isListItemBlock ( value : ListEntry ) : value is ListItemBlock {
4058 return (
4159 ! ! value &&
@@ -307,11 +325,11 @@ export default function AccordionList({ items }: { items: QuestionEntry[] }) {
307325 ) ;
308326 const [ modalOpen , setModalOpen ] = useState ( false ) ;
309327 const [ cachedTerms , setCachedTerms ] = useState < Set < string > > (
310- ( ) => new Set ( getCachedTerms ( ) )
328+ ( ) => new Set ( getCachedTerms ( ) . map ( normalizeCachedTerm ) )
311329 ) ;
312330
313331 const refreshCachedTerms = useCallback ( ( ) => {
314- const terms = getCachedTerms ( ) ;
332+ const terms = getCachedTerms ( ) . map ( normalizeCachedTerm ) ;
315333 setCachedTerms ( new Set ( terms ) ) ;
316334 } , [ ] ) ;
317335
@@ -380,20 +398,21 @@ export default function AccordionList({ items }: { items: QuestionEntry[] }) {
380398 < Accordion type = "single" collapsible className = "w-full" >
381399 { items . map ( ( q , idx ) => {
382400 const key = q . id ?? idx ;
383- const accent =
401+ const accentColor =
384402 categoryTabStyles [ q . category as keyof typeof categoryTabStyles ]
385- ?. accent ;
403+ ?. accent ?? '#A1A1AA' ;
386404 const animationDelay = `${ Math . min ( idx , 10 ) * 60 } ms` ;
387- const itemStyle : CSSProperties = {
405+ const itemStyle : QaItemStyle = {
388406 animationDelay,
389407 animationFillMode : 'both' ,
390- ...( accent ? ( { '--qa-accent' : accent } as CSSProperties ) : { } ) ,
408+ '--qa-accent' : accentColor ,
409+ '--qa-accent-soft' : hexToRgba ( accentColor , 0.22 ) ,
391410 } ;
392411 return (
393412 < AccordionItem
394413 key = { key }
395414 value = { String ( key ) }
396- className = "qa-accordion-item mb-3 rounded-xl border border-black/5 bg-white/90 shadow-sm transition-colors last:mb-0 last:border-b dark:border-white/10 dark:bg-neutral-900/80 animate-in fade-in slide-in-from-bottom-2 duration-500"
415+ className = "qa-accordion-item mb-3 rounded-xl border border-black/5 bg-white/90 shadow-sm transition-colors last:mb-0 last:border-b dark:border-white/10 dark:bg-neutral-900/80 animate-in fade-in slide-in-from-bottom-2 duration-500 motion-reduce:animate-none "
397416 style = { itemStyle }
398417 >
399418 < AccordionTrigger
0 commit comments