import type { Meta, StoryObj } from 'storybook-solidjs-vite';
import { createSignal } from 'solid-js';
import {
Message, MessageAvatar, MessageContent, MessageActions,
FeedbackBar, Button,
} from '../index';
import { Tooltip } from '../ui/tooltip';
import { Copy, ThumbsUp, ThumbsDown, RefreshCw, Share, Bookmark, Check } from 'lucide-solid';
const meta: Meta = {
title: 'Examples/Message Actions',
parameters: { layout: 'padded' },
};
export default meta;
type Story = StoryObj;
export const HoverActions: Story = {
name: 'Actions on Hover',
render: () => (
Hover over the assistant message to see action buttons appear.
How do I handle errors in async Rust functions?
{`In Rust, async functions return \`Result\` types just like sync functions. The \`?\` operator works seamlessly:
\`\`\`rust
async fn fetch_user(id: u64) -> Result {
let response = client.get(&format!("/users/{}", id))
.send()
.await?; // propagates reqwest::Error
let user = response
.json::()
.await?; // propagates deserialization error
Ok(user)
}
\`\`\`
Use \`anyhow::Result\` for applications and \`thiserror\` for libraries to define custom error types.`}
{`To install Tailwind CSS v4 in a Vite project:
\`\`\`bash
pnpm add tailwindcss @tailwindcss/vite
\`\`\`
Then add the plugin to your \`vite.config.ts\`:
\`\`\`typescript
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [tailwindcss()],
});
\`\`\`
Import Tailwind in your main CSS file:
\`\`\`css
@import "tailwindcss";
\`\`\``}
Everything combined — avatar, markdown, built-in copy/regenerate plus custom
Share & Bookmark (with copy→check confirmation), and a Feedback Bar below.
{`Use \`anyhow::Result\` for application code and \`thiserror\` for libraries:
\`\`\`rust
async fn fetch_user(id: u64) -> anyhow::Result {
let user = client.get(&format!("/users/{}", id)).send().await?.json().await?;
Ok(user)
}
\`\`\`
The \`?\` operator propagates errors from any \`Result\`-returning call.`}
{showFeedback() && (
setShowFeedback(false)}
/>
)}