Skip to content

fix: improve text visibility in warning box for dark mode in SettingsLog - #1974

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
RedwindA:fix/Visibility
Oct 6, 2025
Merged

fix: improve text visibility in warning box for dark mode in SettingsLog#1974
seefs001 merged 1 commit into
QuantumNous:mainfrom
RedwindA:fix/Visibility

Conversation

@RedwindA

@RedwindA RedwindA commented Oct 5, 2025

Copy link
Copy Markdown
Contributor

PR 类型

  • Bug 修复
  • 新功能
  • 文档更新
  • 其他

PR 是否包含破坏性更新?

PR 描述

  • Before
image
  • After
image

问题

在日志设置页面的历史日志删除确认对话框中,警告提示框使用固定的浅黄色背景(#fff7e6),但文字颜色使用的是 Semi Design
的主题色(type="warning", type="danger",
type="tertiary")。在暗色模式下,这些主题色会变成白色或浅色,导致在浅黄色背景上可见性很差,用户难以阅读警告信息。

解决方案

将警告框内所有文本组件的颜色从主题相关的 type 属性改为显式的内联 style 颜色值:

  • 容器添加默认文字颜色 color: '#333'
  • "注意"文字使用橙色 #d46b08(警告色)
  • 时间戳使用红色 #cf1322(危险色)
  • "天前"提示使用灰色 #8c8c8c
  • 其他文字使用深灰色 #333

这样无论在亮色还是暗色模式下,文字都能在浅黄色背景上保持良好的对比度和可读性。

@coderabbitai

coderabbitai Bot commented Oct 5, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The change updates inline styles and text coloring within a confirmation modal in web/src/pages/Setting/Operation/SettingsLog.jsx. It adjusts color properties for headings, body text, date highlight, and auxiliary days-difference text. No logic, control flow, or exported interfaces were modified.

Changes

Cohort / File(s) Summary
UI styling adjustments
web/src/pages/Setting/Operation/SettingsLog.jsx
Added explicit color styles to modal title/body, target time, auxiliary days-diff text, and specific phrases; minor inline style formatting cleanup; no behavioral or data-flow changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

I nibble on CSS with careful delight,
Tinting warnings amber, making dates bright.
A hush of gray whispers “days till then,”
Logs stand steady in #333’s den.
No logic hops—just colors in view,
A rabbit approves: style fresh and true. 🐇🎨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly states that this pull request fixes text visibility in the warning box for dark mode specifically within the SettingsLog component, which directly reflects the primary change of applying explicit color values for better contrast. It is concise, descriptive, and avoids unnecessary detail or vague language. It succinctly summarizes the bug fix without listing implementation details.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
web/src/pages/Setting/Operation/SettingsLog.jsx (1)

109-116: LGTM! Consider theme-aware background for better dark mode UX.

The explicit color: '#333' provides good contrast on the light yellow background and solves the immediate dark mode text visibility issue.

However, the fixed light background (#fff7e6) may be jarring in dark mode. Consider making the warning box theme-aware in a future enhancement:

// Example future enhancement
const isDarkMode = /* detect theme */;
const warningBoxStyle = {
  background: isDarkMode ? '#2b2111' : '#fff7e6',
  border: isDarkMode ? '1px solid #594214' : '1px solid #ffd591',
  // ... other styles
};
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb0ed4d and ca9ee54.

📒 Files selected for processing (1)
  • web/src/pages/Setting/Operation/SettingsLog.jsx (1 hunks)

Comment on lines +117 to +119
<Text strong style={{ color: '#d46b08' }}>⚠️ {t('注意')}:</Text>
<Text style={{ color: '#333' }}>{t('将删除')} </Text>
<Text strong style={{ color: '#cf1322' }}>{targetTime}</Text>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify color contrast ratios meet WCAG AA standards.

The explicit colors solve the dark mode visibility issue. Please verify the contrast ratios:

  • Orange #d46b08 on #fff7e6
  • Red #cf1322 on #fff7e6

Both should meet WCAG AA (4.5:1 for normal text, 3:1 for large text).


🏁 Script executed:

#!/bin/bash
# Verify WCAG color contrast ratios

python3 << 'EOF'
def hex_to_rgb(hex_color):
    hex_color = hex_color.lstrip('#')
    return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))

def relative_luminance(rgb):
    r, g, b = [x / 255.0 for x in rgb]
    r = r / 12.92 if r <= 0.03928 else ((r + 0.055) / 1.055) ** 2.4
    g = g / 12.92 if g <= 0.03928 else ((g + 0.055) / 1.055) ** 2.4
    b = b / 12.92 if b <= 0.03928 else ((b + 0.055) / 1.055) ** 2.4
    return 0.2126 * r + 0.7152 * g + 0.0722 * b

