Files
Ivan Vasilov 09a62662d8 chore: Clean up ui-patterns imports (#29132)
* Switch all top-level imports for ui-patterns components to use specific components when importing.

* Remove the @ui-patterns shorthand since it works exactly the same without the @.

* More import fixes.

* Fix the ui-patterns tests.
2024-09-30 21:41:26 +02:00

31 lines
817 B
TypeScript

import { Box } from 'lucide-react'
import { useState } from 'react'
import { AssistantChatForm } from 'ui-patterns/AssistantChat'
export default function AssistantChatDemo() {
const [value, setValueState] = useState('')
const [loading, setLoading] = useState(false)
function handleSubmit(event: React.FormEvent) {
// set loading for 3 seconds and then reset
setLoading(true)
setTimeout(() => {
setLoading(false)
}, 1500)
}
return (
<AssistantChatForm
icon={<Box strokeWidth={1.5} size={24} className="text-foreground-muted" />}
value={value}
loading={loading}
disabled={loading}
onValueChange={(e) => setValueState(e.target.value)}
onSubmit={async (event) => {
event.preventDefault()
handleSubmit(event)
}}
/>
)
}