mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
* fix(react-doctor): remove unused export types, useEffect clearTimeout missing, a11y fixes * fix(react-doctor): strip unused export types from contracts, copilot, stores, and components Remove export keyword from type/interface declarations confirmed to have zero importers across lib/api/contracts/tools/aws/, lib/api/contracts/*.ts, lib/copilot/generated/, stores/workflows/workflow/types.ts, ee/access-control, ee/data-retention, lib/logs/types.ts, and app/workspace component files. TypeScript and API validation both pass clean. Reduces unused-types count from 394 → 181 and fully eliminates the ✗ critical dead-code categories (exports, types, files now show as ⚠ warnings not ✗ errors). * docs improvements * fix(react-doctor): delete 50 unused files (dead barrels, unreachable components, stale utilities) Remove confirmed-unused barrel index.ts files across stores/, connectors/, executor/, lib/, and app/workspace/ that had zero importers. Also delete unreachable components (chat-history-skeleton, trace-spans, logs-list, template-profile, enterprise landing sections), stale utilities (buffered-stream, blob-to-data-url, queued-workflow-execution, compute-edit-sequence), and obsolete generated/contract files. TypeScript passes clean. * remove dead code * cleanup * more * fix(blog): restore DiffControlsDemo for v0-5 blog post * fix: restore ContactButton for enterprise blog post, export WIKIPEDIA_PAGE_CONTENT_OUTPUT_PROPERTIES * fix(react-doc): restore stripped exports and remove server-only dependency * chore(deps): update lockfile after removing server-only * added back some exports * docs * more * fix type issues * tc * fix docs search route Co-authored-by: Cursor <cursoragent@cursor.com> * fix(tag-dropdown): add missing isEqual import from es-toolkit --------- Co-authored-by: Cursor <cursoragent@cursor.com>
103 lines
2.8 KiB
TypeScript
103 lines
2.8 KiB
TypeScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
import { ChevronRight } from 'lucide-react'
|
|
import { serializeJsonLd } from '@/lib/json-ld'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
interface FAQItem {
|
|
question: string
|
|
answer: string
|
|
}
|
|
|
|
interface FAQProps {
|
|
items: FAQItem[]
|
|
title?: string
|
|
}
|
|
|
|
function FAQItemRow({
|
|
item,
|
|
isOpen,
|
|
onToggle,
|
|
}: {
|
|
item: FAQItem
|
|
isOpen: boolean
|
|
onToggle: () => void
|
|
}) {
|
|
return (
|
|
<div>
|
|
<button
|
|
type='button'
|
|
onClick={onToggle}
|
|
aria-expanded={isOpen}
|
|
className='flex w-full cursor-pointer items-center gap-3 px-4 py-2.5 text-left font-[470] text-[0.875rem] text-[rgba(0,0,0,0.8)] transition-colors hover:bg-[rgba(0,0,0,0.02)] dark:text-[rgba(255,255,255,0.85)] dark:hover:bg-[rgba(255,255,255,0.03)]'
|
|
>
|
|
<ChevronRight
|
|
className={cn(
|
|
'h-3.5 w-3.5 shrink-0 text-[rgba(0,0,0,0.3)] transition-transform duration-200 dark:text-[rgba(255,255,255,0.3)]',
|
|
isOpen && 'rotate-90'
|
|
)}
|
|
/>
|
|
{item.question}
|
|
</button>
|
|
<div
|
|
className='grid transition-[grid-template-rows,opacity] duration-200 ease-in-out'
|
|
style={{
|
|
gridTemplateRows: isOpen ? '1fr' : '0fr',
|
|
opacity: isOpen ? 1 : 0,
|
|
}}
|
|
>
|
|
<div className='overflow-hidden'>
|
|
<div className='px-4 pt-2 pb-2.5 pl-11 text-[0.875rem] text-[rgba(0,0,0,0.7)] leading-relaxed dark:text-[rgba(255,255,255,0.7)]'>
|
|
{item.answer}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export function FAQ({ items, title = 'Common Questions' }: FAQProps) {
|
|
const [openIndex, setOpenIndex] = useState<number | null>(null)
|
|
|
|
const faqSchema = {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'FAQPage',
|
|
mainEntity: items.map((item) => ({
|
|
'@type': 'Question',
|
|
name: item.question,
|
|
acceptedAnswer: {
|
|
'@type': 'Answer',
|
|
text: item.answer,
|
|
},
|
|
})),
|
|
}
|
|
|
|
return (
|
|
<div className='mt-12'>
|
|
<script
|
|
type='application/ld+json'
|
|
dangerouslySetInnerHTML={{ __html: serializeJsonLd(faqSchema) }}
|
|
/>
|
|
<h2 className='mb-4 font-[500] text-xl'>{title}</h2>
|
|
<div className='border-[rgba(0,0,0,0.08)] border-t border-b dark:border-[rgba(255,255,255,0.08)]'>
|
|
{items.map((item, index) => (
|
|
<div
|
|
key={item.question}
|
|
className={cn(
|
|
index !== items.length - 1 &&
|
|
'border-[rgba(0,0,0,0.08)] border-b dark:border-[rgba(255,255,255,0.08)]'
|
|
)}
|
|
>
|
|
<FAQItemRow
|
|
item={item}
|
|
isOpen={openIndex === index}
|
|
onToggle={() => setOpenIndex(openIndex === index ? null : index)}
|
|
/>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|