import type { ReactNode } from 'react'
import { Link } from 'react-router-dom'
import type { AcAppKey } from '../lib/acAssets'
import { AcIcon } from './AcIcon'
export function PageTitle({ title, subtitle }: { title: string; subtitle?: string }) {
return (
{title}
{subtitle ? (
{subtitle}
) : null}
)
}
export function Card({ children, className = '' }: { children: ReactNode; className?: string }) {
return (
{children}
)
}
export function Field({
label,
children,
}: {
label: string
children: ReactNode
}) {
return (
)
}
export function Input(props: React.InputHTMLAttributes) {
return (
)
}
export function Textarea(props: React.TextareaHTMLAttributes) {
return (
)
}
export function Button({
children,
variant = 'primary',
...props
}: React.ButtonHTMLAttributes & { variant?: 'primary' | 'ghost' | 'danger' | 'soft' }) {
const styles =
variant === 'primary'
? 'ac-btn-primary'
: variant === 'danger'
? 'ac-btn-danger'
: variant === 'soft'
? 'ac-btn-secondary bg-brand-soft text-brand'
: 'ac-btn-secondary'
const { className, ...rest } = props
return (
)
}
export function Badge({
children,
tone = 'neutral',
}: {
children: ReactNode
tone?: 'neutral' | 'brand' | 'sky' | 'success' | 'warning' | 'danger'
}) {
const tones = {
neutral: 'border-wood-dark bg-accent-soft text-ink',
brand: 'border-brand bg-brand-soft text-brand',
sky: 'border-accent bg-accent-soft text-accent',
success: 'border-success bg-success-soft text-success',
warning: 'border-warning bg-warning-soft text-warning',
danger: 'border-danger bg-danger-soft text-danger',
}
return (
{children}
)
}
export function ErrorText({ message }: { message?: string }) {
if (!message) return null
return {message}
}
export function CopyableId({ label, value }: { label: string; value: string }) {
const copy = async () => {
if (!value) return
await navigator.clipboard.writeText(value)
}
return (
{label}
{value || '—'}
{value ? (
) : null}
)
}
export function QuickLinkCard({
to,
title,
desc,
icon,
}: {
to: string
title: string
desc: string
icon: AcAppKey
tag?: string
}) {
return (
{title}
{desc}
打開 →
)
}
export function StatCard({
label,
value,
hint,
tone = 'default',
}: {
label: string
value: ReactNode
hint?: string
tone?: 'default' | 'brand' | 'sky'
}) {
const slot =
tone === 'brand' ? 'ac-slot ac-slot--brand' : tone === 'sky' ? 'ac-slot ac-slot--sky' : 'ac-slot'
return (
{label}
{value}
{hint ?
{hint}
: null}
)
}