feat: add preferences page with theme toggle
- Simple preferences page with engine selection - Light/dark theme toggle with localStorage persistence - Clean form layout without complex JS dependencies - Add dark theme CSS variables Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
030b4a8508
commit
77a41834a5
3 changed files with 355 additions and 166 deletions
|
|
@ -1,191 +1,142 @@
|
|||
{{define "title"}}Preferences{{end}}
|
||||
{{define "content"}}
|
||||
<div class="preferences-layout">
|
||||
<!-- Preferences Navigation -->
|
||||
<nav class="preferences-nav" id="preferences-nav">
|
||||
<div class="preferences-nav-title">Settings</div>
|
||||
<button class="preferences-nav-item active" data-section="search">🔍 Search</button>
|
||||
<button class="preferences-nav-item" data-section="privacy">🔒 Privacy</button>
|
||||
<button class="preferences-nav-item" data-section="tabs">📑 Tabs</button>
|
||||
<button class="preferences-nav-item" data-section="appearance">🎨 Appearance</button>
|
||||
<button class="preferences-nav-item" data-section="sidebar">📐 Sidebar</button>
|
||||
<button class="preferences-nav-item" data-section="content">📄 Content</button>
|
||||
<button class="preferences-nav-item" data-section="languages">🌍 Languages</button>
|
||||
<button class="preferences-nav-item" data-section="regional">📍 Regional</button>
|
||||
</nav>
|
||||
<div class="preferences-container">
|
||||
<h1 class="preferences-title">Preferences</h1>
|
||||
|
||||
<!-- Preferences Content -->
|
||||
<div class="preferences-content">
|
||||
<!-- Search Section -->
|
||||
<section class="pref-section" id="section-search">
|
||||
<h2 class="pref-section-title">Search</h2>
|
||||
<form class="preferences-form" method="POST" action="/preferences">
|
||||
<input type="hidden" name="theme" id="theme-input" value="light">
|
||||
|
||||
<section class="pref-section">
|
||||
<h2 class="pref-section-title">Appearance</h2>
|
||||
<div class="pref-row">
|
||||
<label for="pref-default-engine">Default engine</label>
|
||||
<select id="pref-default-engine">
|
||||
<option value="">All engines</option>
|
||||
<option value="wikipedia">Wikipedia</option>
|
||||
<option value="arxiv">arXiv</option>
|
||||
<option value="braveapi">Brave API</option>
|
||||
<option value="duckduckgo">DuckDuckGo</option>
|
||||
<option value="github">GitHub</option>
|
||||
<option value="reddit">Reddit</option>
|
||||
<option value="bing">Bing</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="pref-row">
|
||||
<label for="pref-safesearch">Safe search</label>
|
||||
<select id="pref-safesearch">
|
||||
<option value="moderate">Moderate</option>
|
||||
<option value="strict">Strict</option>
|
||||
<option value="off">Off</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="pref-row">
|
||||
<label for="pref-search-lang">Search language</label>
|
||||
<select id="pref-search-lang">
|
||||
<option value="">All languages</option>
|
||||
<option value="en">English</option>
|
||||
<option value="de">Deutsch</option>
|
||||
<option value="fr">Français</option>
|
||||
<option value="es">Español</option>
|
||||
<option value="zh">中文</option>
|
||||
</select>
|
||||
<label>Theme</label>
|
||||
<div class="theme-buttons">
|
||||
<button type="button" class="theme-btn active" data-theme="light">Light</button>
|
||||
<button type="button" class="theme-btn" data-theme="dark">Dark</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Privacy Section -->
|
||||
<section class="pref-section" id="section-privacy" style="display:none;">
|
||||
<section class="pref-section">
|
||||
<h2 class="pref-section-title">Search Engines</h2>
|
||||
<p class="pref-desc">Select which engines to use for searches.</p>
|
||||
<div class="engine-grid">
|
||||
<label class="engine-toggle">
|
||||
<input type="checkbox" name="engine" value="google" checked>
|
||||
<span>Google</span>
|
||||
</label>
|
||||
<label class="engine-toggle">
|
||||
<input type="checkbox" name="engine" value="duckduckgo" checked>
|
||||
<span>DuckDuckGo</span>
|
||||
</label>
|
||||
<label class="engine-toggle">
|
||||
<input type="checkbox" name="engine" value="bing" checked>
|
||||
<span>Bing</span>
|
||||
</label>
|
||||
<label class="engine-toggle">
|
||||
<input type="checkbox" name="engine" value="brave" checked>
|
||||
<span>Brave</span>
|
||||
</label>
|
||||
<label class="engine-toggle">
|
||||
<input type="checkbox" name="engine" value="wikipedia" checked>
|
||||
<span>Wikipedia</span>
|
||||
</label>
|
||||
<label class="engine-toggle">
|
||||
<input type="checkbox" name="engine" value="github">
|
||||
<span>GitHub</span>
|
||||
</label>
|
||||
<label class="engine-toggle">
|
||||
<input type="checkbox" name="engine" value="reddit">
|
||||
<span>Reddit</span>
|
||||
</label>
|
||||
<label class="engine-toggle">
|
||||
<input type="checkbox" name="engine" value="youtube">
|
||||
<span>YouTube</span>
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="pref-section">
|
||||
<h2 class="pref-section-title">Privacy</h2>
|
||||
<div class="pref-row">
|
||||
<div class="pref-row-info">
|
||||
<label>Tracking protection</label>
|
||||
<p class="pref-desc">Block trackers and scripts that follow you across the web.</p>
|
||||
<label>Safe Search</label>
|
||||
<p class="pref-desc">Filter explicit content from results</p>
|
||||
</div>
|
||||
<input type="checkbox" id="pref-tracking" checked disabled>
|
||||
</div>
|
||||
<div class="pref-row">
|
||||
<div class="pref-row-info">
|
||||
<label>Send Do Not Track header</label>
|
||||
<p class="pref-desc">Ask websites not to track you.</p>
|
||||
</div>
|
||||
<input type="checkbox" id="pref-dnt">
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Tabs Section -->
|
||||
<section class="pref-section" id="section-tabs" style="display:none;">
|
||||
<h2 class="pref-section-title">Tabs</h2>
|
||||
<div class="pref-row">
|
||||
<div class="pref-row-info">
|
||||
<label>New tab behavior</label>
|
||||
<p class="pref-desc">Choose what happens when you open a new tab.</p>
|
||||
</div>
|
||||
<select id="pref-newtab">
|
||||
<option value="blank">Blank page</option>
|
||||
<option value="home">Homepage</option>
|
||||
<select name="safesearch">
|
||||
<option value="0">Off</option>
|
||||
<option value="1" selected>Moderate</option>
|
||||
<option value="2">Strict</option>
|
||||
</select>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Appearance Section -->
|
||||
<section class="pref-section" id="section-appearance" style="display:none;">
|
||||
<h2 class="pref-section-title">Appearance</h2>
|
||||
<section class="pref-section">
|
||||
<h2 class="pref-section-title">Language</h2>
|
||||
<div class="pref-row">
|
||||
<label for="pref-theme">Theme</label>
|
||||
<select id="pref-theme">
|
||||
<option value="system">System</option>
|
||||
<option value="light">Light</option>
|
||||
<option value="dark">Dark</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="pref-row">
|
||||
<label for="pref-fontsize">Results font size</label>
|
||||
<select id="pref-fontsize">
|
||||
<option value="small">Small</option>
|
||||
<option value="medium" selected>Medium</option>
|
||||
<option value="large">Large</option>
|
||||
</select>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Sidebar Section -->
|
||||
<section class="pref-section" id="section-sidebar" style="display:none;">
|
||||
<h2 class="pref-section-title">Sidebar</h2>
|
||||
<div class="pref-row">
|
||||
<div class="pref-row-info">
|
||||
<label>Show sidebar on results page</label>
|
||||
<p class="pref-desc">Display the left navigation sidebar on search results.</p>
|
||||
</div>
|
||||
<input type="checkbox" id="pref-show-sidebar" checked>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Content Section -->
|
||||
<section class="pref-section" id="section-content" style="display:none;">
|
||||
<h2 class="pref-section-title">Content</h2>
|
||||
<div class="pref-row">
|
||||
<div class="pref-row-info">
|
||||
<label>Filter explicit results</label>
|
||||
<p class="pref-desc">Hide explicit content from search results (SafeSearch).</p>
|
||||
</div>
|
||||
<input type="checkbox" id="pref-explicit-filter" checked>
|
||||
</div>
|
||||
<div class="pref-row">
|
||||
<div class="pref-row-info">
|
||||
<label>Auto-play media</label>
|
||||
<p class="pref-desc">Automatically play video content when visible.</p>
|
||||
</div>
|
||||
<input type="checkbox" id="pref-autoplay">
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Languages Section -->
|
||||
<section class="pref-section" id="section-languages" style="display:none;">
|
||||
<h2 class="pref-section-title">Languages</h2>
|
||||
<div class="pref-row">
|
||||
<label for="pref-ui-lang">Interface language</label>
|
||||
<select id="pref-ui-lang">
|
||||
<option value="en" selected>English</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="pref-row">
|
||||
<label for="pref-search-lang-full">Search language</label>
|
||||
<select id="pref-search-lang-full">
|
||||
<option value="">All languages</option>
|
||||
<label for="search-lang">Interface & Search Language</label>
|
||||
<select name="language" id="search-lang">
|
||||
<option value="all" selected>All languages</option>
|
||||
<option value="en">English</option>
|
||||
<option value="de">Deutsch</option>
|
||||
<option value="fr">Français</option>
|
||||
<option value="es">Español</option>
|
||||
<option value="zh">中文</option>
|
||||
<option value="ja">日本語</option>
|
||||
<option value="ru">Русский</option>
|
||||
</select>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Regional Section -->
|
||||
<section class="pref-section" id="section-regional" style="display:none;">
|
||||
<h2 class="pref-section-title">Regional</h2>
|
||||
<div class="pref-row">
|
||||
<label for="pref-region">Country/Region</label>
|
||||
<select id="pref-region">
|
||||
<option value="">All regions</option>
|
||||
<option value="us">United States</option>
|
||||
<option value="uk">United Kingdom</option>
|
||||
<option value="de">Germany</option>
|
||||
<option value="fr">France</option>
|
||||
<option value="cn">China</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="pref-row">
|
||||
<label for="pref-timezone">Timezone</label>
|
||||
<select id="pref-timezone">
|
||||
<option value="">Auto-detect</option>
|
||||
<option value="utc">UTC</option>
|
||||
<option value="us-eastern">US/Eastern</option>
|
||||
<option value="us-pacific">US/Pacific</option>
|
||||
<option value="europe">Europe</option>
|
||||
</select>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="pref-actions">
|
||||
<a href="/" class="btn-secondary">Cancel</a>
|
||||
<button type="submit" class="btn-primary">Save Preferences</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
// Theme buttons
|
||||
var themeInput = document.getElementById('theme-input');
|
||||
var themeButtons = document.querySelectorAll('.theme-btn');
|
||||
|
||||
// Load saved theme
|
||||
var savedTheme = localStorage.getItem('kafka-theme') || 'light';
|
||||
themeInput.value = savedTheme;
|
||||
document.querySelectorAll('.theme-btn').forEach(function(btn) {
|
||||
btn.classList.toggle('active', btn.dataset.theme === savedTheme);
|
||||
});
|
||||
document.documentElement.setAttribute('data-theme', savedTheme);
|
||||
|
||||
themeButtons.forEach(function(btn) {
|
||||
btn.addEventListener('click', function() {
|
||||
var theme = btn.dataset.theme;
|
||||
themeInput.value = theme;
|
||||
themeButtons.forEach(function(b) { b.classList.remove('active'); });
|
||||
btn.classList.add('active');
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('kafka-theme', theme);
|
||||
});
|
||||
});
|
||||
|
||||
// Load saved engine preferences
|
||||
var savedEngines = JSON.parse(localStorage.getItem('kafka-engines') || 'null');
|
||||
if (savedEngines) {
|
||||
savedEngines.forEach(function(engine) {
|
||||
var checkbox = document.querySelector('input[name="engine"][value="' + engine.id + '"]');
|
||||
if (checkbox) checkbox.checked = engine.enabled;
|
||||
});
|
||||
}
|
||||
|
||||
// Save on submit
|
||||
document.querySelector('.preferences-form').addEventListener('submit', function() {
|
||||
var engines = [];
|
||||
document.querySelectorAll('input[name="engine"]').forEach(function(cb) {
|
||||
engines.push({ id: cb.value, enabled: cb.checked });
|
||||
});
|
||||
localStorage.setItem('kafka-engines', JSON.stringify(engines));
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{{end}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue