Fix system theme being included twice (#37526)

This commit is contained in:
Claire 2026-01-16 16:55:16 +01:00 committed by GitHub
parent e21cb9f0d0
commit cc3c7ba532
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 19 deletions

View File

@ -18,14 +18,10 @@ module ThemeHelper
end
def theme_style_tags(theme)
if theme == 'system'
''.html_safe.tap do |tags|
tags << vite_stylesheet_tag('themes/mastodon-light', type: :virtual, media: 'not all and (prefers-color-scheme: dark)', crossorigin: 'anonymous')
tags << vite_stylesheet_tag('themes/default', type: :virtual, media: '(prefers-color-scheme: dark)', crossorigin: 'anonymous')
end
else
vite_stylesheet_tag "themes/#{theme}", type: :virtual, media: 'all', crossorigin: 'anonymous'
end
# TODO: get rid of that when we retire the themes and perform the settings migration
theme = 'default' if %w(mastodon-light contrast system).include?(theme)
vite_stylesheet_tag "themes/#{theme}", type: :virtual, media: 'all', crossorigin: 'anonymous'
end
def theme_color_tags(color_scheme)

View File

@ -9,17 +9,10 @@ RSpec.describe ThemeHelper do
context 'when using "system" theme' do
let(:theme) { 'system' }
it 'returns the mastodon-light and application stylesheets with correct color schemes' do
it 'returns the default theme' do
expect(html_links.first.attributes.symbolize_keys)
.to include(
# This is now identical to the default theme & will be unified very soon
href: have_attributes(value: match(/default/)),
media: have_attributes(value: 'not all and (prefers-color-scheme: dark)')
)
expect(html_links.last.attributes.symbolize_keys)
.to include(
href: have_attributes(value: match(/default/)),
media: have_attributes(value: '(prefers-color-scheme: dark)')
href: have_attributes(value: match(/default/))
)
end
end
@ -41,8 +34,7 @@ RSpec.describe ThemeHelper do
it 'returns the theme stylesheet without color scheme information' do
expect(html_links.first.attributes.symbolize_keys)
.to include(
href: have_attributes(value: match(/default/)),
media: have_attributes(value: 'all')
href: have_attributes(value: match(/default/))
)
end
end