refactor: Migration auf ManaWebShell + ManaTheme.paper aus mana-swift-* v1.6.0/v0.6.0

ManaWebShell aus mana-swift-ui v0.6.0 ersetzt den lokalen
`Sources/Features/WebShell/`-Ordner. WebShellCoordinator, WebShell-
View, WebShellScripts geloescht (~430 LOC). CookieBridge bleibt
lokal (App-spezifischer Cookie-SSO-Pfad fuer .mana.how), wandert
nach `Sources/Core/WebShell/CookieBridge.swift`.

`RootView.makeWebShellConfig()` baut Config mit Host-Whitelist
`zitare.com` + `www.zitare.com` + `*.mana.how`, ZitareTheme-Hints,
`syncDarkMode(localStorageKey: "zitare-mode")` und `hideElements`
fuer den zitare-web-Header.

ZitareTheme forwarded auf ManaTheme.paper aus mana-swift-core
v1.6.0 (~90 LOC weg, paper-Werte jetzt single-source in
`mana/packages/themes/src/variants/paper.css`).

AppConfig.userAgent als plattform-spezifischer Helper hinzu.

20/20 Unit-Tests gruen.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-05-17 21:13:16 +02:00
parent e139a382d8
commit 4b00c4ecdf
8 changed files with 72 additions and 534 deletions

View file

@ -1,105 +1,28 @@
import ManaTokens
import SwiftUI
#if canImport(UIKit)
import UIKit
private typealias PlatformColorType = UIColor
#elseif canImport(AppKit)
import AppKit
private typealias PlatformColorType = NSColor
#endif
/// Paper-Variant aus `mana/packages/themes/src/variants/paper.css`.
/// Lokal in zitare-native nachgebaut, weil ManaTokens noch keine
/// Variants kennt.
/// Zitare-Theme forwarded auf ``ManaTheme/paper`` aus
/// `mana-swift-core` v1.6.0 (dieselbe Variant wie zitare-web).
///
/// Sepia, warm, lese-fokussiert skeumorph an Druckpapier angelehnt,
/// passt zum (read)-Surface der Web-App.
/// Bis v1.5.x lebte hier ein ~90-LOC-HSL-Apparat als lokaler Nachbau
/// der `paper.css`-Variant. Mit v1.6.0 liefert ManaTokens alle acht
/// Web-Theme-Variants nativ `paper` ist eine davon.
///
/// `ZitareTheme` bleibt als dünner Alias bestehen, damit bestehende
/// Call-Sites nicht in einem Sprint umziehen müssen. Neue Call-Sites
/// bevorzugen direkt `ManaTheme.paper.<token>` (oder
/// `@Environment(\.manaTheme)`).
enum ZitareTheme {
/// Page-Hintergrund (warmes Off-White / dunkles Sepia)
static let background = dynamic(light: HSL(38, 28, 95), dark: HSL(24, 14, 9))
/// Standard-Text
static let foreground = dynamic(light: HSL(20, 14, 16), dark: HSL(38, 24, 88))
/// Card, Panel, Modal
static let surface = dynamic(light: HSL(0, 0, 100), dark: HSL(24, 12, 13))
/// Hover-State auf Surface
static let surfaceHover = dynamic(light: HSL(38, 24, 92), dark: HSL(24, 14, 17))
/// Disabled-Felder, Skeleton
static let muted = dynamic(light: HSL(38, 20, 90), dark: HSL(24, 12, 18))
/// Sekundär-Text, Placeholder
static let mutedForeground = dynamic(light: HSL(20, 14, 50), dark: HSL(38, 12, 60))
/// Rahmen, Trennlinien
static let border = dynamic(light: HSL(38, 18, 80), dark: HSL(24, 10, 25))
/// Zitare-Primary warmes Terra/Sienna im Light, weicheres Sienna im Dark
static let primary = dynamic(light: HSL(18, 50, 38), dark: HSL(24, 60, 65))
/// Text auf Primary
static let primaryForeground = dynamic(light: HSL(0, 0, 100), dark: HSL(24, 14, 9))
static let error = dynamic(light: HSL(0, 65, 45), dark: HSL(0, 60, 55))
static let success = dynamic(light: HSL(135, 35, 35), dark: HSL(135, 35, 55))
static let warning = dynamic(light: HSL(38, 80, 40), dark: HSL(38, 70, 55))
// MARK: - HSL Helper
struct HSL {
let hue: Double
let saturation: Double
let lightness: Double
init(_ hue: Double, _ saturation: Double, _ lightness: Double) {
self.hue = hue
self.saturation = saturation
self.lightness = lightness
}
var color: Color {
Color(
hue: hue / 360.0,
saturation: saturation / 100.0,
brightness: brightnessFromLightness(),
opacity: 1.0
)
}
/// HSL HSB Konversion (SwiftUI Color nutzt HSB).
private func brightnessFromLightness() -> Double {
let l = lightness / 100.0
let s = saturation / 100.0
return l + s * min(l, 1 - l)
}
}
private static func dynamic(light: HSL, dark: HSL) -> Color {
#if canImport(UIKit)
return Color(
PlatformColorType { trait in
trait.userInterfaceStyle == .dark
? PlatformColorType(dark.color)
: PlatformColorType(light.color)
}
)
#elseif canImport(AppKit)
return Color(
PlatformColorType(name: nil) { appearance in
let isDark = appearance.bestMatch(
from: [.darkAqua, .aqua]
) == .darkAqua
return isDark
? PlatformColorType(dark.color)
: PlatformColorType(light.color)
}
)
#else
return light.color
#endif
}
static let background = ManaTheme.paper.background
static let foreground = ManaTheme.paper.foreground
static let surface = ManaTheme.paper.surface
static let surfaceHover = ManaTheme.paper.surfaceHover
static let muted = ManaTheme.paper.muted
static let mutedForeground = ManaTheme.paper.mutedForeground
static let border = ManaTheme.paper.border
static let primary = ManaTheme.paper.primary
static let primaryForeground = ManaTheme.paper.primaryForeground
static let error = ManaTheme.paper.error
static let success = ManaTheme.paper.success
static let warning = ManaTheme.paper.warning
}