//! 通用 UI 原子组件与类名常量。 //! //! 提供跨页面共享的样式常量(卡片、按钮、徽章外层等)与可复用组件 //! (分页导航、状态徽章、空状态)。样式常量用于消除散落在各页面的重复 //! Tailwind 类字符串;组件用于封装结构固定的 UI 单元。 //! //! 与 `forms.rs`(表单控件)并列,本模块聚焦通用展示类原子。 use dioxus::prelude::*; use dioxus::router::components::Link; use crate::router::Route; // =========================================================================== // 样式常量 // =========================================================================== /// Admin 卡片容器:内容档圆角(16px),作为主面板内的内容卡片,与外壳 32px 形成层次。 pub const ADMIN_CARD_CLASS: &str = "bg-[var(--color-paper-entry)] rounded-2xl shadow-sm border border-transparent hover:border-[var(--color-paper-border)] transition-colors"; /// Admin 表格容器:内容档圆角(16px),与卡片一致。 pub const ADMIN_TABLE_CLASS: &str = "bg-[var(--color-paper-entry)] rounded-2xl shadow-sm border border-transparent hover:border-[var(--color-paper-border)] transition-colors overflow-hidden"; /// Admin 表格行 hover 态:底部分割线 + 悬停背景。 pub const ADMIN_ROW_HOVER: &str = "border-b border-paper-border last:border-b-0 hover:bg-[var(--color-paper-accent-soft)] transition-colors"; /// 列表复选框统一样式(全选表头 + 行内)。 pub const CHECKBOX_CLASS: &str = "rounded border-paper-border"; /// 行内加载 spinner:环形渐变 + 自旋动画,用 currentColor 继承文字色。 /// /// 内联 SVG(含 `@keyframes`),通过 `dangerous_inner_html` 注入;尺寸由外层 /// Tailwind 类(如 `w-3.5 h-3.5`)控制。源文件 `public/icons/90-ring-with-gradient.svg`。 pub const SPINNER_SVG: &str = r#""#; /// 状态徽章外层:小号圆角胶囊。 pub const BADGE_BASE: &str = "inline-flex items-center px-2 py-0.5 rounded text-xs font-medium whitespace-nowrap"; // --- 实心小按钮(批量操作栏:通过 / 垃圾 / 删除) --- /// 绿色实心小按钮(批量通过、批量恢复)。 pub const BTN_SOLID_GREEN: &str = "px-4 py-1.5 text-sm font-medium bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors cursor-pointer"; /// 琥珀色实心小按钮(批量标为垃圾)。 pub const BTN_SOLID_AMBER: &str = "px-4 py-1.5 text-sm font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 rounded-full hover:bg-amber-500/20 transition-colors cursor-pointer"; /// 红色实心小按钮(批量删除、批量彻底删除)。 pub const BTN_SOLID_RED: &str = "px-4 py-1.5 text-sm font-medium bg-red-500/10 text-red-600 dark:text-red-400 rounded-full hover:bg-red-500/20 transition-colors cursor-pointer"; // --- 文字小按钮(表格行内操作:通过 / 垃圾 / 删除 / 恢复) --- /// 绿色文字小按钮(行内通过)。 pub const BTN_TEXT_GREEN: &str = "text-xs text-green-600 hover:text-green-800 dark:text-green-400 dark:hover:text-green-300 transition-colors cursor-pointer"; /// 琥珀色文字小按钮(行内标为垃圾)。 pub const BTN_TEXT_AMBER: &str = "text-xs text-amber-600 hover:text-amber-800 dark:text-amber-400 dark:hover:text-amber-300 transition-colors cursor-pointer"; /// 红色文字小按钮(行内删除 / 彻底删除)。 pub const BTN_TEXT_RED: &str = "text-xs text-red-500 hover:text-red-700 dark:hover:text-red-300 transition-colors cursor-pointer"; /// 主题绿(鼠尾草)文字小按钮(行内恢复)。 pub const BTN_TEXT_ACCENT: &str = "text-xs text-paper-accent hover:text-paper-primary transition-colors cursor-pointer"; // --- 次要按钮(Teal 第二色,ghost 描边风格,从属于主色 Green) --- /// 次要按钮:极简风次要操作。 pub const BTN_SECONDARY: &str = "px-6 py-2.5 rounded-full text-sm font-medium text-center text-[var(--color-paper-secondary)] bg-[var(--color-paper-entry)] hover:bg-[var(--color-paper-border)] hover:text-[var(--color-paper-primary)] transition-all cursor-pointer"; // --- 主操作按钮(主题绿实心胶囊,全站统一 CTA) --- /// 主操作按钮:主题绿实心胶囊(用于 ``、无 loading 态的静态按钮)。 pub const BTN_PRIMARY: &str = "inline-flex items-center justify-center px-5 py-2 text-sm font-medium text-[var(--color-paper-theme)] bg-[var(--color-paper-accent)] rounded-full shadow-sm hover:brightness-110 active:scale-[0.98] transition-all cursor-pointer"; /// 小号主操作按钮:工具栏场景(刷新 / 导出 / 创建备份)。 pub const BTN_PRIMARY_SM: &str = "inline-flex items-center justify-center px-4 py-1.5 text-sm font-medium text-[var(--color-paper-theme)] bg-[var(--color-paper-accent)] rounded-full hover:brightness-110 active:scale-[0.98] transition-all cursor-pointer"; // --- 描边按钮 --- /// 描边次要按钮(posts 重建、system 刷新列表):`relative` 以承载 spinner 叠加层。 pub const BTN_OUTLINE: &str = "relative px-4 py-2 rounded-full text-sm font-medium text-paper-primary border border-paper-border hover:border-paper-accent hover:text-paper-accent transition-all cursor-pointer"; /// 红色描边危险按钮(trash 清空回收站)。 pub const BTN_DANGER_OUTLINE: &str = "px-4 py-2 text-sm font-medium text-red-600 dark:text-red-400 border border-red-300 dark:border-red-900/50 rounded-full hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors cursor-pointer"; // --- 图标按钮 --- /// 关闭图标按钮(× 关闭提示条)。 pub const BTN_CLOSE_ICON: &str = "shrink-0 text-red-400 hover:text-red-600 cursor-pointer text-lg leading-none"; /// 方形图标按钮(trash 步进 −/+)。 pub const BTN_ICON: &str = "w-9 h-9 flex items-center justify-center text-sm text-paper-secondary hover:text-paper-primary hover:bg-paper-theme cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-paper-accent/40"; // =========================================================================== // 组件 // =========================================================================== /// 分页导航组件。 /// /// 统一了后台与前台的分页 UI,通过 `variant` 切换配色与展示细节: /// - `"admin"`:描边胶囊按钮(与 `BTN_OUTLINE` 同族),显示页码计数 /// (`{当前} / {总} 页 (共 {total} {unit})`),首尾页渲染禁用态。 /// - `"frontend"`:主题绿胶囊按钮,不显示计数,首尾页直接不渲染按钮。 /// /// Props: /// - `variant`:`"admin"` 或 `"frontend"` /// - `current_page`:当前页码(从 1 开始) /// - `total`:数据总条数 /// - `per_page`:每页条数,用于计算总页数 /// - `prev_route`:点击上一页跳转的目标路由(路由式翻页用) /// - `next_route`:点击下一页跳转的目标路由(路由式翻页用) /// - `unit`:计数单位("篇" / "条"),仅 admin 显示计数时使用 /// - `on_prev` / `on_next`:可选回调。传入时渲染 `