mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 10:57:04 +08:00
FEATURE: Enables support for dark mode emails (#16520)
This PR enables custom email dark mode styles by default that were added here.
There is currently poor support for dark mode queries in mail clients. The main beneficiary of these changes will be Apple Mail and Outlook.
Enjoy the darkness 🕶️
This commit is contained in:
parent
196b791365
commit
692e0140e2
|
@ -29,8 +29,8 @@ 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 : "")
|
||||
.gsub('%{dark_mode_meta_tags}', dark_mode_meta_tags)
|
||||
.gsub('%{dark_mode_styles}', dark_mode_styles)
|
||||
.html_safe
|
||||
end
|
||||
|
||||
|
|
|
@ -283,9 +283,6 @@ basic:
|
|||
type: enum
|
||||
enum: "ColorSchemeSetting"
|
||||
client: true
|
||||
dark_mode_emails_active:
|
||||
default: false
|
||||
hidden: true
|
||||
relative_date_duration:
|
||||
client: true
|
||||
default: 30
|
||||
|
|
|
@ -238,7 +238,7 @@ module Email
|
|||
|
||||
onebox_styles
|
||||
plugin_styles
|
||||
dark_mode_styles if SiteSetting.dark_mode_emails_active
|
||||
dark_mode_styles
|
||||
|
||||
style('.post-excerpt img', "max-width: 50%; max-height: #{MAX_IMAGE_DIMENSION}px;")
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ describe EmailStyle do
|
|||
SiteSetting.default_email_in_reply_to = true
|
||||
|
||||
expect(mail_html.scan('<h1 style="color: red;">FOR YOU</h1>').count).to eq(1)
|
||||
matches = mail_html.match(/<div style="([^"]+)">#{post.raw}/)
|
||||
matches = mail_html.match(/<div style="([^"]+)" dm=\"body\">#{post.raw}/)
|
||||
expect(matches[1]).to include('color: #FAB;') # custom
|
||||
expect(matches[1]).to include('padding-top:5px;') # div.body
|
||||
end
|
||||
|
|
|
@ -157,10 +157,6 @@ describe Email::Styles do
|
|||
end
|
||||
|
||||
context "dark mode emails" do
|
||||
before do
|
||||
SiteSetting.dark_mode_emails_active = true
|
||||
end
|
||||
|
||||
it "adds dark_mode_styles when site setting active" do
|
||||
frag = html_fragment('<div class="body">test</div>')
|
||||
styler = Email::Styles.new(frag)
|
||||
|
|
Loading…
Reference in New Issue
Block a user