def contrast_ratio(color1, color2):
    lum1 = relative_luminance(hex_to_rgb(color1))
    lum2 = relative_luminance(hex_to_rgb(color2))
    lighter = max(lum1, lum2)
    darker = min(lum1, lum2)
    return (lighter + 0.05) / (darker + 0.05)

bg = '#fff7e6'
colors = {
    'Orange warning (#d46b08)': '#d46b08',
    'Red danger (#cf1322)': '#cf1322',
    'Dark gray (#333)': '#333',
    'Light gray (#8c8c8c)': '#8c8c8c'
}

print("WCAG Contrast Ratios (Background: #fff7e6)")
print("=" * 50)
print("WCAG AA requires: 4.5:1 for normal text, 3:1 for large text")
print("WCAG AAA requires: 7:1 for normal text, 4.5:1 for large text")
print()

for name, color in colors.items():
    ratio = contrast_ratio(bg, color)
    status = "✓ PASS AA" if ratio >= 4.5 else ("✓ PASS AA Large" if ratio >= 3.0 else "✗ FAIL")
    print(f"{name:30s} {ratio:5.2f}:1  {status}")
EOF

Length of output: 574


Adjust warning text color for WCAG AA compliance
Orange #d46b08 on #fff7e6 yields 3.34:1 (fails 4.5:1 normal-text contrast; only meets 3:1 large-text). Use a darker shade or ensure it’s ≥18pt bold. Red #cf1322 (5.23:1) is fine.

🤖 Prompt for AI Agents
In web/src/pages/Setting/Operation/SettingsLog.jsx around lines 117-119, the
orange warning text uses #d46b08 which fails WCAG AA contrast against the
background (#fff7e6); replace that color with a darker orange that meets at
least 4.5:1 contrast (for example use ~#9a4700 or darker) or alternatively
increase the text to ≥18pt bold, and keep the red #cf1322 unchanged; update the
style value accordingly so the warning text meets WCAG AA.

Comment on lines 120 to +123
{daysDiff > 0 && (
<Text type="tertiary"> ({t('约')} {daysDiff} {t('天前')})</Text>
<Text style={{ color: '#8c8c8c' }}> ({t('约')} {daysDiff} {t('天前')})</Text>
)}
<Text> {t('之前的所有日志')}</Text>
<Text style={{ color: '#333' }}> {t('之前的所有日志')}</Text>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Potential accessibility issue: Light gray may have insufficient contrast.

The light gray color #8c8c8c on the light yellow background #fff7e6 likely has a contrast ratio below 4.5:1, which fails WCAG AA standards for normal text.

Consider using a darker gray (e.g., #595959 or #666) to ensure the auxiliary "days ago" text remains readable for users with visual impairments.

Apply this diff to use a darker, more accessible gray:

-              <Text style={{ color: '#8c8c8c' }}> ({t('约')} {daysDiff} {t('天前')})</Text>
+              <Text style={{ color: '#666' }}> ({t('约')} {daysDiff} {t('天前')})</Text>

Note: The verification script in the previous comment will confirm the actual contrast ratios.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{daysDiff > 0 && (
<Text type="tertiary"> ({t('约')} {daysDiff} {t('天前')})</Text>
<Text style={{ color: '#8c8c8c' }}> ({t('约')} {daysDiff} {t('天前')})</Text>
)}
<Text> {t('之前的所有日志')}</Text>
<Text style={{ color: '#333' }}> {t('之前的所有日志')}</Text>
{daysDiff > 0 && (
<Text style={{ color: '#666' }}> ({t('约')} {daysDiff} {t('天前')})</Text>
)}
<Text style={{ color: '#333' }}> {t('之前的所有日志')}</Text>
🤖 Prompt for AI Agents
In web/src/pages/Setting/Operation/SettingsLog.jsx around lines 120 to 123, the
auxiliary "days ago" text uses color #8c8c8c which is too light for the page
background; replace that hex with a darker accessible gray such as #595959 or
#666 to meet contrast requirements, update the inline style accordingly, and run
the project's contrast verification script to confirm the ratio >= 4.5:1.

@seefs001
seefs001 merged commit 2397ec8 into QuantumNous:main Oct 6, 2025
1 check passed
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
fix: improve text visibility in warning box for dark mode in SettingsLog
@RedwindA
RedwindA deleted the fix/Visibility branch July 23, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants