FEATURE: Add email dark mode (#16104)

implement dark mode emails when `SiteSetting.dark_mode_emails_active` is active.
This commit is contained in:
Isaac Janzen
2022-04-11 12:27:50 -05:00
committed by GitHub
parent a0ef25f4f0
commit 6c0abe15e0
9 changed files with 104 additions and 8 deletions

View File

@ -238,6 +238,7 @@ module Email
onebox_styles
plugin_styles
dark_mode_styles if SiteSetting.dark_mode_emails_active
style('.post-excerpt img', "max-width: 50%; max-height: #{MAX_IMAGE_DIMENSION}px;")
@ -333,6 +334,16 @@ module Email
private
def dark_mode_styles
# When we ship the email template and its styles we strip all css classes so to give our
# dark mode styles we are including in the template a selector we add a data-attr of 'dm=value' to
# the appropriate place
style(".digest-header, .digest-topic, .digest-topic-body, .digest-topic-title-wrapper, .digest-topic-stats, .popular-post-excerpt", nil, dm: "header")
style(".digest-content, .header-popular-posts, .spacer, .popular-post-spacer, .popular-post-meta, .digest-new-header, .digest-new-topic, .body", nil, dm: "body")
style(".with-accent-colors, .digest-content-header", nil, dm: "body_primary")
style(".summary-footer", nil, dm: "text-color")
end
def replace_relative_urls
forum_uri = URI(Discourse.base_url)
host = forum_uri.host