|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | + <title>✍️ MiniTemplate - Simple Template Engine</title> |
| 7 | + |
| 8 | + <!-- DaisyUI with Tailwind CDN --> |
| 9 | + <link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.12/dist/full.min.css" rel="stylesheet" /> |
| 10 | + <script src="https://cdn.tailwindcss.com"></script> |
| 11 | +</head> |
| 12 | +<body class="flex flex-col min-h-screen"> |
| 13 | + |
| 14 | + <div> |
| 15 | + <div id="sidebar_default" data-state="closed" class="bg-neutral w-64 h-full fixed top-0 left-0 flex flex-col justify-between transform -translate-x-full md:translate-x-0 transition-transform duration-300 ease-in-out z-10"> |
| 16 | + <!-- Sidebar Header --> |
| 17 | + <div class="h-16 flex items-center justify-between px-4"> |
| 18 | + <!-- Hamburger Icon (Always Visible) --> |
| 19 | + <button class="toggleSidebarButton" aria-label="Toggle Sidebar"> |
| 20 | + ☰ |
| 21 | + </button> |
| 22 | + |
| 23 | + <button onclick="" aria-label="New Chat"> |
| 24 | + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="w-6 h-6"> |
| 25 | + <path d="M12 19c4.418 0 8-3.582 8-8s-3.582-8-8-8S4 6.582 4 11a7.93 7.93 0 0 0 1.582 4.635l-1.39 3.483a1 1 0 0 0 1.266 1.266l3.483-1.39A7.93 7.93 0 0 0 12 19zm0-10v4m0 0v-4m-2 2h4"/> |
| 26 | + </svg> |
| 27 | + </button> |
| 28 | + </div> |
| 29 | + |
| 30 | + <!-- Sidebar Navigation --> |
| 31 | + <nav class="flex-1 p-4"> |
| 32 | + <ul class="menu w-full"> |
| 33 | + <li>sidebar entry</li> |
| 34 | + </ul> |
| 35 | + </nav> |
| 36 | + |
| 37 | + <!-- Sidebar Footer --> |
| 38 | + <div class="p-4 h-5px flex items-center justify-center"> |
| 39 | + <p class="text-sm"></p> |
| 40 | + </div> |
| 41 | + |
| 42 | + <!-- Self-contained JavaScript for Sidebar Toggle and Breakpoint Detection --> |
| 43 | + <script> |
| 44 | + (function() { |
| 45 | + document.addEventListener('DOMContentLoaded', function() { |
| 46 | + const sidebar = document.getElementById('sidebar_default'); |
| 47 | + const toggleButtons = document.querySelectorAll('.toggleSidebarButton'); // Targeting all hamburger icons |
| 48 | + const mainContainer = document.body; |
| 49 | + const content = document.getElementById('content_component'); |
| 50 | + const contentHamburger = document.getElementById('contentHamburger'); // The hamburger in the content header |
| 51 | + |
| 52 | + function updateSidebarState() { |
| 53 | + if (window.innerWidth >= 768) { // Medium screens and larger |
| 54 | + sidebar.classList.remove('-translate-x-full', 'md:-translate-x-64'); |
| 55 | + sidebar.classList.add('md:translate-x-0'); |
| 56 | + sidebar.setAttribute('data-state', 'open'); |
| 57 | + content.classList.add('md:ml-64'); |
| 58 | + mainContainer.setAttribute('data-sidebar', 'open'); |
| 59 | + contentHamburger.classList.add('hidden'); // Hide content hamburger when sidebar is open |
| 60 | + } else { // Small screens (mobile) |
| 61 | + sidebar.classList.add('-translate-x-full', 'md:-translate-x-64'); |
| 62 | + sidebar.setAttribute('data-state', 'closed'); |
| 63 | + content.classList.remove('md:ml-64'); |
| 64 | + mainContainer.setAttribute('data-sidebar', 'closed'); |
| 65 | + contentHamburger.classList.remove('hidden'); // Show content hamburger when sidebar is collapsed |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + // Add event listener to buttons for toggling the sidebar |
| 70 | + toggleButtons.forEach(button => { |
| 71 | + button.addEventListener('click', function() { |
| 72 | + const state = sidebar.getAttribute('data-state'); |
| 73 | + if (state === 'open') { |
| 74 | + sidebar.classList.add('-translate-x-full', 'md:-translate-x-64'); |
| 75 | + sidebar.setAttribute('data-state', 'closed'); |
| 76 | + mainContainer.setAttribute('data-sidebar', 'closed'); |
| 77 | + content.classList.remove('md:ml-64'); |
| 78 | + contentHamburger.classList.remove('hidden'); // Show content hamburger when sidebar is collapsed |
| 79 | + } else { |
| 80 | + sidebar.classList.remove('-translate-x-full', 'md:-translate-x-64'); |
| 81 | + sidebar.setAttribute('data-state', 'open'); |
| 82 | + mainContainer.setAttribute('data-sidebar', 'open'); |
| 83 | + content.classList.add('md:ml-64'); |
| 84 | + contentHamburger.classList.add('hidden'); // Hide content hamburger when sidebar is open |
| 85 | + } |
| 86 | + }); |
| 87 | + }); |
| 88 | + |
| 89 | + // Detect window resize and apply sidebar state accordingly |
| 90 | + window.addEventListener('resize', updateSidebarState); |
| 91 | + |
| 92 | + // Set initial sidebar state based on screen size |
| 93 | + updateSidebarState(); |
| 94 | + }); |
| 95 | + })(); |
| 96 | + </script> |
| 97 | +</div> |
| 98 | + <div id="content_default" class="bg-neutral flex flex-col flex-1 transition-all duration-300 ease-in-out md:ml-64 h-dvh"> |
| 99 | + <div id="header_default"> |
| 100 | + <header id="contentHeader" class="h-16 flex items-center justify-between w-full p-0 px-4"> |
| 101 | + <div class="flex items-center space-x-4"> |
| 102 | + <button id="contentHamburger" class="toggleSidebarButton hidden" aria-label="Toggle Sidebar">☰</button> |
| 103 | + <h1 id="auth-modeldropdown" class="text-lg"></h1> |
| 104 | + </div> |
| 105 | + <div id="themecontroller_default" class="dropdown"> |
| 106 | + <div id="themeButton" tabindex="0" role="button" class="btn"> |
| 107 | + Theme |
| 108 | + <svg width="12px" height="12px" class="inline-block h-2 w-2 fill-current opacity-60" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2048 2048"> |
| 109 | + <path d="M1799 349l242 241-1017 1017L7 590l242-241 775 775 775-775z"></path> |
| 110 | + </svg> |
| 111 | + </div> |
| 112 | + <ul id="themeDropdown" tabindex="0" class="dropdown-content bg-base-300 rounded-box z-[1] shadow-2xl hidden"> |
| 113 | + <li> |
| 114 | + <input type="radio" name="theme-dropdown" class="theme-controller btn btn-sm btn-block btn-ghost justify-start" aria-label="Dark" value="dark" /> |
| 115 | + </li> |
| 116 | + <li> |
| 117 | + <input type="radio" name="theme-dropdown" class="theme-controller btn btn-sm btn-block btn-ghost justify-start" aria-label="Light" value="light" /> |
| 118 | + </li> |
| 119 | + <li> |
| 120 | + <input type="radio" name="theme-dropdown" class="theme-controller btn btn-sm btn-block btn-ghost justify-start" aria-label="Cyberpunk" value="cyberpunk" /> |
| 121 | + </li> |
| 122 | + <li> |
| 123 | + <input type="radio" name="theme-dropdown" class="theme-controller btn btn-sm btn-block btn-ghost justify-start" aria-label="Business" value="business" /> |
| 124 | + </li> |
| 125 | + <li> |
| 126 | + <input type="radio" name="theme-dropdown" class="theme-controller btn btn-sm btn-block btn-ghost justify-start" aria-label="Aqua" value="aqua" /> |
| 127 | + </li> |
| 128 | + </ul> |
| 129 | + <script> |
| 130 | + (function() { |
| 131 | + document.addEventListener('DOMContentLoaded', function() { |
| 132 | + const themeButton = document.getElementById('themeButton'); |
| 133 | + const themeDropdown = document.getElementById('themeDropdown'); |
| 134 | + const themeOptions = document.querySelectorAll('.theme-controller'); |
| 135 | + |
| 136 | + // Set initial theme from local storage or default to "Theme" |
| 137 | + const savedTheme = localStorage.getItem('selectedTheme'); |
| 138 | + if (savedTheme) { |
| 139 | + document.body.setAttribute('data-theme', savedTheme); |
| 140 | + const selectedOption = Array.from(themeOptions).find(option => option.value === savedTheme); |
| 141 | + if (selectedOption) { |
| 142 | + themeButton.childNodes[0].textContent = selectedOption.getAttribute('aria-label'); |
| 143 | + selectedOption.checked = true; |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + // Toggle dropdown visibility when the button is clicked |
| 148 | + themeButton.addEventListener('click', function() { |
| 149 | + themeDropdown.classList.toggle('hidden'); |
| 150 | + }); |
| 151 | + |
| 152 | + // Close the dropdown if clicked outside |
| 153 | + document.addEventListener('click', function(event) { |
| 154 | + if (!themeButton.contains(event.target) && !themeDropdown.contains(event.target)) { |
| 155 | + themeDropdown.classList.add('hidden'); |
| 156 | + } |
| 157 | + }); |
| 158 | + |
| 159 | + // Apply selected theme, update button label, save to local storage, and close dropdown |
| 160 | + themeOptions.forEach(option => { |
| 161 | + option.addEventListener('change', function() { |
| 162 | + document.body.setAttribute('data-theme', this.value); // Change theme |
| 163 | + themeButton.childNodes[0].textContent = this.getAttribute('aria-label'); // Update button label |
| 164 | + localStorage.setItem('selectedTheme', this.value); // Save to local storage |
| 165 | + themeDropdown.classList.add('hidden'); // Close dropdown |
| 166 | + }); |
| 167 | + }); |
| 168 | + }); |
| 169 | + })(); |
| 170 | + </script> |
| 171 | +</div> |
| 172 | + </header> |
| 173 | + <script> |
| 174 | + </script> |
| 175 | +</div> |
| 176 | + <div id="" class="flex flex-1 flex-col p-6 rounded-lg shadow overflow-hidden"> |
| 177 | + <div id="hero_default"> |
| 178 | +<div class="hero bg-base-200"> |
| 179 | + <div class="hero-content text-center"> |
| 180 | + <div class="max-w-md"> |
| 181 | + <h1 class="text-5xl font-bold">Hi there!</h1> |
| 182 | + <p class="py-6"> |
| 183 | + MiniTemplate is a self-contained, modular, static, CDN-only template engine. |
| 184 | + Build your projects easily without dependency hell or the need for complex setups. |
| 185 | + </p> |
| 186 | + <button class="btn btn-primary" onclick="window.open('https://github.com/nostack-dev/minitemplate/blob/main/README.md', '_blank')">Get Started</button> |
| 187 | + </div> |
| 188 | + </div> |
| 189 | +</div> |
| 190 | + <script> |
| 191 | + </script> |
| 192 | +</div> |
| 193 | + </div> |
| 194 | + <!-- Content Footer --> |
| 195 | + <div class="p-4 h-5px flex items-center justify-center"> |
| 196 | + <p class="text-sm"></p> |
| 197 | + </div> |
| 198 | + <script> |
| 199 | + </script> |
| 200 | +</div> |
| 201 | + </div> |
| 202 | + |
| 203 | +</body> |
| 204 | +</html> |
0 commit comments