Skip to content

Commit

Permalink
Consolidate html head partials to one partial
Browse files Browse the repository at this point in the history
Originally, we needed this as we didn't extract other views in the layout to partials. No need for specific partials now since chances are if someone wants to edit this, they will want to edit most of the HTML head anyway so easier to extract a single partial with everything already there as its not that many lines.

Since we've improved many of the layout helpers, we'll just inline the title tag now and not sanitize since this is commonly extracted, its much easier now for users to add that in if they want it. We added sanitized due to testing the site title with a link but we've since changed that so the site title really should just be plain text for situations like this. The link was used because often it doubled as the site title in the site header HTML but that is expected to be fully customized and branded now.
  • Loading branch information
javierjulio committed Dec 28, 2023
1 parent c718b4c commit ccba7c6
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<%= stylesheet_link_tag "active_admin" %>
<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 %>
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
} else {
Expand Down
3 changes: 0 additions & 3 deletions app/views/active_admin/html_head/_defaults.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions app/views/active_admin/html_head/_meta_tags.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/active_admin/html_head/_stylesheets.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/active_admin/html_head/_title.html.erb

This file was deleted.

4 changes: 2 additions & 2 deletions app/views/layouts/active_admin.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!doctype html>
<html lang="<%= I18n.locale %>">
<head>
<%= render "active_admin/html_head/title", title: html_head_site_title %>
<%= render "active_admin/html_head/defaults" %>
<title><%= html_head_site_title %></title>
<%= render "active_admin/html_head" %>
</head>
<body class="bg-white dark:bg-gray-950/95 text-gray-950 dark:text-gray-100 antialiased">
<%= render "active_admin/site_header", title: site_title %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/active_admin_logged_out.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!doctype html>
<html lang="<%= I18n.locale %>">
<head>
<%= render "active_admin/html_head/title", title: html_head_site_title %>
<%= render "active_admin/html_head/defaults" %>
<title><%= html_head_site_title %></title>
<%= render "active_admin/html_head" %>
</head>
<body class="bg-gray-50 dark:bg-gray-900 text-gray-950 dark:text-gray-100 antialiased">
<div class="flex flex-col items-center justify-center min-h-screen py-4 sm:px-6 sm:py-8 mx-auto">
Expand Down

0 comments on commit ccba7c6

Please sign in to comment.