feat(frontend): add preferences page template and styles

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ashisgreat22 2026-03-22 13:47:30 +01:00
parent 3dbde9fbfd
commit b4053b7f98
3 changed files with 284 additions and 0 deletions

View file

@ -1269,6 +1269,89 @@ a:focus-visible {
} }
} }
/* ============================================================
Preferences Page Styles
============================================================ */
.pref-section {
margin-bottom: 2rem;
}
.pref-section:last-child {
margin-bottom: 0;
}
.pref-section-title {
font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 1rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--border);
}
.pref-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 0.75rem 0;
border-bottom: 1px solid var(--border);
}
.pref-row:last-child {
border-bottom: none;
}
.pref-row label {
font-size: 0.9rem;
color: var(--text-primary);
}
.pref-row-info {
flex: 1;
}
.pref-row-info label {
font-weight: 500;
}
.pref-desc {
font-size: 0.8rem;
color: var(--text-muted);
margin-top: 0.25rem;
}
.pref-row select {
padding: 0.5rem 0.75rem;
font-size: 0.85rem;
font-family: inherit;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
background: var(--bg);
color: var(--text-primary);
cursor: pointer;
min-width: 150px;
}
.pref-row select:focus {
outline: none;
border-color: var(--accent);
}
.pref-row input[type="checkbox"] {
width: 18px;
height: 18px;
accent-color: var(--accent);
cursor: pointer;
flex-shrink: 0;
}
.pref-row input[type="checkbox"]:disabled {
opacity: 0.6;
cursor: not-allowed;
}
/* ============================================================ /* ============================================================
Print Print
============================================================ */ ============================================================ */

View file

@ -0,0 +1,191 @@
{{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>
<!-- Preferences Content -->
<div class="preferences-content">
<!-- Search Section -->
<section class="pref-section" id="section-search">
<h2 class="pref-section-title">Search</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>
</div>
</section>
<!-- Privacy Section -->
<section class="pref-section" id="section-privacy" style="display:none;">
<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>
</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>
</div>
</section>
<!-- Appearance Section -->
<section class="pref-section" id="section-appearance" style="display:none;">
<h2 class="pref-section-title">Appearance</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>
<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>
</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>
{{end}}

View file

@ -92,6 +92,7 @@ var (
tmplFull *template.Template tmplFull *template.Template
tmplIndex *template.Template tmplIndex *template.Template
tmplFragment *template.Template tmplFragment *template.Template
tmplPreferences *template.Template
) )
func init() { func init() {
@ -111,6 +112,9 @@ func init() {
tmplFragment = template.Must(template.New("").Funcs(funcMap).ParseFS(tmplFS, tmplFragment = template.Must(template.New("").Funcs(funcMap).ParseFS(tmplFS,
"results_inner.html", "result_item.html", "video_item.html", "results_inner.html", "result_item.html", "video_item.html",
)) ))
tmplPreferences = template.Must(template.New("").Funcs(funcMap).ParseFS(tmplFS,
"base.html", "preferences.html",
))
} }
// StaticFS returns the embedded static file system for serving CSS/JS/images. // StaticFS returns the embedded static file system for serving CSS/JS/images.
@ -288,3 +292,9 @@ func RenderSearchAuto(w http.ResponseWriter, r *http.Request, data PageData) err
return RenderSearch(w, data) return RenderSearch(w, data)
} }
// RenderPreferences renders the full preferences page.
func RenderPreferences(w http.ResponseWriter, sourceURL string) error {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
return tmplPreferences.ExecuteTemplate(w, "base", PageData{ShowHeader: true, SourceURL: sourceURL})
}