Weird typescript error
Unanswered
Bald Eagle posted this in #help-forum
Bald EagleOP
Hi all I'm attempting to make a custom dropdown accordion but there is a scrolldown icon that appears to the right which I don't want to have . How do I get rid of it?
Here is my code:
The image is attached:
Here is my code:
import ChevronUpLogo from '@/components/ChevronUpLogo'
import React, { useRef, useState } from 'react'
interface AccordionProps {
title: React.ReactNode
content: React.ReactNode
}
export const Accordion: React.FC<AccordionProps> = ({ title, content }) => {
const [active, setActive] = useState(false)
const [height, setHeight] = useState('0px')
const [rotate, setRotate] = useState('transform duration-700 ease')
const contentSpace = useRef(null)
function toggleAccordion() {
setActive((prevState) => !prevState)
// @ts-ignore
setHeight(active ? '0px' : `${contentSpace.current.scrollHeight}px`)
setRotate(active ? 'transform duration-700 ease' : 'transform duration-700 ease rotate-180')
}
return (
<div className="flex flex-col">
<button
className="py-6 box-border appearance-none cursor-pointer focus:outline-none flex items-center justify-between"
onClick={toggleAccordion}
>
<p className="inline-block text-footnote light">{title}</p>
<div className={`${rotate} inline-block`}>
<ChevronUpLogo/>
</div>
</button>
<div
ref={contentSpace}
style={{ maxHeight: `${height}` }}
className="overflow-auto transition-max-height duration-700 ease-in-out"
>
<div className="pb-10">{content}</div>
</div>
</div>
)
}The image is attached:
2 Replies
Bald EagleOP
<div className="block rounded-lg bg-white p-6 shadow-[0_2px_15px_-3px_rgba(0,0,0,0.07),0_10px_20px_-2px_rgba(0,0,0,0.04)] dark:bg-neutral-700">
<Accordion
title={
audioUrl ?
<div className="audio-player">
<audio src={audioUrl} controls></audio>
</div> :
<h1>This item does not have an audio file associated. Please delete!</h1>
}
content={
<div className="flex flex-col items-center gap-4">
{transcription ? <p>{transcription}</p> : <button onClick={transcribe}>Transcribe</button>}
<button onClick={summarize}>Summarize</button>
<button onClick={generate_embeddings}>Enable Search</button>
<button onClick={semanticSearch}>Search</button>
<button onClick={deleteItem}>Delete</button>
</div>
}
/>
</div>This is the code that populates the accordion
Also if you could help me reduce the top margins that would be very helpful as well