AI UP LAB / 组件规范Components / v1.2.1
资源卡片与收藏Resource cards & favorites
把预览、用途、来源与下一步放在一个可扫描的单元里,帮助读者从发现进入详情。Combine preview, purpose, source, and next action in a scannable unit that leads readers into a resource.
01 / LIVE SPECIMEN
实际示例Working example
示例 / 可操作的状态标有按钮EXAMPLE / Interactive states have controls
组件Component
CSS Bed:一套可切换的 classless CSS 主题床CSS Bed: a switchable bed of classless CSS themes
给纯 HTML 切换不同的 CSS 主题。Switch CSS themes for plain HTML.
cssbed.com
02 / STRUCTURE & RULES
组成与使用规则Anatomy & usage
- 01可选预览 → 目录标签 → 标题 → 短简介 → 来源域名。Optional preview → section → title → short description → source host.
- 02主链接包裹内容区域,收藏按钮作为相邻独立控件。The primary link wraps the content; the favorite button is a separate sibling.
- 03稳定键由来源库与原始 id 组成,不能用当前列表位置替代。Stable keys combine source library and original ID, never list position.
必须遵守Required behavior
- 短简介写具体用途,不重复长标题,也不把宣传语当事实。Describe a concrete purpose without repeating the title or presenting promotion as fact.
- 长标题可换行;优先保证产品名和用途可读。Wrap long titles and preserve readable product names and purpose.
- 无图条目仍然展示完整正文;不要补一个无关图片。Text-only entries retain full copy; do not fill the gap with unrelated imagery.
- 收藏不触发卡片导航;刷新与详情页之间保持同一状态。Saving must not navigate; preserve the state across refresh and detail views.
推荐做法Do
“CSS Bed:切换 HTML 的 CSS 主题”,附 cssbed.com 来源。CSS Bed: switch CSS themes for HTML, with the cssbed.com source.
避免做法Avoid
“最强神器,效率暴涨 100 倍”,没有来源或使用条件。The ultimate tool: 100× faster, with no source or requirements.
03 / PARAMETERS
参数与状态Parameters & states
| 参数Parameter | 取值Value | 用法Usage |
|---|---|---|
card.radius | 8px | 统一卡片边界,悬停仅强调边线。Consistent card edge; hover emphasizes the border only. |
card.title | 17px / mobile 15px | 桌面纵向卡片 / 手机紧凑卡片。Desktop vertical / compact mobile card. |
card.thumbnail | 16:10 / mobile 100×90px | 桌面封面比例与当前手机缩略图规格。Desktop cover ratio and current mobile thumbnail size. |
favorite.key | library:id | 与详情页和收藏页共用同一个稳定键。Share the stable key with detail and saved pages. |
有图 / 无图With / without image
两者都能独立传达用途与来源,图像不决定是否可阅读。Both communicate purpose and source independently of imagery.
未收藏 / 已收藏Unsaved / saved
图标、可读标签与 aria-pressed 同步;重复点击可以撤销。Synchronize icon, label, and aria-pressed; clicking again reverses it.
数据陈旧Stale data
以真实核验日期和说明表达状态,不自动伪装成“已验证”。Use real review dates and explanations; never invent a verified badge.
代码映射与 AI 使用Code mapping & AI use
先读取本项规则,再通过下列映射找到已有实现。调整共用组件时,同步检查依赖项。Read these rules, then locate the existing implementation below. Check dependencies when changing shared components.
src/components/DirectoryCard.astro卡片结构与链接Card anatomy and links ↗src/components/FavButton.astro收藏按钮Favorite control ↗src/lib/directory.ts统一内容对象Unified resource objects ↗实现片段Implementation fragment
组件片段需放入相应 Astro 文件上下文,按代码映射补齐导入。Place component fragments in the corresponding Astro context and complete imports from the code mappings.
import DirectoryCard from "../components/DirectoryCard.astro";
import { entries } from "../lib/directory";
const entry = entries.find(item => item.key === "html:css-bed");
{entry && <DirectoryCard entry={entry} />}使用的设计变量Design tokens
--lab-radius-card--lab-color-surface--lab-color-border相关规则Related rules
给 AI 的完整规则文本Full rules for AI
# 资源卡片与收藏 / Resource cards & favorites
ID: resource-cards
Version: 1.2.1
把预览、用途、来源与下一步放在一个可扫描的单元里,帮助读者从发现进入详情。
Combine preview, purpose, source, and next action in a scannable unit that leads readers into a resource.
## Anatomy
- 可选预览 → 目录标签 → 标题 → 短简介 → 来源域名。
Optional preview → section → title → short description → source host.
- 主链接包裹内容区域,收藏按钮作为相邻独立控件。
The primary link wraps the content; the favorite button is a separate sibling.
- 稳定键由来源库与原始 id 组成,不能用当前列表位置替代。
Stable keys combine source library and original ID, never list position.
## Parameters
- card.radius: 8px
统一卡片边界,悬停仅强调边线。
Consistent card edge; hover emphasizes the border only.
- card.title: 17px / mobile 15px
桌面纵向卡片 / 手机紧凑卡片。
Desktop vertical / compact mobile card.
- card.thumbnail: 16:10 / mobile 100×90px
桌面封面比例与当前手机缩略图规格。
Desktop cover ratio and current mobile thumbnail size.
- favorite.key: library:id
与详情页和收藏页共用同一个稳定键。
Share the stable key with detail and saved pages.
## Rules
- 短简介写具体用途,不重复长标题,也不把宣传语当事实。
Describe a concrete purpose without repeating the title or presenting promotion as fact.
- 长标题可换行;优先保证产品名和用途可读。
Wrap long titles and preserve readable product names and purpose.
- 无图条目仍然展示完整正文;不要补一个无关图片。
Text-only entries retain full copy; do not fill the gap with unrelated imagery.
- 收藏不触发卡片导航;刷新与详情页之间保持同一状态。
Saving must not navigate; preserve the state across refresh and detail views.
## States
- 有图 / 无图 / With / without image: 两者都能独立传达用途与来源,图像不决定是否可阅读。
Both communicate purpose and source independently of imagery.
- 未收藏 / 已收藏 / Unsaved / saved: 图标、可读标签与 aria-pressed 同步;重复点击可以撤销。
Synchronize icon, label, and aria-pressed; clicking again reverses it.
- 数据陈旧 / Stale data: 以真实核验日期和说明表达状态,不自动伪装成“已验证”。
Use real review dates and explanations; never invent a verified badge.
## Do / Avoid
- Do: “CSS Bed:切换 HTML 的 CSS 主题”,附 cssbed.com 来源。 / CSS Bed: switch CSS themes for HTML, with the cssbed.com source.
- Avoid: “最强神器,效率暴涨 100 倍”,没有来源或使用条件。 / The ultimate tool: 100× faster, with no source or requirements.
## Code mapping
- src/components/DirectoryCard.astro: 卡片结构与链接 / Card anatomy and links
- src/components/FavButton.astro: 收藏按钮 / Favorite control
- src/lib/directory.ts: 统一内容对象 / Unified resource objects
## Dependencies
foundations, layout, buttons
## Acceptance
- 无图、长中文标题和长英文域名均不溢出。
Missing images, long Chinese titles, and long hosts do not overflow.
- 收藏与详情跳转可以分别用键盘触发。
Keyboard users can save and navigate independently.
- 来源库 id 与旧收藏键保持兼容。
Source IDs remain compatible with existing saved keys.
## Implementation example
```
import DirectoryCard from "../components/DirectoryCard.astro";
import { entries } from "../lib/directory";
const entry = entries.find(item => item.key === "html:css-bed");
{entry && <DirectoryCard entry={entry} />}
```
## Reference
Method reference: https://tmall-design.com/#style/component/product-card
Rules, parameters, examples, and branding in this file are specific to AI UP LAB.
交付前检查Before delivery
- 无图、长中文标题和长英文域名均不溢出。Missing images, long Chinese titles, and long hosts do not overflow.
- 收藏与详情跳转可以分别用键盘触发。Keyboard users can save and navigate independently.
- 来源库 id 与旧收藏键保持兼容。Source IDs remain compatible with existing saved keys.
方法参考与适用边界Reference & scope
参考 Tmall Design 将规则、映射与代码关联的组织方法。本页参数、示例和品牌资产为 AI UP LAB 自身规范。Inspired by Tmall Design’s organization of rules, mappings, and code. Parameters, examples, and brand assets here are specific to AI UP LAB.
Tmall Design ↗