templates/partials/header.html.twig line 1

Open in your IDE?
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="utf-8" />
  5.     <title>{{ title }} | Fortified</title>
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
  8.     <meta content="Coderthemes" name="author" />
  9.     <!-- App favicon -->
  10.     <link rel="shortcut icon" href="{{ asset('assets/images/favicon.ico') }}">
  11.     {{ pageCss|raw }}
  12.     <script>
  13.         function setTheme(themeName) {
  14.             localStorage.setItem('theme', themeName);
  15.             console.log(document.querySelector('body'));
  16.             document.querySelector('body').setAttribute('data-layout-color', themeName);
  17.         }
  18.         // function to toggle between light and dark theme
  19.         function toggleTheme() {
  20.             if (localStorage.getItem('theme') === 'dark'){
  21.                 setTheme('light');
  22.             } else {
  23.                 setTheme('dark');
  24.             }
  25.         }
  26.         function initTheme() {
  27.             if (localStorage.getItem('theme') === 'light') {
  28.                 setTheme('light');
  29.             } else {
  30.                 setTheme('dark');
  31.             }
  32.             document.querySelector(".theme-icon").addEventListener("click", () => {
  33.                 toggleTheme();
  34.             });
  35.         }
  36.         // Immediately invoked function to set the theme on initial load
  37.         (function () {
  38.             window.onload = (event) => {
  39.                 initTheme();
  40.             };
  41.         })();
  42.     </script>
  43.     <style>
  44.         .theme-icon i {
  45.             font-size: 32px;
  46.             vertical-align: middle;
  47.             line-height: 70px;
  48.         }
  49.         body:not([data-layout-color=light]) .theme-icon .fa-sun {
  50.             display: none;
  51.         }
  52.         body:not([data-layout-color=light]) .theme-icon .fa-moon {
  53.             display: inline-block;
  54.             color: var(--ct-body-color);
  55.         }
  56.         body[data-layout-color=light] .theme-icon .fa-sun {
  57.             display: inline-block;
  58.         }
  59.         body[data-layout-color=light] .theme-icon .fa-moon {
  60.             display: none;
  61.         }
  62.     </style>
  63. </head>