预览使用示例数据运行,不需要网络,也不需要渠道。
tsx
import { YuvaDiscussionComposer } from "@/components/yuva-discussion-composer"
import { YuvaDiscussionsProvider } from "@/hooks/use-yuva-discussions"
export function Docs({ children }: { children: React.ReactNode }) {
return (
<YuvaDiscussionsProvider
server={process.env.NEXT_PUBLIC_YUVA_SERVER}
channel={process.env.NEXT_PUBLIC_YUVA_CHANNEL}
>
<YuvaDiscussionComposer withTitle onSubmit={async ({ title, body }) => save(title, body)} />
</YuvaDiscussionsProvider>
)
}安装
在 shadcn 项目中运行。文件会复制到你自己的代码里。
Shell
npx shadcn@latest add https://useyuva.com/r/yuva-discussion-composer.jsonShell
pnpm dlx shadcn@latest add https://useyuva.com/r/yuva-discussion-composer.jsonShell
yarn dlx shadcn@latest add https://useyuva.com/r/yuva-discussion-composer.jsonShell
bunx --bun shadcn@latest add https://useyuva.com/r/yuva-discussion-composer.json用法
tsx
import { YuvaDiscussionComposer } from "@/components/yuva-discussion-composer"
<YuvaDiscussionComposer withTitle onSubmit={async ({ title, body }) => {}} />Props
YuvaDiscussionComposerProps
| Prop | 类型 |
|---|---|
withTitle? | boolean |
initialTitle? | string |
initialBody? | string |
submitLabel? | string |
placeholder? | string |
autoFocus? | boolean |
labels? | Partial<YuvaDiscussionsLabels> |
className? | string |
onTitleChange? | (title: string) => void |
onSubmit | (input: { title: string; body: string }) => Promise<unknown> |
onCancel? | () => void |
YuvaSignInProps
| Prop | 类型 |
|---|---|
labels? | Partial<YuvaDiscussionsLabels> |
className? | string |
标签
依赖
安装此项时还会添加以下内容。