Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the theme-color value automatically when using a built-in theme #29795

Merged
merged 1 commit into from Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/helpers/application_helper.rb
Expand Up @@ -164,8 +164,11 @@
if theme == 'system'
concat stylesheet_pack_tag('mastodon-light', media: 'not all and (prefers-color-scheme: dark)', crossorigin: 'anonymous')
concat stylesheet_pack_tag('default', media: '(prefers-color-scheme: dark)', crossorigin: 'anonymous')
concat tag.meta name: 'theme-color', content: Themes::MASTODON_DARK_THEME_COLOR, media: '(prefers-color-scheme: dark)'
concat tag.meta name: 'theme-color', content: Themes::MASTODON_LIGHT_THEME_COLOR, media: '(prefers-color-scheme: light)'
else
stylesheet_pack_tag theme, media: 'all', crossorigin: 'anonymous'
concat stylesheet_pack_tag theme, media: 'all', crossorigin: 'anonymous'

Check warning on line 170 in app/helpers/application_helper.rb

View check run for this annotation

Codecov / codecov/patch

app/helpers/application_helper.rb#L170

Added line #L170 was not covered by tests
concat tag.meta name: 'theme-color', content: theme == 'mastodon-light' ? Themes::MASTODON_LIGHT_THEME_COLOR : Themes::MASTODON_DARK_THEME_COLOR
end
end

Expand Down
3 changes: 3 additions & 0 deletions app/lib/themes.rb
Expand Up @@ -6,6 +6,9 @@
class Themes
include Singleton

MASTODON_DARK_THEME_COLOR = '#191b22'
MASTODON_LIGHT_THEME_COLOR = '#f3f5f7'

def initialize
@conf = YAML.load_file(Rails.root.join('config', 'themes.yml'))
end
Expand Down
1 change: 0 additions & 1 deletion app/views/layouts/application.html.haml
Expand Up @@ -21,7 +21,6 @@

%link{ rel: 'mask-icon', href: frontend_asset_path('images/logo-symbol-icon.svg'), color: '#6364FF' }/
%link{ rel: 'manifest', href: manifest_path(format: :json) }/
%meta{ name: 'theme-color', content: '#191b22' }/
%meta{ name: 'apple-mobile-web-app-capable', content: 'yes' }/

%title= html_title
Expand Down