Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix: improve dark mode across clients (#204)

tianma-ifabd871c06bae
diff --git a/apps/ios/EdgeEver/DesignSystem/ChromeParity.swift b/apps/ios/EdgeEver/DesignSystem/ChromeParity.swift
index 769549f4..71c44664 100644
--- a/apps/ios/EdgeEver/DesignSystem/ChromeParity.swift
+++ b/apps/ios/EdgeEver/DesignSystem/ChromeParity.swift
@@ -142,21 +142,21 @@ enum DetailSyncStatus: Equatable, Sendable {
var background: Color {
switch self {
- case .synced: return Color(hex: 0xF1F5F9)
- case .pending: return Color(hex: 0xEFF6FF)
- case .syncing: return Color(hex: 0xF1F5F9)
- case .conflict: return Color(hex: 0xFFF7ED)
- case .error: return Color(hex: 0xFEF2F2)
+ case .synced: return AppTheme.searchFill
+ case .pending: return AppTheme.infoSurface
+ case .syncing: return AppTheme.searchFill
+ case .conflict: return AppTheme.warningSurface
+ case .error: return AppTheme.dangerSurface
}
}
var foreground: Color {
switch self {
- case .synced: return Color(hex: 0x64748B)
- case .pending: return Color(hex: 0x1D4ED8)
- case .syncing: return Color(hex: 0x64748B)
- case .conflict: return Color(hex: 0xC2410C)
- case .error: return Color(hex: 0xB91C1C)
+ case .synced: return AppTheme.secondary
+ case .pending: return AppTheme.infoText
+ case .syncing: return AppTheme.secondary
+ case .conflict: return AppTheme.warningText
+ case .error: return AppTheme.danger
}
}
}
diff --git a/apps/ios/EdgeEver/DesignSystem/EditFabButton.swift b/apps/ios/EdgeEver/DesignSystem/EditFabButton.swift
index ab3cd07d..ed7b9a2b 100644
--- a/apps/ios/EdgeEver/DesignSystem/EditFabButton.swift
+++ b/apps/ios/EdgeEver/DesignSystem/EditFabButton.swift
@@ -15,7 +15,11 @@ struct EditFabButton: UIViewRepresentable {
var config = UIButton.Configuration.filled()
config.image = UIImage(systemName: "pencil", withConfiguration: UIImage.SymbolConfiguration(pointSize: 18, weight: .semibold))
config.baseForegroundColor = .white
- config.baseBackgroundColor = UIColor(red: 0x10 / 255, green: 0xB9 / 255, blue: 0x81 / 255, alpha: 1)
+ config.baseBackgroundColor = UIColor { traits in
+ traits.userInterfaceStyle == .dark
+ ? UIColor(red: 0x04 / 255, green: 0x78 / 255, blue: 0x57 / 255, alpha: 1)
+ : UIColor(red: 0x10 / 255, green: 0xB9 / 255, blue: 0x81 / 255, alpha: 1)
+ }
config.cornerStyle = .capsule
config.contentInsets = NSDirectionalEdgeInsets(top: 14, leading: 14, bottom: 14, trailing: 14)
button.configuration = config
diff --git a/apps/ios/EdgeEver/DesignSystem/Theme.swift b/apps/ios/EdgeEver/DesignSystem/Theme.swift
index b0907756..41182092 100644
--- a/apps/ios/EdgeEver/DesignSystem/Theme.swift
+++ b/apps/ios/EdgeEver/DesignSystem/Theme.swift
@@ -1,47 +1,62 @@
import SwiftUI
+import UIKit
/// Exact visual tokens from Android `workspace-styles.ts`.
enum AppTheme {
// Surfaces
- static let background = Color(hex: 0xF8FAFC)
- static let card = Color.white
- static let cardBorder = Color(hex: 0xF1F5F9)
- static let border = Color(hex: 0xE2E8F0)
- static let searchFill = Color(hex: 0xF1F5F9)
- static let searchActiveFill = Color(hex: 0xECFDF5)
+ static let background = Color(light: 0xF8FAFC, dark: 0x020617)
+ static let card = Color(light: 0xFFFFFF, dark: 0x0F172A)
+ static let cardElevated = Color(light: 0xFFFFFF, dark: 0x1E293B)
+ static let cardBorder = Color(light: 0xF1F5F9, dark: 0x1E293B)
+ static let border = Color(light: 0xE2E8F0, dark: 0x334155)
+ static let searchFill = Color(light: 0xF1F5F9, dark: 0x1E293B)
+ static let searchActiveFill = Color(light: 0xECFDF5, dark: 0x064E3B)
+ static let disabledFill = Color(light: 0xCBD5E1, dark: 0x334155)
+ static let disabledText = Color(light: 0xF8FAFC, dark: 0x94A3B8)
+ static let sheetHandle = Color(light: 0xCBD5E1, dark: 0x475569)
// Text
- static let title = Color(hex: 0x0F172A)
- static let body = Color(hex: 0x0F172A)
- static let secondary = Color(hex: 0x64748B)
- static let meta = Color(hex: 0x334155)
- static let muted = Color(hex: 0x94A3B8)
- static let slate = Color(hex: 0x475569)
- static let filterActive = Color(hex: 0x334155)
+ static let title = Color(light: 0x0F172A, dark: 0xF8FAFC)
+ static let body = Color(light: 0x0F172A, dark: 0xF8FAFC)
+ static let secondary = Color(light: 0x64748B, dark: 0xCBD5E1)
+ static let meta = Color(light: 0x334155, dark: 0xE2E8F0)
+ static let muted = Color(light: 0x94A3B8, dark: 0x94A3B8)
+ static let slate = Color(light: 0x475569, dark: 0xE2E8F0)
+ static let filterActive = Color(light: 0x334155, dark: 0x475569)
// Brand
- static let accent = Color(hex: 0x059669)
- static let accentStrong = Color(hex: 0x047857)
- static let accentBright = Color(hex: 0x10B981)
- static let accentSoft = Color(hex: 0xECFDF5)
- static let accentBorder = Color(hex: 0xA7F3D0)
- static let accentText = Color(hex: 0x065F46)
- static let danger = Color(hex: 0xDC2626)
+ static let accent = Color(light: 0x059669, dark: 0x34D399)
+ static let accentStrong = Color(light: 0x047857, dark: 0x6EE7B7)
+ static let accentBright = Color(light: 0x10B981, dark: 0x34D399)
+ static let accentSoft = Color(light: 0xECFDF5, dark: 0x064E3B)
+ static let accentBorder = Color(light: 0xA7F3D0, dark: 0x047857)
+ static let accentText = Color(light: 0x065F46, dark: 0xA7F3D0)
+ static let danger = Color(light: 0xDC2626, dark: 0xFCA5A5)
+ static let dangerStrong = Color(light: 0x9F1239, dark: 0xFDA4AF)
+ static let accentAction = Color(light: 0x059669, dark: 0x047857)
+ static let dangerAction = Color(light: 0xBE123C, dark: 0x9F1239)
+ static let dangerSurface = Color(light: 0xFFF1F2, dark: 0x4C0519)
+ static let dangerBorder = Color(light: 0xFECDD3, dark: 0x9F1239)
+ static let infoAction = Color(light: 0x1D4ED8, dark: 0x2563EB)
+ static let infoText = Color(light: 0x1E3A8A, dark: 0xBFDBFE)
+ static let infoSurface = Color(light: 0xEFF6FF, dark: 0x172554)
+ static let warningText = Color(light: 0xC2410C, dark: 0xFDBA74)
+ static let warningSurface = Color(light: 0xFFF7ED, dark: 0x431407)
// First-sync progress / error (Android memoSync* + memoListLoading* / memoListError*)
- static let syncProgressTrack = Color(hex: 0xD1FAE5)
- static let syncProgressFill = Color(hex: 0x059669)
- static let syncErrorBackground = Color(hex: 0xFFFBEB)
- static let syncErrorBorder = Color(hex: 0xFCD34D)
- static let syncErrorTitle = Color(hex: 0x451A03)
- static let syncErrorBody = Color(hex: 0x92400E)
- static let syncErrorRetryFill = Color(hex: 0xFEF3C7)
- static let emptyDashBorder = Color(hex: 0xCBD5E1)
+ static let syncProgressTrack = Color(light: 0xD1FAE5, dark: 0x065F46)
+ static let syncProgressFill = Color(light: 0x059669, dark: 0x34D399)
+ static let syncErrorBackground = Color(light: 0xFFFBEB, dark: 0x451A03)
+ static let syncErrorBorder = Color(light: 0xFCD34D, dark: 0x92400E)
+ static let syncErrorTitle = Color(light: 0x451A03, dark: 0xFEF3C7)
+ static let syncErrorBody = Color(light: 0x92400E, dark: 0xFDE68A)
+ static let syncErrorRetryFill = Color(light: 0xFEF3C7, dark: 0x78350F)
+ static let emptyDashBorder = Color(light: 0xCBD5E1, dark: 0x475569)
// Tag chip
- static let tagBackground = Color(hex: 0xF1F5F9)
+ static let tagBackground = Color(light: 0xF1F5F9, dark: 0x1E293B)
- static let fabShadow = Color(hex: 0x10B981).opacity(0.28)
+ static let fabShadow = Color(light: 0x10B981, dark: 0x34D399).opacity(0.28)
// Typography helpers matching RN sizes
static let notebookTitleFont = Font.system(size: 17, weight: .bold)
@@ -63,4 +78,24 @@ extension Color {
let b = Double(hex & 0xFF) / 255
self.init(.sRGB, red: r, green: g, blue: b, opacity: opacity)
}
+
+ init(light: UInt32, dark: UInt32, opacity: Double = 1) {
+ self.init(uiColor: UIColor { traits in
+ UIColor(
+ hex: traits.userInterfaceStyle == .dark ? dark : light,
+ opacity: opacity
+ )
+ })
+ }
+}
+
+private extension UIColor {
+ convenience init(hex: UInt32, opacity: Double = 1) {
+ self.init(
+ red: CGFloat((hex >> 16) & 0xFF) / 255,
+ green: CGFloat((hex >> 8) & 0xFF) / 255,
+ blue: CGFloat(hex & 0xFF) / 255,
+ alpha: opacity
+ )
+ }
}
diff --git a/apps/ios/EdgeEver/Editor/ResourceActions.swift b/apps/ios/EdgeEver/Editor/ResourceActions.swift
index 58593508..6c45071e 100644
--- a/apps/ios/EdgeEver/Editor/ResourceActions.swift
+++ b/apps/ios/EdgeEver/Editor/ResourceActions.swift
@@ -160,7 +160,7 @@ struct ResourceActionSheet: View {
VStack(spacing: 0) {
// Handle
Capsule()
- .fill(Color(hex: 0xCBD5E1))
+ .fill(AppTheme.sheetHandle)
.frame(width: 42, height: 4)
.padding(.top, 10)
.padding(.bottom, 14)
@@ -170,10 +170,10 @@ struct ResourceActionSheet: View {
VStack(alignment: .leading, spacing: 3) {
Text(mode == .rename ? renameTitle : actionsTitle)
.font(.system(size: 19, weight: .heavy))
- .foregroundStyle(Color(hex: 0x0F172A))
+ .foregroundStyle(AppTheme.title)
Text(target.filename)
.font(.system(size: 13))
- .foregroundStyle(Color(hex: 0x64748B))
+ .foregroundStyle(AppTheme.secondary)
.lineLimit(1)
}
Spacer(minLength: 8)
@@ -182,7 +182,7 @@ struct ResourceActionSheet: View {
} label: {
Image(systemName: "xmark")
.font(.system(size: 13, weight: .semibold))
- .foregroundStyle(Color(hex: 0x475569))
+ .foregroundStyle(AppTheme.slate)
.frame(width: 40, height: 40)
}
.buttonStyle(.plain)
@@ -202,7 +202,7 @@ struct ResourceActionSheet: View {
.controlSize(.small)
Text(env.preferences.t("正在准备文件…", en: "Preparing file…"))
.font(.system(size: 13))
- .foregroundStyle(Color(hex: 0x64748B))
+ .foregroundStyle(AppTheme.secondary)
Spacer()
}
.padding(.top, 10)
@@ -211,14 +211,14 @@ struct ResourceActionSheet: View {
if let error {
Text(error)
.font(.system(size: 13))
- .foregroundStyle(Color(hex: 0xBE123C))
+ .foregroundStyle(AppTheme.danger)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 10)
}
}
.padding(.horizontal, 20)
.padding(.bottom, 28)
- .background(Color.white)
+ .background(AppTheme.card)
.onAppear { filename = target.filename }
.confirmationDialog(deleteTitle, isPresented: $showDeleteConfirm, titleVisibility: .visible) {
Button(env.preferences.t("删除", en: "Delete"), role: .destructive) {
@@ -312,7 +312,7 @@ struct ResourceActionSheet: View {
mode = .rename
}
Rectangle()
- .fill(Color(hex: 0xE2E8F0))
+ .fill(AppTheme.border)
.frame(height: 1)
.padding(.vertical, 4)
actionRow(
@@ -329,7 +329,7 @@ struct ResourceActionSheet: View {
en: "Rename and delete are available after the resource has synced."
))
.font(.system(size: 12))
- .foregroundStyle(Color(hex: 0x64748B))
+ .foregroundStyle(AppTheme.secondary)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 4)
}
@@ -341,7 +341,7 @@ struct ResourceActionSheet: View {
VStack(alignment: .leading, spacing: 8) {
Text(env.preferences.t("文件名", en: "Filename"))
.font(.system(size: 13, weight: .semibold))
- .foregroundStyle(Color(hex: 0x475569))
+ .foregroundStyle(AppTheme.slate)
TextField("", text: $filename)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
@@ -349,7 +349,7 @@ struct ResourceActionSheet: View {
.frame(minHeight: 46)
.background(
RoundedRectangle(cornerRadius: 9)
- .stroke(Color(hex: 0xCBD5E1), lineWidth: 1)
+ .stroke(AppTheme.border, lineWidth: 1)
)
.disabled(pending)
@@ -360,11 +360,11 @@ struct ResourceActionSheet: View {
} label: {
Text(env.preferences.t("取消", en: "Cancel"))
.font(.system(size: 14, weight: .bold))
- .foregroundStyle(Color(hex: 0x475569))
+ .foregroundStyle(AppTheme.slate)
.frame(minWidth: 84, minHeight: 42)
.overlay(
RoundedRectangle(cornerRadius: 9)
- .stroke(Color(hex: 0xCBD5E1), lineWidth: 1)
+ .stroke(AppTheme.border, lineWidth: 1)
)
}
.buttonStyle(.plain)
@@ -383,7 +383,7 @@ struct ResourceActionSheet: View {
}
}
.frame(minWidth: 84, minHeight: 42)
- .background(Color(hex: 0x059669))
+ .background(AppTheme.accentAction)
.clipShape(RoundedRectangle(cornerRadius: 9))
}
.buttonStyle(.plain)
@@ -406,11 +406,11 @@ struct ResourceActionSheet: View {
HStack(spacing: 14) {
Image(systemName: systemImage)
.font(.system(size: 17, weight: .semibold))
- .foregroundStyle(danger ? Color(hex: 0xBE123C) : Color(hex: 0x0F172A))
+ .foregroundStyle(danger ? AppTheme.danger : AppTheme.title)
.frame(width: 22)
Text(label)
.font(.system(size: 16, weight: .semibold))
- .foregroundStyle(danger ? Color(hex: 0xBE123C) : Color(hex: 0x0F172A))
+ .foregroundStyle(danger ? AppTheme.danger : AppTheme.title)
Spacer()
}
.frame(minHeight: 52)
diff --git a/apps/ios/EdgeEver/Features/Auth/LoginView.swift b/apps/ios/EdgeEver/Features/Auth/LoginView.swift
index 615291be..53afea05 100644
--- a/apps/ios/EdgeEver/Features/Auth/LoginView.swift
+++ b/apps/ios/EdgeEver/Features/Auth/LoginView.swift
@@ -30,7 +30,7 @@ struct LoginView: View {
.font(.system(size: 18, weight: .semibold))
.foregroundStyle(AppTheme.slate)
.frame(width: 42, height: 42)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(Circle())
.overlay(Circle().stroke(AppTheme.border, lineWidth: 1))
}
@@ -114,7 +114,7 @@ struct LoginView: View {
.frame(maxWidth: .infinity)
.frame(height: 48)
.foregroundStyle(.white)
- .background(canSubmit ? AppTheme.title : Color(hex: 0xCBD5E1))
+ .background(canSubmit ? AppTheme.title : AppTheme.disabledFill)
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
}
.buttonStyle(CreateButtonPressStyle())
@@ -165,7 +165,7 @@ struct LoginView: View {
.foregroundStyle(AppTheme.title)
.padding(.horizontal, 14)
.frame(height: 48)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 10, style: .continuous)
diff --git a/apps/ios/EdgeEver/Features/Workspace/AccountPasswordPanel.swift b/apps/ios/EdgeEver/Features/Workspace/AccountPasswordPanel.swift
index c5a98da7..aa0c7262 100644
--- a/apps/ios/EdgeEver/Features/Workspace/AccountPasswordPanel.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/AccountPasswordPanel.swift
@@ -14,12 +14,12 @@ struct AccountPasswordPanel: View {
HStack(alignment: .top, spacing: 10) {
Image(systemName: "key.fill")
.font(.system(size: 18, weight: .semibold))
- .foregroundStyle(Color(hex: 0x15803D))
+ .foregroundStyle(AppTheme.accentStrong)
.padding(.top, 2)
VStack(alignment: .leading, spacing: 3) {
Text(env.preferences.t("修改密码", en: "Change password"))
.font(.system(size: 16, weight: .heavy))
- .foregroundStyle(Color(hex: 0x17211A))
+ .foregroundStyle(AppTheme.title)
Text(env.preferences.t(
"修改后会保留当前设备登录,并退出其他设备上的登录会话。",
en: "Keeps this device signed in and signs out other sessions."
@@ -37,7 +37,7 @@ struct AccountPasswordPanel: View {
if let message {
Text(message)
.font(.system(size: 13, weight: isError ? .regular : .bold))
- .foregroundStyle(isError ? Color(hex: 0xBE123C) : Color(hex: 0x15803D))
+ .foregroundStyle(isError ? AppTheme.danger : AppTheme.accentStrong)
}
Button {
@@ -50,7 +50,7 @@ struct AccountPasswordPanel: View {
.foregroundStyle(.white)
.frame(maxWidth: .infinity)
.frame(minHeight: 48)
- .background(Color(hex: 0x15803D))
+ .background(AppTheme.accentAction)
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
.opacity(busy ? 0.45 : 1)
}
@@ -59,7 +59,7 @@ struct AccountPasswordPanel: View {
}
.padding(16)
.padding(.bottom, 8)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 12, style: .continuous)
@@ -76,11 +76,11 @@ struct AccountPasswordPanel: View {
.font(.system(size: 15))
.padding(.horizontal, 13)
.frame(minHeight: 48)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 10, style: .continuous)
- .stroke(Color(hex: 0xCAD8CC), lineWidth: 1)
+ .stroke(AppTheme.border, lineWidth: 1)
)
}
}
diff --git a/apps/ios/EdgeEver/Features/Workspace/ApiTokensView.swift b/apps/ios/EdgeEver/Features/Workspace/ApiTokensView.swift
index c47be104..245e8dd1 100644
--- a/apps/ios/EdgeEver/Features/Workspace/ApiTokensView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/ApiTokensView.swift
@@ -40,7 +40,7 @@ struct ApiTokensView: View {
}
}
}
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).stroke(AppTheme.border, lineWidth: 1))
@@ -50,7 +50,7 @@ struct ApiTokensView: View {
TextField(env.preferences.t("名称", en: "Name"), text: $newName)
.padding(.horizontal, 12)
.frame(height: 44)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 8))
.overlay(RoundedRectangle(cornerRadius: 8).stroke(AppTheme.border, lineWidth: 1))
Button {
@@ -72,7 +72,7 @@ struct ApiTokensView: View {
}
}
.padding(16)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).stroke(AppTheme.border, lineWidth: 1))
}
diff --git a/apps/ios/EdgeEver/Features/Workspace/DevicesView.swift b/apps/ios/EdgeEver/Features/Workspace/DevicesView.swift
index d555fda8..cfba8794 100644
--- a/apps/ios/EdgeEver/Features/Workspace/DevicesView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/DevicesView.swift
@@ -37,7 +37,7 @@ struct DevicesView: View {
}
}
}
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).stroke(AppTheme.border, lineWidth: 1))
@@ -52,7 +52,7 @@ struct DevicesView: View {
.frame(maxWidth: .infinity)
.frame(height: 44)
.foregroundStyle(AppTheme.title)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).stroke(AppTheme.border, lineWidth: 1))
}
diff --git a/apps/ios/EdgeEver/Features/Workspace/ListActionsSheet.swift b/apps/ios/EdgeEver/Features/Workspace/ListActionsSheet.swift
index 8fd3ae90..a5cb8189 100644
--- a/apps/ios/EdgeEver/Features/Workspace/ListActionsSheet.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/ListActionsSheet.swift
@@ -14,7 +14,7 @@ struct ListActionsSheet: View {
var body: some View {
VStack(spacing: 0) {
Capsule()
- .fill(Color(hex: 0xCBD5E1))
+ .fill(AppTheme.sheetHandle)
.frame(width: 42, height: 4)
.padding(.top, 10)
.padding(.bottom, 8)
@@ -124,7 +124,7 @@ struct ListActionsSheet: View {
.padding(8)
}
}
- .background(Color.white)
+ .background(AppTheme.card)
.presentationDetents([.medium])
.presentationDragIndicator(.hidden)
.presentationCornerRadius(MobileUIMetrics.floatingSheetCornerRadius)
diff --git a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift
index 2f9fc51b..d4107ffc 100644
--- a/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/MemoDetailView.swift
@@ -49,7 +49,7 @@ struct MemoDetailView: View {
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
- .background(Color.white)
+ .background(AppTheme.card)
// UIKit FAB in overlay — SwiftUI Button over WKWebView often receives zero taps.
.overlay(alignment: .bottomTrailing) {
if let memo, !memo.isDeleted {
@@ -63,7 +63,7 @@ struct MemoDetailView: View {
.padding(.bottom, 12)
}
}
- .background(Color.white.ignoresSafeArea())
+ .background(AppTheme.card.ignoresSafeArea())
.toolbar(.hidden, for: .navigationBar)
.accessibilityIdentifier(DetailMemoChrome.root)
.sheet(isPresented: $showRevisions) {
@@ -259,7 +259,7 @@ struct MemoDetailView: View {
}
.padding(.horizontal, 12)
.frame(minHeight: 48)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(alignment: .bottom) {
Rectangle().fill(AppTheme.cardBorder).frame(height: 1)
}
@@ -293,13 +293,13 @@ struct MemoDetailView: View {
en: "This note changed on another device or while offline. Copy the local draft, then adopt the cloud version to continue."
))
.font(.system(size: 12))
- .foregroundStyle(Color(hex: 0x9F1239))
+ .foregroundStyle(AppTheme.dangerStrong)
.fixedSize(horizontal: false, vertical: true)
if let lastOutboxError, !lastOutboxError.isEmpty {
Text(lastOutboxError)
.font(.system(size: 12))
- .foregroundStyle(Color(hex: 0x9F1239))
+ .foregroundStyle(AppTheme.dangerStrong)
}
HStack(spacing: 8) {
@@ -316,7 +316,7 @@ struct MemoDetailView: View {
.foregroundStyle(.white)
.padding(.horizontal, 10)
.padding(.vertical, 8)
- .background(Color(hex: 0xBE123C))
+ .background(AppTheme.dangerAction)
.clipShape(RoundedRectangle(cornerRadius: 8))
}
.buttonStyle(.plain)
@@ -326,13 +326,13 @@ struct MemoDetailView: View {
} label: {
Text(env.preferences.t("复制本地草稿", en: "Copy local draft"))
.font(.system(size: 12, weight: .semibold))
- .foregroundStyle(Color(hex: 0x9F1239))
+ .foregroundStyle(AppTheme.dangerStrong)
.padding(.horizontal, 10)
.padding(.vertical, 8)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(
RoundedRectangle(cornerRadius: 8)
- .stroke(Color(hex: 0xFECDD3), lineWidth: 1)
+ .stroke(AppTheme.dangerBorder, lineWidth: 1)
)
}
.buttonStyle(.plain)
@@ -341,9 +341,9 @@ struct MemoDetailView: View {
.padding(.horizontal, 14)
.padding(.vertical, 12)
.frame(maxWidth: .infinity, alignment: .leading)
- .background(Color(hex: 0xFFF1F2))
+ .background(AppTheme.dangerSurface)
.overlay(alignment: .bottom) {
- Rectangle().fill(Color(hex: 0xFECDD3)).frame(height: 0.5)
+ Rectangle().fill(AppTheme.dangerBorder).frame(height: 0.5)
}
}
@@ -357,7 +357,7 @@ struct MemoDetailView: View {
: env.preferences.t("本地改动待上传。下拉刷新或点此可立即同步。", en: "Local changes pending upload. Pull to refresh or tap to sync now."))
)
.font(.system(size: 12))
- .foregroundStyle(isError ? Color(hex: 0x991B1B) : Color(hex: 0x1E3A8A))
+ .foregroundStyle(isError ? AppTheme.dangerStrong : AppTheme.infoText)
.fixedSize(horizontal: false, vertical: true)
HStack(spacing: 8) {
@@ -375,7 +375,7 @@ struct MemoDetailView: View {
.foregroundStyle(.white)
.padding(.horizontal, 10)
.padding(.vertical, 8)
- .background(isError ? Color(hex: 0xB91C1C) : Color(hex: 0x1D4ED8))
+ .background(isError ? AppTheme.dangerAction : AppTheme.infoAction)
.clipShape(RoundedRectangle(cornerRadius: 8))
}
.buttonStyle(.plain)
@@ -386,13 +386,13 @@ struct MemoDetailView: View {
} label: {
Text(env.preferences.t("复制本地草稿", en: "Copy local draft"))
.font(.system(size: 12, weight: .semibold))
- .foregroundStyle(Color(hex: 0x991B1B))
+ .foregroundStyle(AppTheme.dangerStrong)
.padding(.horizontal, 10)
.padding(.vertical, 8)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(
RoundedRectangle(cornerRadius: 8)
- .stroke(Color(hex: 0xFECACA), lineWidth: 1)
+ .stroke(AppTheme.dangerBorder, lineWidth: 1)
)
}
.buttonStyle(.plain)
@@ -402,10 +402,10 @@ struct MemoDetailView: View {
.padding(.horizontal, 14)
.padding(.vertical, 12)
.frame(maxWidth: .infinity, alignment: .leading)
- .background(isError ? Color(hex: 0xFEF2F2) : Color(hex: 0xEFF6FF))
+ .background(isError ? AppTheme.dangerSurface : AppTheme.infoSurface)
.overlay(alignment: .bottom) {
Rectangle()
- .fill(isError ? Color(hex: 0xFECACA) : Color(hex: 0xBFDBFE))
+ .fill(isError ? AppTheme.dangerBorder : AppTheme.infoText.opacity(0.55))
.frame(height: 0.5)
}
}
@@ -532,7 +532,7 @@ struct MemoDetailView: View {
ProgressView()
.tint(AppTheme.title)
.frame(maxWidth: .infinity, maxHeight: .infinity)
- .background(Color.white.opacity(0.92))
+ .background(AppTheme.card.opacity(0.92))
.allowsHitTesting(false)
}
}
diff --git a/apps/ios/EdgeEver/Features/Workspace/MemoEditView.swift b/apps/ios/EdgeEver/Features/Workspace/MemoEditView.swift
index d71e8f96..84b89a1e 100644
--- a/apps/ios/EdgeEver/Features/Workspace/MemoEditView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/MemoEditView.swift
@@ -79,7 +79,7 @@ struct MemoEditView: View {
.accessibilityIdentifier("createMemoUploadOverlay")
}
}
- .background(Color.white.ignoresSafeArea())
+ .background(AppTheme.card.ignoresSafeArea())
.accessibilityIdentifier(CreateMemoChrome.root)
.sheet(isPresented: $showNotebookPicker) {
EditNotebookPickerSheet(
@@ -242,7 +242,7 @@ struct MemoEditView: View {
}
.frame(minWidth: 58, minHeight: 36)
.padding(.horizontal, 12)
- .background(canSubmitDone ? AppTheme.title : Color(hex: 0xE2E8F0))
+ .background(canSubmitDone ? AppTheme.title : AppTheme.disabledFill)
.clipShape(Capsule())
}
.buttonStyle(.plain)
@@ -255,7 +255,7 @@ struct MemoEditView: View {
.padding(.horizontal, 12)
.padding(.vertical, 8)
.frame(minHeight: 52)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(alignment: .bottom) {
Rectangle().fill(AppTheme.cardBorder).frame(height: 1)
}
@@ -388,12 +388,12 @@ struct MemoEditView: View {
.foregroundStyle(AppTheme.secondary)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
- .background(Color.white)
+ .background(AppTheme.card)
.allowsHitTesting(false)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 10, style: .continuous)
@@ -981,7 +981,7 @@ private struct EditNotebookPickerSheet: View {
}
.padding(.horizontal, 16)
.padding(.vertical, 12)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(alignment: .bottom) {
Rectangle().fill(AppTheme.border).frame(height: 1)
}
@@ -1006,6 +1006,6 @@ private struct EditNotebookPickerSheet: View {
}
.listStyle(.plain)
}
- .background(Color.white)
+ .background(AppTheme.card)
}
}
diff --git a/apps/ios/EdgeEver/Features/Workspace/NotebookPickerSheet.swift b/apps/ios/EdgeEver/Features/Workspace/NotebookPickerSheet.swift
index 4b971084..c1b6e483 100644
--- a/apps/ios/EdgeEver/Features/Workspace/NotebookPickerSheet.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/NotebookPickerSheet.swift
@@ -39,7 +39,7 @@ struct NotebookPickerSheet: View {
var body: some View {
VStack(spacing: 0) {
Capsule()
- .fill(Color(hex: 0xCBD5E1))
+ .fill(AppTheme.sheetHandle)
.frame(width: 42, height: 4)
.padding(.top, 10)
.padding(.bottom, 8)
@@ -193,7 +193,7 @@ struct NotebookPickerSheet: View {
.padding(.bottom, 12)
}
}
- .background(Color.white)
+ .background(AppTheme.card)
.presentationDetents([.medium, .large])
.presentationDragIndicator(.hidden)
.onAppear {
diff --git a/apps/ios/EdgeEver/Features/Workspace/NotesListView.swift b/apps/ios/EdgeEver/Features/Workspace/NotesListView.swift
index d59b461d..64966709 100644
--- a/apps/ios/EdgeEver/Features/Workspace/NotesListView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/NotesListView.swift
@@ -157,7 +157,7 @@ struct NotesListView: View {
.foregroundStyle(AppTheme.danger)
.padding(10)
.frame(maxWidth: .infinity)
- .background(Color.white.opacity(0.96))
+ .background(AppTheme.card.opacity(0.96))
.transition(Motion.softFade)
.edgeEverErrorShake(on: err)
}
@@ -199,7 +199,7 @@ struct NotesListView: View {
.frame(maxWidth: .infinity)
.padding(.horizontal, 16)
.padding(.vertical, 34)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(style: StrokeStyle(lineWidth: 1, dash: [5, 4]))
@@ -452,10 +452,10 @@ struct NotesListView: View {
.foregroundStyle(AppTheme.title)
.padding(.horizontal, 14)
.frame(minHeight: 38)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(
RoundedRectangle(cornerRadius: 8, style: .continuous)
- .stroke(Color(hex: 0xCBD5E1), lineWidth: 1)
+ .stroke(AppTheme.border, lineWidth: 1)
)
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
}
@@ -469,7 +469,7 @@ struct NotesListView: View {
.frame(maxWidth: .infinity)
.padding(.horizontal, 16)
.padding(.vertical, 34)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(style: StrokeStyle(lineWidth: 1, dash: [5, 4]))
@@ -536,7 +536,7 @@ struct NotesListView: View {
if store.selectionMode {
ZStack {
Circle()
- .stroke(selected ? AppTheme.title : Color(hex: 0xCBD5E1), lineWidth: 1)
+ .stroke(selected ? AppTheme.title : AppTheme.border, lineWidth: 1)
.background(Circle().fill(selected ? AppTheme.title : Color.clear))
.frame(width: 24, height: 24)
if selected {
@@ -560,7 +560,7 @@ struct NotesListView: View {
.padding(.leading, store.selectionMode ? 12 : density.cardPadding)
}
.frame(maxWidth: .infinity, minHeight: density.cardMinHeight, alignment: .leading)
- .background(selected ? AppTheme.background : Color.white)
+ .background(selected ? AppTheme.background : AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 8, style: .continuous)
diff --git a/apps/ios/EdgeEver/Features/Workspace/RevisionsView.swift b/apps/ios/EdgeEver/Features/Workspace/RevisionsView.swift
index 33519eee..b05023ae 100644
--- a/apps/ios/EdgeEver/Features/Workspace/RevisionsView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/RevisionsView.swift
@@ -146,7 +146,7 @@ struct RevisionsView: View {
.foregroundStyle(canRestore ? AppTheme.title : AppTheme.muted)
.padding(.horizontal, 12)
.padding(.vertical, 10)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.stroke(AppTheme.border, lineWidth: 1)
@@ -158,7 +158,7 @@ struct RevisionsView: View {
}
}
.padding(14)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 12, style: .continuous)
@@ -235,7 +235,7 @@ struct RevisionsView: View {
}
.padding(.horizontal, 12)
.padding(.vertical, 10)
- .background(active ? AppTheme.filterActive : Color.white)
+ .background(active ? AppTheme.filterActive : AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 10, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 10, style: .continuous)
@@ -252,7 +252,7 @@ struct RevisionsView: View {
.frame(maxWidth: .infinity)
.padding(.vertical, 28)
.padding(.horizontal, 12)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 12, style: .continuous)
@@ -275,7 +275,7 @@ struct RevisionsView: View {
.frame(maxWidth: .infinity, alignment: .leading)
.textSelection(.enabled)
.padding(14)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 12, style: .continuous)
diff --git a/apps/ios/EdgeEver/Features/Workspace/SettingsView.swift b/apps/ios/EdgeEver/Features/Workspace/SettingsView.swift
index 22898052..c30ad23e 100644
--- a/apps/ios/EdgeEver/Features/Workspace/SettingsView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/SettingsView.swift
@@ -123,7 +123,7 @@ struct SettingsView: View {
}
.padding(.horizontal, 12)
.frame(minHeight: 56)
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(alignment: .bottom) {
Rectangle().fill(AppTheme.border).frame(height: 1)
}
@@ -204,7 +204,7 @@ struct SettingsView: View {
VStack(spacing: 0) {
content()
}
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 16, style: .continuous)
@@ -235,7 +235,7 @@ struct SettingsView: View {
VStack(alignment: .leading, spacing: 1) {
Text(title)
.font(.system(size: 14, weight: .bold))
- .foregroundStyle(Color(hex: 0x1E293B))
+ .foregroundStyle(AppTheme.title)
if let subtitle {
Text(subtitle)
.font(.system(size: 12))
@@ -309,7 +309,7 @@ struct SettingsView: View {
}
.padding(.horizontal, 12)
.frame(minHeight: 40)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 8))
.overlay(
RoundedRectangle(cornerRadius: 8).stroke(AppTheme.border, lineWidth: 1)
@@ -363,7 +363,7 @@ struct SettingsView: View {
Spacer(minLength: 0)
}
.padding(16)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 12, style: .continuous)
@@ -412,18 +412,18 @@ struct SettingsView: View {
.foregroundStyle(.white)
.padding(.horizontal, 14)
.frame(minHeight: 40)
- .background(Color(hex: 0xE11D48))
+ .background(AppTheme.dangerAction)
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
}
.buttonStyle(.plain)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(16)
- .background(Color(hex: 0xFFF1F2))
+ .background(AppTheme.dangerSurface)
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 8, style: .continuous)
- .stroke(Color(hex: 0xFECACA), lineWidth: 1)
+ .stroke(AppTheme.dangerBorder, lineWidth: 1)
)
}
}
@@ -457,7 +457,7 @@ struct SettingsView: View {
.frame(maxWidth: .infinity)
.frame(minHeight: 44)
.foregroundStyle(AppTheme.title)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).stroke(AppTheme.border, lineWidth: 1))
}
@@ -499,7 +499,7 @@ struct SettingsView: View {
.padding(16)
content()
}
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
.overlay(
RoundedRectangle(cornerRadius: 12, style: .continuous)
diff --git a/apps/ios/EdgeEver/Features/Workspace/TagsManagementView.swift b/apps/ios/EdgeEver/Features/Workspace/TagsManagementView.swift
index cf74d4bf..f9691f12 100644
--- a/apps/ios/EdgeEver/Features/Workspace/TagsManagementView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/TagsManagementView.swift
@@ -56,7 +56,7 @@ struct TagsManagementView: View {
private func settingsListCard<Content: View>(@ViewBuilder _ content: () -> Content) -> some View {
VStack(spacing: 0) { content() }
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).stroke(AppTheme.border, lineWidth: 1))
}
diff --git a/apps/ios/EdgeEver/Features/Workspace/TemplatePickerSheet.swift b/apps/ios/EdgeEver/Features/Workspace/TemplatePickerSheet.swift
index 2a2d211e..0cc9e51b 100644
--- a/apps/ios/EdgeEver/Features/Workspace/TemplatePickerSheet.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/TemplatePickerSheet.swift
@@ -12,7 +12,7 @@ struct CreateChoiceSheet: View {
var body: some View {
VStack(spacing: 0) {
Capsule()
- .fill(Color(hex: 0xCBD5E1))
+ .fill(AppTheme.sheetHandle)
.frame(width: 42, height: 4)
.padding(.top, 10)
.padding(.bottom, 8)
@@ -70,7 +70,7 @@ struct CreateChoiceSheet: View {
.padding(.vertical, 8)
.padding(.bottom, 12)
}
- .background(Color.white)
+ .background(AppTheme.card)
.presentationDetents([.height(280)])
.presentationDragIndicator(.hidden)
.accessibilityIdentifier("createChoiceSheet")
@@ -129,7 +129,7 @@ struct TemplatePickerSheet: View {
var body: some View {
VStack(spacing: 0) {
Capsule()
- .fill(Color(hex: 0xCBD5E1))
+ .fill(AppTheme.sheetHandle)
.frame(width: 42, height: 4)
.padding(.top, 10)
.padding(.bottom, 8)
@@ -206,7 +206,7 @@ struct TemplatePickerSheet: View {
.padding(.bottom, 20)
}
}
- .background(Color.white)
+ .background(AppTheme.card)
.presentationDetents([.medium, .large])
.presentationDragIndicator(.hidden)
.accessibilityIdentifier("templatePickerSheet")
@@ -302,7 +302,7 @@ struct TemplatePickerSheet: View {
.padding(.vertical, 2)
.background(isCustom ? AppTheme.accentSoft : AppTheme.searchFill)
.overlay(
- Capsule().stroke(isCustom ? Color(hex: 0xA7F3D0) : AppTheme.border, lineWidth: 1)
+ Capsule().stroke(isCustom ? AppTheme.accentBorder : AppTheme.border, lineWidth: 1)
)
.clipShape(Capsule())
}
diff --git a/apps/ios/EdgeEver/Features/Workspace/UsersManagementView.swift b/apps/ios/EdgeEver/Features/Workspace/UsersManagementView.swift
index 8c9b9069..7cde3acd 100644
--- a/apps/ios/EdgeEver/Features/Workspace/UsersManagementView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/UsersManagementView.swift
@@ -54,7 +54,7 @@ struct UsersManagementView: View {
}
}
}
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).stroke(AppTheme.border, lineWidth: 1))
@@ -95,7 +95,7 @@ struct UsersManagementView: View {
.buttonStyle(.plain)
}
.padding(16)
- .background(Color.white)
+ .background(AppTheme.card)
.clipShape(RoundedRectangle(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).stroke(AppTheme.border, lineWidth: 1))
}
diff --git a/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift b/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift
index 64e6ec4e..cd102e7c 100644
--- a/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift
+++ b/apps/ios/EdgeEver/Features/Workspace/WorkspaceView.swift
@@ -380,7 +380,7 @@ struct WorkspaceView: View {
.padding(.horizontal, 10)
.padding(.vertical, 6)
.frame(minHeight: 32)
- .background(searchActive ? AppTheme.searchActiveFill : Color.white)
+ .background(searchActive ? AppTheme.searchActiveFill : AppTheme.card)
.overlay(
RoundedRectangle(cornerRadius: 6)
.stroke(searchActive ? AppTheme.accentBorder : AppTheme.border, lineWidth: 1)
@@ -420,7 +420,7 @@ struct WorkspaceView: View {
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(active ? .white : AppTheme.slate)
.frame(width: MobileUIMetrics.compactControlHeight, height: MobileUIMetrics.compactControlHeight)
- .background(active ? AppTheme.filterActive : Color.white)
+ .background(active ? AppTheme.filterActive : AppTheme.card)
.clipShape(Circle())
.overlay(Circle().stroke(active ? AppTheme.filterActive : AppTheme.border, lineWidth: 1))
.accessibilityLabel(label)
@@ -472,9 +472,9 @@ struct WorkspaceView: View {
} label: {
Image(systemName: "plus")
.font(.system(size: 22, weight: .semibold))
- .foregroundStyle(canCreate ? .white : Color(hex: 0xE2E8F0))
+ .foregroundStyle(canCreate ? .white : AppTheme.disabledText)
.frame(width: createSize, height: createSize)
- .background(canCreate ? AppTheme.accentBright : Color(hex: 0xCBD5E1))
+ .background(canCreate ? AppTheme.accentAction : AppTheme.disabledFill)
.clipShape(Circle())
.overlay(Circle().stroke(Color.white, lineWidth: 3))
.shadow(
@@ -514,11 +514,11 @@ struct WorkspaceView: View {
.frame(maxWidth: .infinity)
// Home indicator — same white surface, continuous with the 52pt band.
- Color.white
+ AppTheme.card
.frame(height: bottomInset)
.frame(maxWidth: .infinity)
}
- .background(Color.white)
+ .background(AppTheme.card)
.accessibilityIdentifier("bottomNav")
}
@@ -573,11 +573,11 @@ struct WorkspaceView: View {
.frame(height: MobileUIMetrics.bottomNavigationHeight, alignment: .top)
.frame(maxWidth: .infinity)
- Color.white
+ AppTheme.card
.frame(height: bottomInset)
.frame(maxWidth: .infinity)
}
- .background(Color.white)
+ .background(AppTheme.card)
.overlay(alignment: .top) {
Rectangle().fill(AppTheme.border).frame(height: 1)
}
@@ -600,7 +600,7 @@ struct WorkspaceView: View {
}
.padding(.horizontal, 12)
.padding(.vertical, 6)
- .background(Color.white)
+ .background(AppTheme.card)
.transition(.move(edge: .top).combined(with: .opacity))
}
}
@@ -662,7 +662,7 @@ struct MoveNotebookSheet: View {
var body: some View {
VStack(spacing: 0) {
Capsule()
- .fill(Color(hex: 0xCBD5E1))
+ .fill(AppTheme.sheetHandle)
.frame(width: 42, height: 4)
.padding(.top, 10)
.padding(.bottom, 8)
@@ -713,7 +713,7 @@ struct MoveNotebookSheet: View {
}
}
}
- .background(Color.white)
+ .background(AppTheme.card)
.presentationDetents([.medium, .large])
.presentationDragIndicator(.hidden)
}
diff --git a/apps/mobile/src/components/MobileResourceActions.tsx b/apps/mobile/src/components/MobileResourceActions.tsx
index 9ee9ea4f..e1112500 100644
--- a/apps/mobile/src/components/MobileResourceActions.tsx
+++ b/apps/mobile/src/components/MobileResourceActions.tsx
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState, type ReactNode } from "react";
-import { ActivityIndicator, Alert, Modal, StyleSheet, View } from "react-native";
-import { Download, FileText, MoreHorizontal, Pencil, Share2, Trash2, X } from "./icons";
+import { Alert, Modal, StyleSheet, View } from "react-native";
+import { ActivityIndicator, Download, FileText, MoreHorizontal, Pencil, Share2, Trash2, X } from "./icons";
import { Pressable, Text, TextInput } from "./LocalizedText";
import {
MobileResourceCancelledError,
diff --git a/apps/mobile/src/components/MobileTemplatePicker.tsx b/apps/mobile/src/components/MobileTemplatePicker.tsx
index a4cb1eb1..3317e027 100644
--- a/apps/mobile/src/components/MobileTemplatePicker.tsx
+++ b/apps/mobile/src/components/MobileTemplatePicker.tsx
@@ -1,8 +1,8 @@
import { useQuery } from "@tanstack/react-query";
import type { createEdgeEverClient } from "@edgeever/client";
import { useMemo } from "react";
-import { ActivityIndicator, Modal, Pressable, ScrollView, View } from "react-native";
-import { FileText, LayoutTemplate, X } from "./icons";
+import { Modal, Pressable, ScrollView, View } from "react-native";
+import { ActivityIndicator, FileText, LayoutTemplate, X } from "./icons";
import { Text } from "./LocalizedText";
import {
getMobileBuiltInTemplates,
@@ -259,4 +259,3 @@ const TemplateRow = ({
</Pressable>
);
};
-
diff --git a/apps/mobile/src/components/MobileUpdateCard.tsx b/apps/mobile/src/components/MobileUpdateCard.tsx
index 1ff5173e..87c5be41 100644
--- a/apps/mobile/src/components/MobileUpdateCard.tsx
+++ b/apps/mobile/src/components/MobileUpdateCard.tsx
@@ -1,7 +1,7 @@
import Constants from "expo-constants";
import * as Updates from "expo-updates";
-import { ActivityIndicator, StyleSheet, View } from "react-native";
-import { RefreshCw } from "./icons";
+import { StyleSheet, View } from "react-native";
+import { ActivityIndicator, RefreshCw } from "./icons";
import { Pressable, Text } from "./LocalizedText";
import { useMobileLocale } from "../lib/mobile-locale";
import { useMobileUpdate } from "../lib/mobile-update";
diff --git a/apps/mobile/src/components/icons.tsx b/apps/mobile/src/components/icons.tsx
index 02096659..cf4a2a2b 100644
--- a/apps/mobile/src/components/icons.tsx
+++ b/apps/mobile/src/components/icons.tsx
@@ -1,10 +1,16 @@
import Feather from "@expo/vector-icons/Feather";
import type { ComponentProps } from "react";
+import { ActivityIndicator as NativeActivityIndicator, type ActivityIndicatorProps } from "react-native";
import { resolveMobileThemeColor, useMobileTheme } from "../lib/mobile-theme";
type FeatherName = ComponentProps<typeof Feather>["name"];
type IconProps = Omit<ComponentProps<typeof Feather>, "name">;
+export const ActivityIndicator = ({ color, ...props }: ActivityIndicatorProps) => {
+ const { resolvedTheme } = useMobileTheme();
+ return <NativeActivityIndicator {...props} color={resolveMobileThemeColor(color as string | undefined, resolvedTheme)} />;
+};
+
const createIcon = (name: FeatherName) => {
const Icon = ({ color, ...props }: IconProps) => {
const { resolvedTheme } = useMobileTheme();
diff --git a/apps/mobile/src/lib/mobile-theme-colors.test.ts b/apps/mobile/src/lib/mobile-theme-colors.test.ts
new file mode 100644
index 00000000..882edc55
--- /dev/null
+++ b/apps/mobile/src/lib/mobile-theme-colors.test.ts
@@ -0,0 +1,24 @@
+import { describe, expect, test } from "bun:test";
+import { resolveMobileThemeColor, resolveMobileThemeStyles } from "./mobile-theme-colors";
+
+describe("mobile dark theme colors", () => {
+ test("maps neutral and semantic foreground colors", () => {
+ expect(resolveMobileThemeColor("#0f172a", "dark")).toBe("#f8fafc");
+ expect(resolveMobileThemeColor("#92400E", "dark")).toBe("#fde68a");
+ expect(resolveMobileThemeColor("#1d4ed8", "dark")).toBe("#93c5fd");
+ });
+
+ test("maps warning and informational surfaces and borders", () => {
+ expect(resolveMobileThemeColor("#fef3c7", "dark", "background")).toBe("#78350f");
+ expect(resolveMobileThemeColor("#eff6ff", "dark", "background")).toBe("#172554");
+ expect(resolveMobileThemeColor("#bfdbfe", "dark", "border")).toBe("#1e3a8a");
+ });
+
+ test("resolves StyleSheet-shaped records without changing light mode", () => {
+ const styles = { card: { backgroundColor: "#ffffff", borderColor: "#e2e8f0", color: "#0f172a" } };
+ expect(resolveMobileThemeStyles(styles, "light")).toBe(styles);
+ expect(resolveMobileThemeStyles(styles, "dark")).toEqual({
+ card: { backgroundColor: "#0f172a", borderColor: "#334155", color: "#f8fafc" },
+ });
+ });
+});
diff --git a/apps/mobile/src/lib/mobile-theme-colors.ts b/apps/mobile/src/lib/mobile-theme-colors.ts
new file mode 100644
index 00000000..7b0cae67
--- /dev/null
+++ b/apps/mobile/src/lib/mobile-theme-colors.ts
@@ -0,0 +1,110 @@
+export type MobileResolvedTheme = "light" | "dark";
+export type MobileThemeColorUsage = "foreground" | "background" | "border";
+
+const foregroundDarkMap: Record<string, string> = {
+ "#020617": "#f8fafc",
+ "#0f172a": "#f8fafc",
+ "#1e293b": "#f1f5f9",
+ "#17211a": "#f8fafc",
+ "#334155": "#e2e8f0",
+ "#475569": "#e2e8f0",
+ "#64748b": "#cbd5e1",
+ "#94a3b8": "#94a3b8",
+ "#047857": "#6ee7b7",
+ "#059669": "#6ee7b7",
+ "#10b981": "#34d399",
+ "#15803d": "#86efac",
+ "#0f766e": "#5eead4",
+ "#134e4a": "#99f6e4",
+ "#92400e": "#fde68a",
+ "#78350f": "#fde68a",
+ "#c2410c": "#fdba74",
+ "#1d4ed8": "#93c5fd",
+ "#1e3a8a": "#bfdbfe",
+ "#991b1b": "#fca5a5",
+ "#dc2626": "#fca5a5",
+ "#b91c1c": "#fca5a5",
+ "#be123c": "#fda4af",
+ "#e11d48": "#fb7185",
+};
+
+const backgroundDarkMap: Record<string, string> = {
+ "#ffffff": "#0f172a",
+ "#f8fafc": "#020617",
+ "#f7faf7": "#020617",
+ "#f1f5f9": "#1e293b",
+ "#ecfdf5": "#064e3b",
+ "#ecfdf3": "#064e3b",
+ "#d1fae5": "#065f46",
+ "#f0fdf4": "#052e16",
+ "#fef2f2": "#450a0a",
+ "#fff1f2": "#4c0519",
+ "#fffbeb": "#451a03",
+ "#fef3c7": "#78350f",
+ "#fff7ed": "#431407",
+ "#eff6ff": "#172554",
+ "#ccfbf1": "#134e4a",
+ "#f3f4f6": "#1f2937",
+ "#f0f0f0": "#1e293b",
+ "#f8f8f8": "#0f172a",
+};
+
+const borderDarkMap: Record<string, string> = {
+ "#f1f5f9": "#1e293b",
+ "#e2e8f0": "#334155",
+ "#cbd5e1": "#475569",
+ "#a7f3d0": "#047857",
+ "#fecaca": "#7f1d1d",
+ "#fda4af": "#9f1239",
+ "#dce7dd": "#334155",
+ "#cad8cc": "#475569",
+ "#bbf7d0": "#047857",
+ "#fde68a": "#92400e",
+ "#bfdbfe": "#1e3a8a",
+ "#fecdd3": "#9f1239",
+};
+
+const palettes: Record<MobileThemeColorUsage, Record<string, string>> = {
+ foreground: foregroundDarkMap,
+ background: backgroundDarkMap,
+ border: borderDarkMap,
+};
+
+export const resolveMobileThemeColor = (
+ value: string | undefined,
+ theme: MobileResolvedTheme,
+ usage: MobileThemeColorUsage = "foreground"
+) => {
+ if (theme !== "dark" || typeof value !== "string") {
+ return value;
+ }
+ return palettes[usage][value.toLowerCase()] ?? value;
+};
+
+export const resolveMobileThemeStyles = <T extends Record<string, unknown>>(styleSheet: T, theme: MobileResolvedTheme): T => {
+ if (theme === "light") {
+ return styleSheet;
+ }
+ return Object.fromEntries(
+ Object.entries(styleSheet).map(([styleName, styleValue]) => {
+ if (!styleValue || typeof styleValue !== "object") {
+ return [styleName, styleValue];
+ }
+ const resolvedStyle = Object.fromEntries(
+ Object.entries(styleValue).map(([property, value]) => {
+ if (property === "color" || property === "tintColor") {
+ return [property, typeof value === "string" ? resolveMobileThemeColor(value, theme, "foreground") : value];
+ }
+ if (property === "backgroundColor") {
+ return [property, typeof value === "string" ? resolveMobileThemeColor(value, theme, "background") : value];
+ }
+ if (property.startsWith("border") && property.endsWith("Color")) {
+ return [property, typeof value === "string" ? resolveMobileThemeColor(value, theme, "border") : value];
+ }
+ return [property, value];
+ })
+ );
+ return [styleName, resolvedStyle];
+ })
+ ) as T;
+};
diff --git a/apps/mobile/src/lib/mobile-theme.tsx b/apps/mobile/src/lib/mobile-theme.tsx
index f3f45d55..42febaaf 100644
--- a/apps/mobile/src/lib/mobile-theme.tsx
+++ b/apps/mobile/src/lib/mobile-theme.tsx
@@ -1,8 +1,11 @@
import { createContext, useContext, useEffect, useMemo, useState, type ReactNode } from "react";
import { useColorScheme } from "react-native";
import { readMobileThemePreference, writeMobileThemePreference, type MobileThemePreference } from "./preferences";
-
-export type MobileResolvedTheme = "light" | "dark";
+import {
+ resolveMobileThemeStyles,
+ type MobileResolvedTheme,
+} from "./mobile-theme-colors";
+export { resolveMobileThemeColor, resolveMobileThemeStyles, type MobileResolvedTheme } from "./mobile-theme-colors";
type MobileThemeContextValue = {
preference: MobileThemePreference;
@@ -13,89 +16,6 @@ type MobileThemeContextValue = {
const MobileThemeContext = createContext<MobileThemeContextValue | null>(null);
-const foregroundDarkMap: Record<string, string> = {
- "#020617": "#f8fafc",
- "#0f172a": "#f8fafc",
- "#1e293b": "#f1f5f9",
- "#17211a": "#f8fafc",
- "#334155": "#e2e8f0",
- "#475569": "#e2e8f0",
- "#64748b": "#cbd5e1",
- "#94a3b8": "#94a3b8",
- "#047857": "#6ee7b7",
- "#059669": "#6ee7b7",
- "#10b981": "#34d399",
- "#15803d": "#86efac",
- "#b91c1c": "#fca5a5",
- "#be123c": "#fda4af",
- "#e11d48": "#fb7185",
-};
-
-const backgroundDarkMap: Record<string, string> = {
- "#ffffff": "#0f172a",
- "#f8fafc": "#020617",
- "#f7faf7": "#020617",
- "#f1f5f9": "#1e293b",
- "#ecfdf5": "#064e3b",
- "#ecfdf3": "#064e3b",
- "#d1fae5": "#065f46",
- "#f0fdf4": "#052e16",
- "#fef2f2": "#450a0a",
- "#fff1f2": "#4c0519",
- "#fffbeb": "#451a03",
-};
-
-const borderDarkMap: Record<string, string> = {
- "#f1f5f9": "#1e293b",
- "#e2e8f0": "#334155",
- "#cbd5e1": "#475569",
- "#a7f3d0": "#047857",
- "#fecaca": "#7f1d1d",
- "#fda4af": "#9f1239",
- "#dce7dd": "#334155",
- "#cad8cc": "#475569",
- "#bbf7d0": "#047857",
- "#fde68a": "#92400e",
-};
-
-const mapThemeColor = (value: unknown, theme: MobileResolvedTheme, palette: Record<string, string>) => {
- if (theme !== "dark" || typeof value !== "string") {
- return value;
- }
- return palette[value.toLowerCase()] ?? value;
-};
-
-export const resolveMobileThemeColor = (value: string | undefined, theme: MobileResolvedTheme, usage: "foreground" | "background" | "border" = "foreground") =>
- mapThemeColor(value, theme, usage === "background" ? backgroundDarkMap : usage === "border" ? borderDarkMap : foregroundDarkMap) as string | undefined;
-
-export const resolveMobileThemeStyles = <T extends Record<string, unknown>>(styleSheet: T, theme: MobileResolvedTheme): T => {
- if (theme === "light") {
- return styleSheet;
- }
- return Object.fromEntries(
- Object.entries(styleSheet).map(([styleName, styleValue]) => {
- if (!styleValue || typeof styleValue !== "object") {
- return [styleName, styleValue];
- }
- const resolvedStyle = Object.fromEntries(
- Object.entries(styleValue).map(([property, value]) => {
- if (property === "color" || property === "tintColor") {
- return [property, mapThemeColor(value, theme, foregroundDarkMap)];
- }
- if (property === "backgroundColor") {
- return [property, mapThemeColor(value, theme, backgroundDarkMap)];
- }
- if (property.startsWith("border") && property.endsWith("Color")) {
- return [property, mapThemeColor(value, theme, borderDarkMap)];
- }
- return [property, value];
- })
- );
- return [styleName, resolvedStyle];
- })
- ) as T;
-};
-
export const MobileThemeProvider = ({ children }: { children: ReactNode }) => {
const systemTheme = useColorScheme();
const [preference, setPreferenceState] = useState<MobileThemePreference>("system");
diff --git a/apps/mobile/src/screens/LoginScreen.tsx b/apps/mobile/src/screens/LoginScreen.tsx
index c2b7053f..b362855b 100644
--- a/apps/mobile/src/screens/LoginScreen.tsx
+++ b/apps/mobile/src/screens/LoginScreen.tsx
@@ -1,6 +1,5 @@
import { useState } from "react";
import {
- ActivityIndicator,
KeyboardAvoidingView,
Linking,
Platform,
@@ -9,7 +8,7 @@ import {
View,
} from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
-import { ExternalLink, LockKeyhole } from "../components/icons";
+import { ActivityIndicator, ExternalLink, LockKeyhole } from "../components/icons";
import { Pressable, Text, TextInput } from "../components/LocalizedText";
import { resolveMobileThemeStyles, useMobileTheme, type MobileResolvedTheme } from "../lib/mobile-theme";
import { useSession } from "../lib/session";
diff --git a/apps/mobile/src/screens/WorkspaceMemoDetail.tsx b/apps/mobile/src/screens/WorkspaceMemoDetail.tsx
index 2dd5780b..afd28301 100644
--- a/apps/mobile/src/screens/WorkspaceMemoDetail.tsx
+++ b/apps/mobile/src/screens/WorkspaceMemoDetail.tsx
@@ -1,10 +1,10 @@
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { DEFAULT_MEMO_TITLE, resolveMemoContentDoc, type MemoDetail, type TiptapDoc } from "@edgeever/shared";
-import { ActivityIndicator, Image as RNImage, Platform, StyleSheet, View, type ImageStyle, type StyleProp } from "react-native";
+import { Image as RNImage, Platform, StyleSheet, View, type ImageStyle, type StyleProp } from "react-native";
import { Modal } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { SvgXml } from "react-native-svg";
-import { ChevronDown, ChevronLeft, ChevronRight, History, MoreHorizontal, Pencil, RotateCcw, Search, Share2, Tag, Trash2, X } from "../components/icons";
+import { ActivityIndicator, ChevronDown, ChevronLeft, ChevronRight, History, MoreHorizontal, Pencil, RotateCcw, Search, Share2, Tag, Trash2, X } from "../components/icons";
import { Alert, Pressable, Text, TextInput } from "../components/LocalizedText";
import LocalTiptapEditor, { type LocalTiptapEditorRef } from "../components/LocalTiptapEditor";
import { MobileResourceActions } from "../components/MobileResourceActions";
diff --git a/apps/mobile/src/screens/WorkspaceNotesView.tsx b/apps/mobile/src/screens/WorkspaceNotesView.tsx
index 21617966..3835ff09 100644
--- a/apps/mobile/src/screens/WorkspaceNotesView.tsx
+++ b/apps/mobile/src/screens/WorkspaceNotesView.tsx
@@ -2,9 +2,9 @@ import { memo, type ReactNode } from "react";
import type { MemoFilterMode } from "@edgeever/client";
import { DEFAULT_MEMO_TITLE, type MemoSummary, type Notebook } from "@edgeever/shared";
import { MOBILE_UI_METRICS, toggleMobileMemoFilterMode } from "@edgeever/shared/mobile-ui";
-import { ActivityIndicator, FlatList, Platform, RefreshControl, View } from "react-native";
+import { FlatList, Platform, RefreshControl, View } from "react-native";
import Animated, { FadeInDown, FadeOutUp, LinearTransition, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
-import { Check, ChevronDown, ChevronLeft, LayoutTemplate, MoreHorizontal, Plus, RotateCcw, Search, Sparkles, Tag, X } from "../components/icons";
+import { ActivityIndicator, Check, ChevronDown, ChevronLeft, LayoutTemplate, MoreHorizontal, Plus, RotateCcw, Search, Sparkles, Tag, X } from "../components/icons";
import { Pressable, Text, TextInput } from "../components/LocalizedText";
import type { MobileBootstrapProgress } from "../lib/local-mirror";
import { useMobileLocale } from "../lib/mobile-locale";
diff --git a/apps/mobile/src/screens/WorkspaceScreen.tsx b/apps/mobile/src/screens/WorkspaceScreen.tsx
index d2e3a18d..e3eacf65 100644
--- a/apps/mobile/src/screens/WorkspaceScreen.tsx
+++ b/apps/mobile/src/screens/WorkspaceScreen.tsx
@@ -5,6 +5,7 @@ import Constants from "expo-constants";
import { File as ExpoFile } from "expo-file-system";
import type { MemoFilterMode, MemoSortMode } from "@edgeever/client";
import {
+ ActivityIndicator,
BookOpen,
Check,
ChevronDown,
@@ -40,7 +41,6 @@ import {
X,
} from "../components/icons";
import {
- ActivityIndicator,
BackHandler,
FlatList,
Image as RNImage,
diff --git a/apps/mobile/src/screens/WorkspaceSettingsView.tsx b/apps/mobile/src/screens/WorkspaceSettingsView.tsx
index 12059ae0..248e0445 100644
--- a/apps/mobile/src/screens/WorkspaceSettingsView.tsx
+++ b/apps/mobile/src/screens/WorkspaceSettingsView.tsx
@@ -2,8 +2,8 @@ import { useEffect, useRef, useState, type ComponentRef, type ReactNode } from "
import * as Clipboard from "expo-clipboard";
import Constants from "expo-constants";
import { buildGitHubFeedbackUrl, type AuthUser } from "@edgeever/shared";
-import { ActivityIndicator, BackHandler, Linking, Modal, Platform, ScrollView, Switch, View } from "react-native";
-import { Check, ChevronDown, ChevronLeft, ChevronRight, Copy, ExternalLink, Image as ImageIcon, Info, LogOut, MessageSquare, Moon, RefreshCw, ShieldCheck, SlidersHorizontal, Sun, UserRound } from "../components/icons";
+import { BackHandler, Linking, Modal, Platform, ScrollView, Switch, View } from "react-native";
+import { ActivityIndicator, Check, ChevronDown, ChevronLeft, ChevronRight, Copy, ExternalLink, Image as ImageIcon, Info, LogOut, MessageSquare, Moon, RefreshCw, ShieldCheck, SlidersHorizontal, Sun, UserRound } from "../components/icons";
import { Pressable, Text } from "../components/LocalizedText";
import { useMobileLocale } from "../lib/mobile-locale";
import { useMobileTheme } from "../lib/mobile-theme";
diff --git a/apps/web/src/components/EditorPane.tsx b/apps/web/src/components/EditorPane.tsx
index d5f3507b..46a04202 100644
--- a/apps/web/src/components/EditorPane.tsx
+++ b/apps/web/src/components/EditorPane.tsx
@@ -3510,7 +3510,7 @@ const RichEditorPane = ({
persistCurrentDraft(event.target.value, tagsText, getMobilePlainTextValue());
markDirty();
}}
- className="block w-full rounded-md border-0 bg-transparent text-2xl font-bold leading-tight text-slate-950 outline-none transition placeholder:text-slate-300 focus-visible:bg-slate-50 focus-visible:shadow-[inset_3px_0_0_var(--brand-green)] sm:text-3xl"
+ className="block w-full rounded-md border-0 bg-transparent text-2xl font-bold leading-tight text-slate-950 outline-none transition placeholder:text-slate-300 focus-visible:bg-muted focus-visible:shadow-[inset_3px_0_0_var(--brand-green)] sm:text-3xl"
placeholder={t("common.untitledMemo")}
/>
<div className="flex flex-wrap items-center gap-2">
@@ -3725,6 +3725,7 @@ const RichEditorPane = ({
? {
"--editor-theme-bg": (resolvedTheme === "dark" ? customEditorTheme.dark : customEditorTheme.light).background,
"--editor-theme-text": (resolvedTheme === "dark" ? customEditorTheme.dark : customEditorTheme.light).text,
+ "--editor-theme-muted": (resolvedTheme === "dark" ? customEditorTheme.dark : customEditorTheme.light).muted,
"--editor-theme-heading": (resolvedTheme === "dark" ? customEditorTheme.dark : customEditorTheme.light).heading,
"--editor-theme-accent": (resolvedTheme === "dark" ? customEditorTheme.dark : customEditorTheme.light).accent,
"--editor-theme-soft": (resolvedTheme === "dark" ? customEditorTheme.dark : customEditorTheme.light).soft,
diff --git a/apps/web/src/components/NotebookPane.tsx b/apps/web/src/components/NotebookPane.tsx
index 90364b71..5cc3ff83 100644
--- a/apps/web/src/components/NotebookPane.tsx
+++ b/apps/web/src/components/NotebookPane.tsx
@@ -611,7 +611,7 @@ export const NotebookPane = ({
<span className="block truncate text-sm font-semibold leading-4">
{t("pwa.sidebarInstall") || "下载桌面客户端"}
</span>
- <span className="mt-1 block truncate whitespace-nowrap text-[11px] font-normal leading-4 text-slate-400">
+ <span className="mt-1 block truncate whitespace-nowrap text-[11px] font-normal leading-4 text-slate-500">
{t("pwa.sidebarInstallAvailability") || "Mac 可用 · Windows 敬请期待"}
</span>
</span>
diff --git a/apps/web/src/components/ThemeProvider.tsx b/apps/web/src/components/ThemeProvider.tsx
index 6dc52b79..e2794f5d 100644
--- a/apps/web/src/components/ThemeProvider.tsx
+++ b/apps/web/src/components/ThemeProvider.tsx
@@ -65,6 +65,7 @@ export type EditorThemeName = string;
export interface ThemeColors {
background: string;
text: string;
+ muted: string;
heading: string;
accent: string;
soft: string;
@@ -82,6 +83,7 @@ export interface CustomEditorTheme {
export const DEFAULT_CUSTOM_LIGHT_COLORS: ThemeColors = {
background: "#fffdf7",
text: "#292524",
+ muted: "#57534e",
heading: "#1c1917",
accent: "#0f766e",
soft: "#f0fdfa",
@@ -91,8 +93,9 @@ export const DEFAULT_CUSTOM_LIGHT_COLORS: ThemeColors = {
export const DEFAULT_CUSTOM_DARK_COLORS: ThemeColors = {
background: "#1c1917",
text: "#fafaf9",
+ muted: "#d6d3d1",
heading: "#fafaf9",
- accent: "#0d9488",
+ accent: "#2dd4bf",
soft: "#292524",
border: "#44403c",
};
@@ -173,6 +176,22 @@ export const getStoredEditorTheme = (): string => {
const isHexColor = (value: unknown): value is string => typeof value === "string" && /^#[0-9a-f]{6}$/i.test(value);
+const normalizeThemeColors = (value: Partial<ThemeColors> | undefined, fallback: ThemeColors): ThemeColors => ({
+ background: isHexColor(value?.background) ? value.background : fallback.background,
+ text: isHexColor(value?.text) ? value.text : fallback.text,
+ muted: isHexColor(value?.muted) ? value.muted : fallback.muted,
+ heading: isHexColor(value?.heading) ? value.heading : fallback.heading,
+ accent: isHexColor(value?.accent) ? value.accent : fallback.accent,
+ soft: isHexColor(value?.soft) ? value.soft : fallback.soft,
+ border: isHexColor(value?.border) ? value.border : fallback.border,
+});
+
+const normalizeCustomEditorTheme = (theme: CustomEditorTheme): CustomEditorTheme => ({
+ ...theme,
+ light: normalizeThemeColors(theme.light, DEFAULT_CUSTOM_LIGHT_COLORS),
+ dark: normalizeThemeColors(theme.dark, DEFAULT_CUSTOM_DARK_COLORS),
+});
+
export const getStoredCustomEditorThemes = (): CustomEditorTheme[] => {
if (typeof window === "undefined") return [DEFAULT_CUSTOM_EDITOR_THEME];
@@ -181,7 +200,7 @@ export const getStoredCustomEditorThemes = (): CustomEditorTheme[] => {
if (storedThemesStr) {
const parsed = JSON.parse(storedThemesStr) as CustomEditorTheme[];
if (Array.isArray(parsed) && parsed.length > 0) {
- return parsed;
+ return parsed.map(normalizeCustomEditorTheme);
}
}
} catch {
@@ -200,6 +219,7 @@ export const getStoredCustomEditorThemes = (): CustomEditorTheme[] => {
light: {
background: oldTheme.background || DEFAULT_CUSTOM_LIGHT_COLORS.background,
text: oldTheme.text || DEFAULT_CUSTOM_LIGHT_COLORS.text,
+ muted: oldTheme.muted || DEFAULT_CUSTOM_LIGHT_COLORS.muted,
heading: oldTheme.heading || DEFAULT_CUSTOM_LIGHT_COLORS.heading,
accent: oldTheme.accent || DEFAULT_CUSTOM_LIGHT_COLORS.accent,
soft: oldTheme.soft || DEFAULT_CUSTOM_LIGHT_COLORS.soft,
diff --git a/apps/web/src/components/settings/CustomEditorThemeDialog.tsx b/apps/web/src/components/settings/CustomEditorThemeDialog.tsx
index 53203c83..41a1c347 100644
--- a/apps/web/src/components/settings/CustomEditorThemeDialog.tsx
+++ b/apps/web/src/components/settings/CustomEditorThemeDialog.tsx
@@ -12,6 +12,7 @@ import {
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { sanitizeAndScopeCss } from "@/lib/css-sandbox";
+import { contrastRatio } from "@/lib/color-contrast";
import {
DEFAULT_CUSTOM_LIGHT_COLORS,
DEFAULT_CUSTOM_DARK_COLORS,
@@ -31,12 +32,19 @@ interface CustomEditorThemeDialogProps {
const COLOR_FIELDS = [
["background", "settings.customEditorTheme.background"],
["text", "settings.customEditorTheme.text"],
+ ["muted", "settings.customEditorTheme.muted"],
["heading", "settings.customEditorTheme.heading"],
["accent", "settings.customEditorTheme.accent"],
["soft", "settings.customEditorTheme.soft"],
["border", "settings.customEditorTheme.border"],
] as const;
+const hasAccessibleContrast = (colors: ThemeColors) =>
+ contrastRatio(colors.text, colors.background) >= 4.5 &&
+ contrastRatio(colors.muted, colors.soft) >= 4.5 &&
+ contrastRatio(colors.heading, colors.background) >= 4.5 &&
+ contrastRatio(colors.accent, colors.background) >= 3;
+
export const CustomEditorThemeDialog = ({
open,
theme,
@@ -77,7 +85,9 @@ export const CustomEditorThemeDialog = ({
const valid =
draft.name.trim().length > 0 &&
validColors(draft.light) &&
- validColors(draft.dark);
+ validColors(draft.dark) &&
+ hasAccessibleContrast(draft.light) &&
+ hasAccessibleContrast(draft.dark);
const handleReset = () => {
setDraft((current) => ({
@@ -158,6 +168,11 @@ export const CustomEditorThemeDialog = ({
</div>
))}
</div>
+ {!valid && validColors(draft.light) && validColors(draft.dark) ? (
+ <p className="rounded-md bg-amber-50 px-2.5 py-2 text-[11px] leading-4 text-amber-800">
+ {t("settings.customEditorTheme.contrastWarning")}
+ </p>
+ ) : null}
{/* Custom CSS Textarea */}
<label className="grid gap-1 text-xs font-semibold text-slate-700">
@@ -192,6 +207,9 @@ export const CustomEditorThemeDialog = ({
{t("settings.customEditorTheme.previewTitle")}
</div>
<p className="mb-0.5">{t("settings.customEditorTheme.previewBody")}</p>
+ <p className="mb-0.5" style={{ color: activeColors.muted }}>
+ {t("settings.customEditorTheme.previewMuted")}
+ </p>
<strong style={{ color: activeColors.accent }}>
{t("settings.customEditorTheme.previewAccent")}
</strong>
diff --git a/apps/web/src/lib/color-contrast.ts b/apps/web/src/lib/color-contrast.ts
new file mode 100644
index 00000000..3b687273
--- /dev/null
+++ b/apps/web/src/lib/color-contrast.ts
@@ -0,0 +1,20 @@
+const HEX_COLOR_PATTERN = /^#[0-9a-f]{6}$/i;
+
+export const isHexColor = (value: string) => HEX_COLOR_PATTERN.test(value);
+
+export const relativeLuminance = (hex: string) => {
+ if (!isHexColor(hex)) {
+ throw new Error(`Expected a six-digit hex color, received: ${hex}`);
+ }
+ const channels = [1, 3, 5].map((offset) => Number.parseInt(hex.slice(offset, offset + 2), 16) / 255);
+ return channels
+ .map((channel) => channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4)
+ .reduce((sum, channel, index) => sum + channel * [0.2126, 0.7152, 0.0722][index], 0);
+};
+
+export const contrastRatio = (foreground: string, background: string) => {
+ const foregroundLuminance = relativeLuminance(foreground);
+ const backgroundLuminance = relativeLuminance(background);
+ return (Math.max(foregroundLuminance, backgroundLuminance) + 0.05) /
+ (Math.min(foregroundLuminance, backgroundLuminance) + 0.05);
+};
diff --git a/apps/web/src/lib/dark-theme.test.mjs b/apps/web/src/lib/dark-theme.test.mjs
new file mode 100644
index 00000000..f572aa2a
--- /dev/null
+++ b/apps/web/src/lib/dark-theme.test.mjs
@@ -0,0 +1,23 @@
+import { describe, expect, test } from "bun:test";
+import { readFileSync } from "node:fs";
+import { contrastRatio } from "./color-contrast";
+import { DEFAULT_CUSTOM_DARK_COLORS, DEFAULT_CUSTOM_LIGHT_COLORS } from "../components/ThemeProvider";
+
+describe("dark theme contracts", () => {
+ test("default custom editor themes meet their contrast thresholds", () => {
+ for (const colors of [DEFAULT_CUSTOM_LIGHT_COLORS, DEFAULT_CUSTOM_DARK_COLORS]) {
+ expect(contrastRatio(colors.text, colors.background)).toBeGreaterThanOrEqual(4.5);
+ expect(contrastRatio(colors.muted, colors.soft)).toBeGreaterThanOrEqual(4.5);
+ expect(contrastRatio(colors.heading, colors.background)).toBeGreaterThanOrEqual(4.5);
+ expect(contrastRatio(colors.accent, colors.background)).toBeGreaterThanOrEqual(3);
+ }
+ });
+
+ test("public shares and divided surfaces have explicit dark rules", () => {
+ const css = readFileSync(new URL("../styles/globals.css", import.meta.url), "utf8");
+ expect(css).toContain(":root.dark .edgeever-public-share .ProseMirror");
+ expect(css).toContain("color: #f8fafc;");
+ expect(css).toContain('[class~="divide-slate-100"]');
+ expect(css).toContain('[class~="text-emerald-700"]');
+ });
+});
diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.css
index 4bab02b7..5973a14d 100644
--- a/apps/web/src/styles/globals.css
+++ b/apps/web/src/styles/globals.css
@@ -268,7 +268,17 @@ textarea {
}
:root.dark .edgeever-public-share .ProseMirror {
- color: #0f172a;
+ color: #f8fafc;
+}
+
+:root.dark .edgeever-public-share .ProseMirror [data-edgeever-theme-block] {
+ border-color: #334155;
+ background: #1e293b;
+}
+
+:root.dark .edgeever-public-share .ProseMirror [data-theme-block-kind="chapter"] {
+ border-left-color: var(--brand-green);
+ background: var(--brand-green-soft);
}
@media (min-width: 640px) {
@@ -1096,15 +1106,15 @@ textarea {
}
:root.dark [class~="bg-slate-50"],
-:root.dark [class*="bg-slate-50/"] { background-color: rgb(var(--slate-50-rgb)) !important; }
+:root.dark [class*="bg-slate-50/"] { background-color: rgb(var(--slate-50-rgb) / var(--dark-utility-alpha, 1)) !important; }
:root.dark [class~="bg-slate-100"],
-:root.dark [class*="bg-slate-100/"] { background-color: rgb(var(--slate-100-rgb)) !important; }
+:root.dark [class*="bg-slate-100/"] { background-color: rgb(var(--slate-100-rgb) / var(--dark-utility-alpha, 1)) !important; }
:root.dark [class~="bg-slate-200"],
-:root.dark [class*="bg-slate-200/"] { background-color: rgb(var(--slate-200-rgb)) !important; }
+:root.dark [class*="bg-slate-200/"] { background-color: rgb(var(--slate-200-rgb) / var(--dark-utility-alpha, 1)) !important; }
:root.dark [class~="bg-slate-300"],
-:root.dark [class*="bg-slate-300/"] { background-color: rgb(var(--slate-300-rgb)) !important; }
+:root.dark [class*="bg-slate-300/"] { background-color: rgb(var(--slate-300-rgb) / var(--dark-utility-alpha, 1)) !important; }
:root.dark [class~="bg-slate-400"],
-:root.dark [class*="bg-slate-400/"] { background-color: rgb(var(--slate-400-rgb)) !important; }
+:root.dark [class*="bg-slate-400/"] { background-color: rgb(var(--slate-400-rgb) / var(--dark-utility-alpha, 1)) !important; }
:root.dark [class~="bg-slate-500"],
:root.dark [class*="bg-slate-500/"] { background-color: rgb(var(--slate-500-rgb)) !important; }
:root.dark [class~="bg-slate-600"],
@@ -1116,25 +1126,28 @@ textarea {
:root.dark [class~="bg-slate-900"],
:root.dark [class*="bg-slate-900/"] { background-color: rgb(var(--slate-900-rgb)) !important; }
-:root.dark [class~="text-slate-50"] { color: rgb(var(--slate-50-rgb)) !important; }
-:root.dark [class~="text-slate-100"] { color: rgb(var(--slate-100-rgb)) !important; }
-:root.dark [class~="text-slate-200"] { color: rgb(var(--slate-200-rgb)) !important; }
-:root.dark [class~="text-slate-300"] { color: rgb(var(--slate-300-rgb)) !important; }
-:root.dark [class~="text-slate-400"] { color: rgb(var(--slate-400-rgb)) !important; }
-:root.dark [class~="text-slate-500"] { color: rgb(var(--slate-500-rgb)) !important; }
-:root.dark [class~="text-slate-600"] { color: rgb(var(--slate-600-rgb)) !important; }
-:root.dark [class~="text-slate-700"] { color: rgb(var(--slate-700-rgb)) !important; }
-:root.dark [class~="text-slate-800"] { color: rgb(var(--slate-800-rgb)) !important; }
-:root.dark [class~="text-slate-900"] { color: rgb(var(--slate-900-rgb)) !important; }
+:root.dark [class~="text-slate-50"] { color: #f8fafc !important; }
+:root.dark [class~="text-slate-100"] { color: #f1f5f9 !important; }
+:root.dark [class~="text-slate-200"] { color: #e2e8f0 !important; }
+:root.dark [class~="text-slate-300"] { color: #cbd5e1 !important; }
+:root.dark [class~="text-slate-350"] { color: #aebdce !important; }
+:root.dark [class~="text-slate-400"],
+:root.dark [class*="text-slate-400/"] { color: rgb(148 163 184 / var(--dark-utility-alpha, 1)) !important; }
+:root.dark [class~="text-slate-500"] { color: #cbd5e1 !important; }
+:root.dark [class~="text-slate-600"],
+:root.dark [class~="text-slate-650"] { color: #e2e8f0 !important; }
+:root.dark [class~="text-slate-700"] { color: #e2e8f0 !important; }
+:root.dark [class~="text-slate-800"] { color: #f1f5f9 !important; }
+:root.dark [class~="text-slate-900"] { color: #f8fafc !important; }
:root.dark [class~="border-slate-50"],
:root.dark [class*="border-slate-50/"] { border-color: rgb(var(--slate-50-rgb)) !important; }
:root.dark [class~="border-slate-100"],
-:root.dark [class*="border-slate-100/"] { border-color: rgb(var(--slate-100-rgb)) !important; }
+:root.dark [class*="border-slate-100/"] { border-color: rgb(var(--slate-100-rgb) / var(--dark-utility-alpha, 1)) !important; }
:root.dark [class~="border-slate-200"],
-:root.dark [class*="border-slate-200/"] { border-color: rgb(var(--slate-200-rgb)) !important; }
+:root.dark [class*="border-slate-200/"] { border-color: rgb(var(--slate-200-rgb) / var(--dark-utility-alpha, 1)) !important; }
:root.dark [class~="border-slate-300"],
-:root.dark [class*="border-slate-300/"] { border-color: rgb(var(--slate-300-rgb)) !important; }
+:root.dark [class*="border-slate-300/"] { border-color: rgb(var(--slate-300-rgb) / var(--dark-utility-alpha, 1)) !important; }
:root.dark [class~="border-slate-400"],
:root.dark [class*="border-slate-400/"] { border-color: rgb(var(--slate-400-rgb)) !important; }
@@ -1144,6 +1157,94 @@ textarea {
:root.dark [class*="hover:text-slate-900"]:hover,
:root.dark [class*="focus:text-slate-900"]:focus { color: rgb(var(--slate-900-rgb)) !important; }
+/* Preserve slash opacity while remapping legacy light palette utilities. */
+:root.dark [class*="/20"] { --dark-utility-alpha: 0.2; }
+:root.dark [class*="/25"] { --dark-utility-alpha: 0.25; }
+:root.dark [class*="/30"] { --dark-utility-alpha: 0.3; }
+:root.dark [class*="/35"] { --dark-utility-alpha: 0.35; }
+:root.dark [class*="/40"] { --dark-utility-alpha: 0.4; }
+:root.dark [class*="/45"] { --dark-utility-alpha: 0.45; }
+:root.dark [class*="/50"] { --dark-utility-alpha: 0.5; }
+:root.dark [class*="/60"] { --dark-utility-alpha: 0.6; }
+:root.dark [class*="/70"] { --dark-utility-alpha: 0.7; }
+:root.dark [class*="/80"] { --dark-utility-alpha: 0.8; }
+:root.dark [class*="/85"] { --dark-utility-alpha: 0.85; }
+:root.dark [class*="/90"] { --dark-utility-alpha: 0.9; }
+:root.dark [class*="/95"] { --dark-utility-alpha: 0.95; }
+:root.dark [class~="bg-slate-50/20"] { --dark-utility-alpha: 0.2; }
+:root.dark [class~="bg-slate-50/30"] { --dark-utility-alpha: 0.3; }
+:root.dark [class~="bg-slate-50/50"],
+:root.dark [class~="bg-slate-100/50"],
+:root.dark [class~="bg-slate-200/50"],
+:root.dark [class~="border-slate-200/50"] { --dark-utility-alpha: 0.5; }
+:root.dark [class~="bg-slate-50/60"],
+:root.dark [class~="border-slate-200/60"] { --dark-utility-alpha: 0.6; }
+:root.dark [class~="bg-slate-100/70"],
+:root.dark [class~="bg-slate-300/70"],
+:root.dark [class~="border-slate-300/70"] { --dark-utility-alpha: 0.7; }
+:root.dark [class~="bg-slate-50/80"],
+:root.dark [class~="bg-slate-200/80"],
+:root.dark [class~="bg-slate-400/80"],
+:root.dark [class~="border-slate-100/80"],
+:root.dark [class~="border-slate-200/80"] { --dark-utility-alpha: 0.8; }
+:root.dark [class~="bg-slate-50/90"],
+:root.dark [class~="text-slate-400/90"] { --dark-utility-alpha: 0.9; }
+
+:root.dark [class~="divide-slate-100"] > :not([hidden]) ~ :not([hidden]) {
+ border-color: rgb(var(--slate-100-rgb)) !important;
+}
+:root.dark [class~="divide-slate-100/50"] > :not([hidden]) ~ :not([hidden]) {
+ border-color: rgb(var(--slate-100-rgb) / 0.5) !important;
+}
+:root.dark [class~="divide-slate-200"] > :not([hidden]) ~ :not([hidden]) {
+ border-color: rgb(var(--slate-200-rgb)) !important;
+}
+:root.dark [class~="divide-slate-200/80"] > :not([hidden]) ~ :not([hidden]) {
+ border-color: rgb(var(--slate-200-rgb) / 0.8) !important;
+}
+
+/* Semantic status colors need their own dark palette; numeric inversion is not meaningful for them. */
+:root.dark [class~="text-emerald-500"],
+:root.dark [class~="text-emerald-600"],
+:root.dark [class~="text-emerald-650"],
+:root.dark [class~="text-emerald-700"] { color: #6ee7b7 !important; }
+:root.dark [class~="text-emerald-800"],
+:root.dark [class~="text-emerald-900"],
+:root.dark [class~="text-emerald-950"] { color: #a7f3d0 !important; }
+:root.dark [class~="bg-emerald-50"],
+:root.dark [class*="bg-emerald-50/"] { background-color: rgb(6 78 59 / var(--dark-utility-alpha, 1)) !important; }
+:root.dark [class~="bg-emerald-100"],
+:root.dark [class*="bg-emerald-100/"] { background-color: rgb(6 95 70 / var(--dark-utility-alpha, 1)) !important; }
+:root.dark [class~="border-emerald-100"],
+:root.dark [class~="border-emerald-200"],
+:root.dark [class*="border-emerald-200/"] { border-color: #047857 !important; }
+
+:root.dark [class~="text-amber-600"],
+:root.dark [class~="text-amber-700"],
+:root.dark [class~="text-amber-800"],
+:root.dark [class~="text-amber-900"],
+:root.dark [class~="text-amber-950"] { color: #fde68a !important; }
+:root.dark [class~="bg-amber-50"],
+:root.dark [class*="bg-amber-50/"] { background-color: rgb(69 26 3 / var(--dark-utility-alpha, 1)) !important; }
+:root.dark [class~="border-amber-100"],
+:root.dark [class~="border-amber-200"],
+:root.dark [class*="border-amber-200/"] { border-color: #92400e !important; }
+
+:root.dark [class~="text-rose-500"],
+:root.dark [class~="text-rose-600"],
+:root.dark [class~="text-rose-700"],
+:root.dark [class~="text-rose-800"],
+:root.dark [class~="text-rose-950"] { color: #fda4af !important; }
+:root.dark [class~="bg-rose-50"],
+:root.dark [class*="bg-rose-50/"] { background-color: rgb(76 5 25 / var(--dark-utility-alpha, 1)) !important; }
+:root.dark [class~="border-rose-100"],
+:root.dark [class~="border-rose-200"] { border-color: #9f1239 !important; }
+:root.dark [class~="text-blue-600"] { color: #93c5fd !important; }
+
+:root.dark * {
+ --tw-ring-offset-color: #0f172a;
+}
+
:root.dark [class~="bg-amber-50/60"] {
background-color: rgb(69 26 3 / 72%) !important;
}
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 225fa7d4..af5dc94f 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -200,13 +200,16 @@ export const enUS = {
name: "Theme name",
background: "Background",
text: "Body text",
+ muted: "Muted text",
heading: "Headings",
accent: "Accent",
soft: "Soft background",
border: "Border",
previewTitle: "Theme preview",
previewBody: "This is a body text preview to help you evaluate the color combination.",
+ previewMuted: "Muted supporting text should remain clear on the soft background.",
previewAccent: "Accent text",
+ contrastWarning: "Body, muted, heading, or accent colors need more contrast before saving.",
},
mermaidThemes: {
"zinc-light": "Zinc Light",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 2224af1e..7e3212e8 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -200,13 +200,16 @@ export const zhCN = {
name: "主题名称",
background: "背景色",
text: "正文色",
+ muted: "辅助文字色",
heading: "标题色",
accent: "强调色",
soft: "柔和背景",
border: "边框色",
previewTitle: "主题预览",
previewBody: "这是一段正文预览,用来感受背景、文字和边框的组合效果。",
+ previewMuted: "辅助说明文字需要在柔和背景上保持清晰。",
previewAccent: "强调文字",
+ contrastWarning: "正文、辅助文字、标题或强调色的对比度不足,请调整后保存。",
},
mermaidThemes: {
"zinc-light": "Zinc 浅色",
diff --git a/tests/e2e/dark-mode.spec.ts b/tests/e2e/dark-mode.spec.ts
new file mode 100644
index 00000000..c4717021
--- /dev/null
+++ b/tests/e2e/dark-mode.spec.ts
@@ -0,0 +1,114 @@
+import { expect, test, type Page } from "@playwright/test";
+
+const installDarkTheme = (page: Page) => page.addInitScript(() => {
+ localStorage.setItem("edgeever.theme", "dark");
+ localStorage.setItem("edgeever.editor-theme", "custom-default");
+ localStorage.setItem("edgeever.custom-editor-themes", JSON.stringify([{
+ id: "custom-default",
+ name: "Dark mode audit",
+ light: {
+ background: "#fffdf7", text: "#292524", muted: "#57534e", heading: "#1c1917",
+ accent: "#0f766e", soft: "#f0fdfa", border: "#99f6e4",
+ },
+ dark: {
+ background: "#1c1917", text: "#fafaf9", muted: "#d6d3d1", heading: "#fafaf9",
+ accent: "#2dd4bf", soft: "#292524", border: "#44403c",
+ },
+ }]));
+});
+
+const auditVisibleTextContrast = (page: Page) => page.evaluate(() => {
+ const parseColor = (color: string) => {
+ const match = color.match(/rgba?\((\d+)[, ]+\s*(\d+)[, ]+\s*(\d+)(?:[, /]+\s*([\d.]+))?/);
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3]), match[4] == null ? 1 : Number(match[4])] : null;
+ };
+ const composite = (foreground: number[], background: number[]) => {
+ const alpha = foreground[3] + background[3] * (1 - foreground[3]);
+ return [0, 1, 2].map((index) => (
+ (foreground[index] * foreground[3] + background[index] * background[3] * (1 - foreground[3])) / alpha
+ )).concat(alpha);
+ };
+ const effectiveBackground = (element: Element) => {
+ const layers: number[][] = [];
+ for (let current: Element | null = element; current; current = current.parentElement) {
+ const color = parseColor(getComputedStyle(current).backgroundColor);
+ if (color && color[3] > 0) layers.push(color);
+ }
+ return layers.reduceRight((background, layer) => composite(layer, background), [15, 23, 42, 1]);
+ };
+ const luminance = (color: number[]) => color.slice(0, 3)
+ .map((channel) => channel / 255)
+ .map((channel) => channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4)
+ .reduce((sum, channel, index) => sum + channel * [0.2126, 0.7152, 0.0722][index], 0);
+ const ratio = (foreground: number[], background: number[]) => {
+ const foregroundLuminance = luminance(foreground);
+ const backgroundLuminance = luminance(background);
+ return (Math.max(foregroundLuminance, backgroundLuminance) + 0.05) /
+ (Math.min(foregroundLuminance, backgroundLuminance) + 0.05);
+ };
+
+ return [...document.querySelectorAll("body *")]
+ .filter((element) => {
+ const bounds = element.getBoundingClientRect();
+ const style = getComputedStyle(element);
+ const hasDirectText = [...element.childNodes].some((node) => node.nodeType === Node.TEXT_NODE && node.textContent?.trim());
+ const hasFormValue = (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) && Boolean(element.value.trim());
+ return (hasDirectText || hasFormValue) && bounds.width > 0 && bounds.height > 0 && bounds.bottom > 0 && bounds.top < innerHeight &&
+ style.visibility !== "hidden" && Number(style.opacity) > 0.45;
+ })
+ .map((element) => {
+ const style = getComputedStyle(element);
+ const foreground = parseColor(style.color);
+ if (!foreground) return null;
+ const background = effectiveBackground(element);
+ const contrast = ratio(composite(foreground, background), background);
+ const fontSize = Number.parseFloat(style.fontSize);
+ const fontWeight = Number.parseInt(style.fontWeight, 10) || 400;
+ const required = fontSize >= 18 || (fontSize >= 14 && fontWeight >= 700) ? 3 : 4.5;
+ return contrast + 0.05 < required
+ ? `${element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement
+ ? element.value.trim().slice(0, 80)
+ : element.textContent?.trim().replace(/\s+/g, " ").slice(0, 80)} (${contrast.toFixed(2)}:1)`
+ : null;
+ })
+ .filter((failure): failure is string => Boolean(failure))
+ .slice(0, 20);
+});
+
+test.describe("dark mode visual contracts", () => {
+ test.beforeEach(async ({ page }) => {
+ await installDarkTheme(page);
+ });
+
+ test("workspace and settings retain readable text and dark surfaces", async ({ page }) => {
+ await page.goto("/");
+ await expect(page.locator("html")).toHaveClass(/dark/);
+ await expect(page.locator(".ProseMirror")).toBeVisible();
+ expect(await auditVisibleTextContrast(page)).toEqual([]);
+
+ const titleInput = page.getByPlaceholder("无标题笔记", { exact: true });
+ await titleInput.focus();
+ await expect(titleInput).toBeFocused();
+ expect(await auditVisibleTextContrast(page)).toEqual([]);
+
+ await page.getByRole("button", { name: "个人中心", exact: true }).click();
+ await expect(page.getByRole("heading", { name: "我的", exact: true })).toBeVisible();
+ expect(await auditVisibleTextContrast(page)).toEqual([]);
+ });
+
+ test("public share content remains readable in dark mode", async ({ page }) => {
+ const memoId = "memo_demo_overview";
+ const response = await page.request.post(`/api/v1/memos/${memoId}/share`);
+ expect(response.ok()).toBe(true);
+ const body = await response.json() as { share: { token: string } };
+
+ try {
+ await page.goto(`/share/${encodeURIComponent(body.share.token)}`);
+ await expect(page.locator("html")).toHaveClass(/dark/);
+ await expect(page.locator(".edgeever-public-share .ProseMirror")).toBeVisible();
+ expect(await auditVisibleTextContrast(page)).toEqual([]);
+ } finally {
+ await page.request.delete(`/api/v1/memos/${memoId}/share`);
+ }
+ });
+});