From 0e3ee19e3abd1cd8b0f676e31372b6cc477d6729 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 8 Jul 2020 17:26:53 -0500 Subject: [PATCH] Made Article View match system accent color --- Multiplatform/Shared/Article/styleSheet.css | 18 ++++++++---------- Shared/Article Rendering/ArticleRenderer.swift | 13 +++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Multiplatform/Shared/Article/styleSheet.css b/Multiplatform/Shared/Article/styleSheet.css index 98e09e971..96cd69d7f 100644 --- a/Multiplatform/Shared/Article/styleSheet.css +++ b/Multiplatform/Shared/Article/styleSheet.css @@ -13,29 +13,27 @@ body { color-scheme: light dark; font: -apple-system-body; font-size: [[font-size]]px; - --primary-accent-color: #086AEE; - --secondary-accent-color: #086AEE; - --block-quote-border-color: rgba(8, 106, 238, 0.75); + --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .75); + --block-quote-border-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .50); } @media(prefers-color-scheme: dark) { :root { - --primary-accent-color: #2D80F1; - --secondary-accent-color: #5E9EF4; - --block-quote-border-color: rgba(94, 158, 244, 0.75); + --accent-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .75); + --block-quote-border-color: rgba([[accent-r]], [[accent-g]], [[accent-b]], .50); --header-table-border-color: rgba(255, 255, 255, 0.2); } } body a, body a:link, body a:visited { - color: var(--secondary-accent-color); + color: var(--accent-color); } body .header { font: -apple-system-body; font-size: [[font-size]]px; } body .header a:link, body .header a:visited { - color: var(--primary-accent-color); + color: var(--accent-color); } .avatar img { @@ -43,12 +41,12 @@ body .header a:link, body .header a:visited { } pre { - border: 1px solid var(--secondary-accent-color); + border: 1px solid var(--accent-color); padding: 5px; } .nnw-overflow table { - border: 1px solid var(--secondary-accent-color); + border: 1px solid var(--accent-color); } .activityIndicatorWrap { diff --git a/Shared/Article Rendering/ArticleRenderer.swift b/Shared/Article Rendering/ArticleRenderer.swift index 2dba5f84d..39cf38b5d 100644 --- a/Shared/Article Rendering/ArticleRenderer.swift +++ b/Shared/Article Rendering/ArticleRenderer.swift @@ -253,11 +253,24 @@ private extension ArticleRenderer { var d = [String: String]() let bodyFont = UIFont.preferredFont(forTextStyle: .body) d["font-size"] = String(describing: bodyFont.pointSize) + + if let components = UIColor(named: "AccentColor")?.cgColor.components { + d["accent-r"] = String(Int(round(components[0] * 0xFF))) + d["accent-g"] = String(Int(round(components[1] * 0xFF))) + d["accent-b"] = String(Int(round(components[2] * 0xFF))) + } + return d } #else func styleSubstitutions() -> [String: String] { var d = [String: String]() + + if #available(macOS 10.16, *) { + let bodyFont = NSFont.preferredFont(forTextStyle: .body) + d["font-size"] = String(describing: Int(round(bodyFont.pointSize * 1.33))) + } + guard let linkColor = NSColor.controlAccentColor.usingColorSpace(.deviceRGB) else { return d }