8000 Move theme setup script into a partial by mgrunberg · Pull Request #8462 · activeadmin/activeadmin · GitHub
[go: up one dir, main page]

Skip to content

Move theme setup script into a partial #8462

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions app/views/active_admin/_html_head.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<% # On page load or when changing themes, best to add inline in `head` to avoid FOUC %>
<%= javascript_tag nonce: true do %>
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
<% end %>

<%= render 'active_admin/shared/theme_setup' %>
<%= javascript_importmap_tags "active_admin", importmap: ActiveAdmin.importmap %>
8 changes: 8 additions & 0 deletions app/views/active_admin/shared/_theme_setup.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% # On page load or when changing themes, best to add inline in `head` to avoid FOUC %>
<%= javascript_tag nonce: true do %>
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should theme be prefixed by activeAdmin or configurable?

I understand that in some circumstances it is better to use the same application theme, but changing the theme in the admin area should not affect the application and vice versa 🤔

/cc @javierjulio

document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
<% end %>
Loading
0