From 4587be645ac00cca9f68f165a606fd9bc669a3b8 Mon Sep 17 00:00:00 2001 From: mooff Date: Mon, 23 Aug 2021 20:26:18 +0100 Subject: [PATCH 1/2] ui: Simplify style rules for body.plain in the composer Setting these rules on `body.plain *` is not needed: they will cascade quite happily on their own, with easier maintenance and readability for humans Also applies to rules whose values are unchanged from those on `body` - better to keep these DRY --- ui/composer-web-view.css | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ui/composer-web-view.css b/ui/composer-web-view.css index 462d5876b..988097570 100644 --- a/ui/composer-web-view.css +++ b/ui/composer-web-view.css @@ -12,12 +12,8 @@ body { font-size: medium !important; } -body.plain, body.plain * { - font-family: monospace !important; - font-weight: normal; - font-style: normal; - font-size: medium !important; - color: black !important; +body.plain { + font-family: monospace; text-decoration: none; } -- GitLab From 4367960d44c11580f6f6b37fc7eab9bc3179eb27 Mon Sep 17 00:00:00 2001 From: mooff Date: Tue, 16 May 2023 05:14:19 +0100 Subject: [PATCH 2/2] Implement dark mode using color-scheme CSS property --- .../accounts/accounts-signature-web-view.vala | 5 +++++ ui/composer-web-view.css | 16 +++++++++++++--- ui/conversation-web-view.css | 7 ++++--- ui/org.gnome.Geary.gresource.xml | 1 + ui/signature-web-view.css | 5 +++++ 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 ui/signature-web-view.css diff --git a/src/client/accounts/accounts-signature-web-view.vala b/src/client/accounts/accounts-signature-web-view.vala index d424dd642..aa1c3ae8a 100644 --- a/src/client/accounts/accounts-signature-web-view.vala +++ b/src/client/accounts/accounts-signature-web-view.vala @@ -12,18 +12,23 @@ public class Accounts.SignatureWebView : Components.WebView { private static WebKit.UserScript? app_script = null; + private static WebKit.UserStyleSheet? app_stylesheet = null; public static new void load_resources() throws GLib.Error { SignatureWebView.app_script = Components.WebView.load_app_script( "signature-web-view.js" ); + SignatureWebView.app_stylesheet = Components.WebView.load_app_stylesheet( + "signature-web-view.css" + ); } public SignatureWebView(Application.Configuration config) { base(config); this.user_content_manager.add_script(SignatureWebView.app_script); + this.user_content_manager.add_style_sheet(SignatureWebView.app_stylesheet); } } diff --git a/ui/composer-web-view.css b/ui/composer-web-view.css index 988097570..6ea2caefe 100644 --- a/ui/composer-web-view.css +++ b/ui/composer-web-view.css @@ -3,12 +3,22 @@ * Copyright 2017 Michael Gratton */ +:root { + /* Adjust default controls and system colors for light and dark mode. + See https://www.w3.org/TR/css-color-adjust-1/#color-scheme-effect */ + color-scheme: light dark; + + /* Apply canvas background to the root element, so body can darken + it using alpha. */ + background-color: canvas; +} + body { + background-color: rgb(50% 50% 50% / .05); + margin: 0 !important; border: 0 !important; padding: 0 !important; - color: black; - background-color: #f9f9f9; font-size: medium !important; } @@ -40,7 +50,7 @@ body > div#geary-quote { } body > div:focus-within { - background-color: white; + background-color: canvas; } body > div#geary-signature:focus-within, diff --git a/ui/conversation-web-view.css b/ui/conversation-web-view.css index d1da2eae5..ed5bcdb99 100644 --- a/ui/conversation-web-view.css +++ b/ui/conversation-web-view.css @@ -13,9 +13,10 @@ transition: height 0.25s !important; } -html { - color: black; - background-color: white; +:root { + /* Adjust default controls and system colors for light and dark mode. + See https://www.w3.org/TR/css-color-adjust-1/#color-scheme-effect */ + color-scheme: light dark; /* Width must always be defined by the viewport so content doesn't overflow inside the WebView, height must always be defined by the diff --git a/ui/org.gnome.Geary.gresource.xml b/ui/org.gnome.Geary.gresource.xml index 3e314b92c..1f9ef0ca6 100644 --- a/ui/org.gnome.Geary.gresource.xml +++ b/ui/org.gnome.Geary.gresource.xml @@ -49,6 +49,7 @@ gtk/help-overlay.ui password-dialog.glade problem-details-dialog.ui + signature-web-view.css signature-web-view.js geary.css single-key-shortcuts.css diff --git a/ui/signature-web-view.css b/ui/signature-web-view.css new file mode 100644 index 000000000..538138875 --- /dev/null +++ b/ui/signature-web-view.css @@ -0,0 +1,5 @@ +:root { + /* Adjust default controls and system colors for light and dark mode. + See https://www.w3.org/TR/css-color-adjust-1/#color-scheme-effect */ + color-scheme: light dark; +} -- GitLab