ash_hq/lib/ash_hq_web/templates/layout/root.html.eex
2022-10-22 05:51:22 -06:00

47 lines
1.9 KiB
Elixir

<!DOCTYPE html>
<html lang="en" class="<%= "#{@configured_theme}" %>">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<%= csrf_meta_tag() %>
<%= live_title_tag assigns[:page_title] || "Ash Framework" %>
<%= if Application.get_env(:ash_hq, :analytics?) do %>
<script defer data-domain="ash-hq.org" src="https://plausible.io/js/plausible.js"></script>
<% end %>
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
<link phx-track-static rel="stylesheet" href="<%= Routes.static_path(@conn, "/assets/app.css") %>"/>
<script>
const configuredThemeRow = document.cookie
.split('; ')
.find(row => row.startsWith('theme='))
if (!configuredThemeRow || configuredThemeRow === "theme=system") {
let theme;
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
theme = "dark";
} else {
theme = "light";
}
document.documentElement.classList.add(theme);
if(theme === "dark") {
document.documentElement.classList.remove("light");
} else {
document.documentElement.classList.remove("dark");
};
document.cookie = 'theme=system;path=/';
}
</script>
</head>
<body class="h-full">
<%= @inner_content %>
<%= if @live_action == :docs do %>
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>mermaid.init(".mermaid")</script>
<% end %>
<script defer phx-track-static type="text/javascript" src="<%= Routes.static_path(@conn, "/assets/app.js") %>"></script>
</body>
</html>