Skip to content

Commit

Permalink
fix(masterbots.ai): restore threadDoubleAccordion sticky effect (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
TopETH committed May 3, 2024
1 parent 00f952c commit 36707b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export function ThreadListAccordion({
type="multiple"
>
{/* Frist level question and excerpt visible on lists */}
<AccordionItem value="pair-1">
<AccordionItem className="relative" value="pair-1">
<AccordionTrigger
isSticky
className={cn('hover:bg-mirage px-5', state.isOpen && 'bg-mirage')}
>
<ThreadHeading
Expand Down
18 changes: 15 additions & 3 deletions apps/masterbots.ai/components/ui/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import * as AccordionPrimitive from '@radix-ui/react-accordion'
import { ChevronDown } from 'lucide-react'
import { cn } from '@/lib/utils'

interface AccordionTriggerProps
extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> {
isSticky?: boolean
}

const Accordion = AccordionPrimitive.Root

const AccordionItem = React.forwardRef<
Expand All @@ -21,9 +26,16 @@ AccordionItem.displayName = 'AccordionItem'

const AccordionTrigger = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<AccordionPrimitive.Header className="flex">
AccordionTriggerProps
>(({ className, isSticky = false, children, ...props }, ref) => (
<AccordionPrimitive.Header
className={cn(
'flex',
isSticky
? '[&[data-state=open]]:sticky [&[data-state=open]]:top-0 z-[1]'
: ''
)}
>
<AccordionPrimitive.Trigger
className={cn(
'flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
Expand Down

0 comments on commit 36707b9

Please sign in to comment.