mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add email dark mode (#16104)
implement dark mode emails when `SiteSetting.dark_mode_emails_active` is active.
This commit is contained in:
@@ -29,11 +29,69 @@ module EmailHelper
|
||||
EmailStyle.new.html
|
||||
.sub('%{email_content}') { capture { yield } }
|
||||
.gsub('%{html_lang}', html_lang)
|
||||
.gsub('%{dark_mode_meta_tags}', SiteSetting.dark_mode_emails_active ? dark_mode_meta_tags : "")
|
||||
.gsub('%{dark_mode_styles}', SiteSetting.dark_mode_emails_active ? dark_mode_styles : "")
|
||||
.html_safe
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def dark_mode_meta_tags
|
||||
"
|
||||
<meta name='color-scheme' content='light dark' />
|
||||
<meta name='supported-color-schemes' content='light dark' />
|
||||
"
|
||||
end
|
||||
|
||||
def dark_mode_styles
|
||||
"
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
html {
|
||||
background: #151515 !important;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
p,
|
||||
span {
|
||||
color: #dddddd !important;
|
||||
}
|
||||
|
||||
[dm='light-img'] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
[dm='dark-img'] {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
[dm='text-color'] {
|
||||
color: #dddddd;
|
||||
}
|
||||
|
||||
[dm='header'] {
|
||||
background: #151515 !important;
|
||||
}
|
||||
|
||||
[dm='body'] {
|
||||
background: #222222 !important;
|
||||
color: #dddddd !important;
|
||||
}
|
||||
|
||||
[dm='body_primary'] {
|
||||
background: #062e3d !important;
|
||||
color: #dddddd !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
"
|
||||
end
|
||||
|
||||
def extract_details(topic)
|
||||
if SiteSetting.private_email?
|
||||
[topic.slugless_url, private_topic_title(topic)]
|
||||
|
||||
Reference in New Issue
Block a user