fix(web/default): api-info color dot shows wrong color due to semantic token mismatch - #4824
Conversation
Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
… color display Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR consolidates semantic color background class mappings to explicit Tailwind utilities and refactors the API info section component to derive badge colors from the centralized ChangesColor System Centralization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Calcium-Ion
left a comment
There was a problem hiding this comment.
Approving. Switching colorToBgClass in web/default/src/lib/colors.ts from semantic tokens (bg-chart-*, bg-warning) to direct Tailwind color classes resolves the name/display mismatch described in the PR. Unifying the settings preview with getBgColorClass so it shares the same source as the overview card is the right call. Adding slate to SemanticColor and the map is consistent with the existing frontend color options.
Suggest landing this before #4823 since both share the slate addition and #4823 also extends the backend whitelist for it.
…c token mismatch (QuantumNous#4824) * fix: unify color system for api-info, add slate to SemanticColor Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> * fix: use direct Tailwind color classes in colorToBgClass for accurate color display Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> --------- Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
…c token mismatch (QuantumNous#4824) * fix: unify color system for api-info, add slate to SemanticColor Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> * fix: use direct Tailwind color classes in colorToBgClass for accurate color display Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> --------- Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
…c token mismatch (QuantumNous#4824) * fix: unify color system for api-info, add slate to SemanticColor Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> * fix: use direct Tailwind color classes in colorToBgClass for accurate color display Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> --------- Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
…c token mismatch (QuantumNous#4824) * fix: unify color system for api-info, add slate to SemanticColor Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> * fix: use direct Tailwind color classes in colorToBgClass for accurate color display Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> --------- Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
…c token mismatch (QuantumNous#4824) * fix: unify color system for api-info, add slate to SemanticColor Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> * fix: use direct Tailwind color classes in colorToBgClass for accurate color display Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com> --------- Signed-off-by: Micah-Zheng <102610064+Micah-Zheng@users.noreply.github.com>
问题描述
系统管理 → 内容 → API 地址页面,设置徽章颜色后,概览页面 API 信息卡片里显示的颜色与设置的颜色不一致(例如设置 Blue 显示红色,设置 Purple 显示黄色)。
根本原因
colorToBgClass(lib/colors.ts)将颜色名映射到语义 token(bg-chart-1、bg-warning等),而这些 token 的实际颜色与颜色名称不对应:同时,设置页面的颜色预览用的是 Tailwind 硬编码类(
bg-blue-500),而概览卡片用的是getBgColorClass(语义 token),两套系统不一致,导致设置页面预览正确但概览卡片显示错误。修复方案
colorToBgClass改用直接的 Tailwind 颜色类(bg-blue-500、bg-green-500等),确保颜色名与显示颜色一致getBgColorClass,与概览卡片保持一致slate到SemanticColor类型和colorToBgClass映射(前端颜色选项已有slate但类型定义缺失)影响范围
colorToBgClass目前仅被api-info-item.tsx和api-info-section.tsx使用,影响范围仅限 API 地址功能。Signed-off-by: Micah-Zheng 102610064+Micah-Zheng@users.noreply.github.com
Summary by CodeRabbit
New Features
Refactor