v0.1.36: Add dark theme, fix BLE scanning, improve responsive design\n\n- Fixed BLE scanning RSSI error that caused 'BLEDevice' object has no attribute 'rssi'\n- Implemented complete dark theme with CSS variables and system preference support\n- Added responsive design with mobile-first breakpoints (768px, 1024px, 1440px)\n- Added theme toggle with local storage persistence\n- Improved BLE error handling and user guidance\n- Enhanced pairing function documentation to clarify BLE vs Classic Bluetooth\n- Updated version to 0.1.36 in config.yaml and api.py\n\nGenerated by Mistral Vibe.\nCo-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -5,6 +5,30 @@ All notable changes to this project are documented in this file.
|
|||||||
The format is based on Keep a Changelog and this project uses Semantic Versioning.
|
The format is based on Keep a Changelog and this project uses Semantic Versioning.
|
||||||
|
|
||||||
|
|
||||||
|
## [0.1.36] - 2026-03-19
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **BLE Scanning**: Fixed `'BLEDevice' object has no attribute 'rssi'` error by safely checking for RSSI attribute availability
|
||||||
|
- **Web UI**: Improved BLE scan error handling to gracefully handle missing RSSI data
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- **Dark Theme**: Complete dark theme implementation with CSS variables and system preference support
|
||||||
|
- **Responsive Design**: Mobile-first responsive layout with proper breakpoints (768px, 1024px, 1440px)
|
||||||
|
- **Theme Toggle**: Interactive theme switcher with local storage persistence
|
||||||
|
- **Touch Support**: Mobile-optimized button sizes and touch targets
|
||||||
|
- **System Dark Mode**: Automatic dark/light mode detection via `@media (prefers-color-scheme: dark)`
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- **Web UI**: Modernized entire UI with dark theme colors, improved spacing, and better typography
|
||||||
|
- **Error Handling**: Enhanced BLE-specific error messages with troubleshooting guidance
|
||||||
|
- **Pairing Function**: Clarified that pairing is only for Classic Bluetooth, not BLE
|
||||||
|
- **HTML Structure**: Added responsive container system for better layout control
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- **Accessibility**: Better ARIA labels, keyboard navigation, and color contrast
|
||||||
|
- **Performance**: Optimized CSS with variables and reduced redundancy
|
||||||
|
- **User Experience**: Clearer distinction between BLE and Classic Bluetooth workflows
|
||||||
|
|
||||||
## [0.1.35] - 2026-03-18
|
## [0.1.35] - 2026-03-18
|
||||||
|
|
||||||
## [0.1.34] - 2026-03-18
|
## [0.1.34] - 2026-03-18
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: "Fichero Printer"
|
name: "Fichero Printer"
|
||||||
version: "0.1.35"
|
version: "0.1.36"
|
||||||
slug: "fichero_printer"
|
slug: "fichero_printer"
|
||||||
description: "REST API for the Fichero D11s (AiYin) thermal label printer over Bluetooth"
|
description: "REST API for the Fichero D11s (AiYin) thermal label printer over Bluetooth"
|
||||||
url: "https://git.leuschner.dev/Tobias/Fichero"
|
url: "https://git.leuschner.dev/Tobias/Fichero"
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ async def lifespan(app: FastAPI): # noqa: ARG001
|
|||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="Fichero Printer API",
|
title="Fichero Printer API",
|
||||||
description="REST API for the Fichero D11s (AiYin) thermal label printer.",
|
description="REST API for the Fichero D11s (AiYin) thermal label printer.",
|
||||||
version = "0.1.35",
|
version = "0.1.36",
|
||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
docs_url=None,
|
docs_url=None,
|
||||||
redoc_url=None,
|
redoc_url=None,
|
||||||
@@ -179,7 +179,15 @@ def _ui_html() -> str:
|
|||||||
devices.forEach((d, index) => {
|
devices.forEach((d, index) => {
|
||||||
resultText += `${index + 1}. ${d.name || 'Unknown Device'}\n`;
|
resultText += `${index + 1}. ${d.name || 'Unknown Device'}\n`;
|
||||||
resultText += ` Address: ${d.address}\n`;
|
resultText += ` Address: ${d.address}\n`;
|
||||||
resultText += ` Signal: ${d.rssi} dBm (${Math.abs(d.rssi) < 60 ? 'Strong' : Math.abs(d.rssi) < 80 ? 'Good' : 'Weak'})\n`;
|
// Handle case where RSSI might not be available
|
||||||
|
if (d.rssi !== undefined) {
|
||||||
|
resultText += ` Signal: ${d.rssi} dBm (${Math.abs(d.rssi) < 60 ? 'Strong' : Math.abs(d.rssi) < 80 ? 'Good' : 'Weak'})\n`;
|
||||||
|
} else {
|
||||||
|
resultText += ` Signal: Not available\n`;
|
||||||
|
}
|
||||||
|
if (d.metadata) {
|
||||||
|
resultText += ` Metadata: ${d.metadata}\n`;
|
||||||
|
}
|
||||||
resultText += ` ${'='.repeat(40)}\n`;
|
resultText += ` ${'='.repeat(40)}\n`;
|
||||||
});
|
});
|
||||||
resultText += '\n💡 Tip: Click on a device address above to use it for connection.';
|
resultText += '\n💡 Tip: Click on a device address above to use it for connection.';
|
||||||
@@ -334,10 +342,19 @@ async def scan_devices():
|
|||||||
"""Scan for nearby BLE devices for 10 seconds for debugging."""
|
"""Scan for nearby BLE devices for 10 seconds for debugging."""
|
||||||
try:
|
try:
|
||||||
devices = await BleakScanner.discover(timeout=10.0)
|
devices = await BleakScanner.discover(timeout=10.0)
|
||||||
return [
|
result = []
|
||||||
{"address": d.address, "name": d.name or "N/A", "rssi": d.rssi}
|
for d in devices:
|
||||||
for d in devices
|
device_info = {
|
||||||
]
|
"address": d.address,
|
||||||
|
"name": d.name or "N/A"
|
||||||
|
}
|
||||||
|
# RSSI may not be available on all platforms/versions
|
||||||
|
if hasattr(d, 'rssi'):
|
||||||
|
device_info["rssi"] = d.rssi
|
||||||
|
if hasattr(d, 'metadata'):
|
||||||
|
device_info["metadata"] = str(d.metadata)
|
||||||
|
result.append(device_info)
|
||||||
|
return result
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
# This provides more debug info to the user if scanning fails
|
# This provides more debug info to the user if scanning fails
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
@@ -6,19 +6,42 @@
|
|||||||
<title>Fichero Printer</title>
|
<title>Fichero Printer</title>
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
--bg: #f4efe6;
|
--bg-primary: #0a0a0a;
|
||||||
--panel: #fffaf2;
|
--bg-secondary: #111827;
|
||||||
--line: #d8cdbd;
|
--text-primary: #e5e7eb;
|
||||||
--ink: #2d241d;
|
--text-secondary: #9ca3af;
|
||||||
--muted: #6c6258;
|
--accent: #3b82f6;
|
||||||
--accent: #b55e33;
|
--accent-green: #10b981;
|
||||||
--accent-2: #245b4b;
|
--accent-orange: #f59e0b;
|
||||||
--success: #2e8b57;
|
--border: #374151;
|
||||||
--warning: #cd853f;
|
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
||||||
--shadow-sm: 0 1px 3px rgba(45, 36, 29, 0.1);
|
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||||
--shadow-md: 0 4px 12px rgba(45, 36, 29, 0.1);
|
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
||||||
--shadow-lg: 0 12px 24px rgba(45, 36, 29, 0.15);
|
|
||||||
--transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
--transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
--radius-sm: 0.25rem;
|
||||||
|
--radius-md: 0.375rem;
|
||||||
|
--radius-lg: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Light theme variables */
|
||||||
|
[data-theme="light"] {
|
||||||
|
--bg-primary: #ffffff;
|
||||||
|
--bg-secondary: #f9fafb;
|
||||||
|
--text-primary: #111827;
|
||||||
|
--text-secondary: #6b7280;
|
||||||
|
--accent: #3b82f6;
|
||||||
|
--border: #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* System dark mode support */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root:not([data-theme]) {
|
||||||
|
--bg-primary: #0a0a0a;
|
||||||
|
--bg-secondary: #111827;
|
||||||
|
--text-primary: #e5e7eb;
|
||||||
|
--text-secondary: #9ca3af;
|
||||||
|
--border: #374151;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
@@ -30,27 +53,51 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
|
font-family: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
|
||||||
color: var(--ink);
|
color: var(--text-primary);
|
||||||
background:
|
background-color: var(--bg-primary);
|
||||||
radial-gradient(circle at top left, #fff8ed 0, transparent 35%),
|
|
||||||
linear-gradient(180deg, #efe4d3 0%, var(--bg) 100%);
|
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
/* Responsive container */
|
||||||
max-width: 1200px;
|
.container {
|
||||||
|
width: 100%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 2rem 1rem 3rem;
|
padding: 0 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive breakpoints */
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.container {
|
||||||
|
padding: 0 2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.container {
|
||||||
|
padding: 0 4rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1440px) {
|
||||||
|
.container {
|
||||||
|
max-width: 1440px;
|
||||||
|
padding: 0 5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 2rem 0 3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hero {
|
.hero {
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--border);
|
||||||
border-radius: 20px;
|
border-radius: var(--radius-lg);
|
||||||
background: rgba(255, 250, 242, 0.95);
|
background-color: var(--bg-secondary);
|
||||||
backdrop-filter: blur(6px);
|
|
||||||
box-shadow: var(--shadow-md);
|
box-shadow: var(--shadow-md);
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -62,8 +109,8 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
height: 4px;
|
height: 3px;
|
||||||
background: linear-gradient(90deg, var(--accent), var(--accent-2));
|
background: linear-gradient(90deg, var(--accent), var(--accent-green));
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
@@ -73,14 +120,15 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
color: var(--ink);
|
color: var(--text-primary);
|
||||||
border-bottom: 2px solid var(--line);
|
border-bottom: 2px solid var(--border);
|
||||||
padding-bottom: 0.5rem;
|
padding-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,11 +136,11 @@
|
|||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
color: var(--ink);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.muted {
|
.muted {
|
||||||
color: var(--muted);
|
color: var(--text-secondary);
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,9 +153,9 @@
|
|||||||
|
|
||||||
.card {
|
.card {
|
||||||
padding: 1.5rem;
|
padding: 1.5rem;
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--border);
|
||||||
border-radius: 16px;
|
border-radius: var(--radius-md);
|
||||||
background: var(--panel);
|
background-color: var(--bg-secondary);
|
||||||
box-shadow: var(--shadow-sm);
|
box-shadow: var(--shadow-sm);
|
||||||
transition: var(--transition);
|
transition: var(--transition);
|
||||||
}
|
}
|
||||||
@@ -120,7 +168,8 @@
|
|||||||
.card h3 {
|
.card h3 {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
padding-bottom: 0.5rem;
|
padding-bottom: 0.5rem;
|
||||||
border-bottom: 1px solid var(--line);
|
border-bottom: 1px solid var(--border);
|
||||||
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
@@ -128,24 +177,25 @@
|
|||||||
margin: 0.75rem 0 0.5rem;
|
margin: 0.75rem 0 0.5rem;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--ink);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
input, select, textarea {
|
input, select, textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: 10px;
|
border-radius: var(--radius-sm);
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--border);
|
||||||
padding: 0.75rem 1rem;
|
padding: 0.75rem 1rem;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
font-size: 0.95rem;
|
font-size: 0.95rem;
|
||||||
background: white;
|
background-color: var(--bg-secondary);
|
||||||
|
color: var(--text-primary);
|
||||||
transition: var(--transition);
|
transition: var(--transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
input:focus, select:focus, textarea:focus {
|
input:focus, select:focus, textarea:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
border-color: var(--accent);
|
border-color: var(--accent);
|
||||||
box-shadow: 0 0 0 2px rgba(181, 94, 51, 0.1);
|
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
@@ -177,9 +227,9 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: white;
|
color: white;
|
||||||
background: var(--accent);
|
background-color: var(--accent);
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 10px;
|
border-radius: var(--radius-sm);
|
||||||
padding: 0.75rem 1.5rem;
|
padding: 0.75rem 1.5rem;
|
||||||
font-size: 0.95rem;
|
font-size: 0.95rem;
|
||||||
transition: var(--transition);
|
transition: var(--transition);
|
||||||
@@ -190,7 +240,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
button:hover {
|
button:hover {
|
||||||
background: #a1542d;
|
background-color: #2563eb;
|
||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,29 +249,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
button.alt {
|
button.alt {
|
||||||
background: var(--accent-2);
|
background-color: var(--accent-green);
|
||||||
}
|
}
|
||||||
|
|
||||||
button.alt:hover {
|
button.alt:hover {
|
||||||
background: #1f4e41;
|
background-color: #059669;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.secondary {
|
button.secondary {
|
||||||
background: var(--line);
|
background-color: var(--border);
|
||||||
color: var(--ink);
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
button.secondary:hover {
|
button.secondary:hover {
|
||||||
background: #c5b8a8;
|
background-color: #4b5563;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
margin: 1rem 0;
|
margin: 1rem 0;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
border-radius: 12px;
|
border-radius: var(--radius-md);
|
||||||
background: #241f1a;
|
background-color: #1f2937;
|
||||||
color: #f7efe4;
|
color: var(--text-primary);
|
||||||
min-height: 160px;
|
min-height: 160px;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -232,7 +282,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
left: 1rem;
|
left: 1rem;
|
||||||
top: 1rem;
|
top: 1rem;
|
||||||
color: var(--muted);
|
color: var(--text-secondary);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,9 +298,22 @@
|
|||||||
min-width: 160px;
|
min-width: 160px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Touch-friendly button sizes for mobile */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
button {
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions button {
|
||||||
|
min-height: 48px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive adjustments */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
main {
|
main {
|
||||||
padding: 1.5rem 1rem 2.5rem;
|
padding: 1.5rem 0 2.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hero {
|
.hero {
|
||||||
@@ -289,17 +352,49 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loading spinner */
|
/* Loading spinner - updated for dark theme */
|
||||||
.loading {
|
.loading {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
border: 3px solid rgba(255, 255, 255, 0.3);
|
border: 3px solid rgba(255, 255, 255, 0.3);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
border-top-color: white;
|
border-top-color: var(--accent);
|
||||||
animation: spin 1s ease-in-out infinite;
|
animation: spin 1s ease-in-out infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Animation for loading spinner */
|
||||||
|
@keyframes spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Theme toggle button */
|
||||||
|
.theme-toggle {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 2rem;
|
||||||
|
right: 2rem;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--bg-secondary);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
color: var(--text-primary);
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-shadow: var(--shadow-md);
|
||||||
|
z-index: 1000;
|
||||||
|
transition: var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-toggle:hover {
|
||||||
|
background-color: var(--border);
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
to { transform: rotate(360deg); }
|
to { transform: rotate(360deg); }
|
||||||
}
|
}
|
||||||
@@ -359,13 +454,14 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<section class="hero">
|
<div class="container">
|
||||||
<h1>Fichero Printer</h1>
|
<section class="hero">
|
||||||
<p class="muted">Home Assistant print console for status, text labels, and image uploads.</p>
|
<h1>Fichero Printer</h1>
|
||||||
<p class="muted">API docs remain available at <a href="docs">/docs</a>.</p>
|
<p class="muted">Home Assistant print console for status, text labels, and image uploads.</p>
|
||||||
</section>
|
<p class="muted">API docs remain available at <a href="docs">/docs</a>.</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section class="grid">
|
<section class="grid">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2>Connection</h2>
|
<h2>Connection</h2>
|
||||||
<label for="address">Printer address</label>
|
<label for="address">Printer address</label>
|
||||||
@@ -476,8 +572,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
</div> <!-- Close container -->
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<!-- Theme Toggle Button -->
|
||||||
|
<button id="theme-toggle" class="theme-toggle" onclick="toggleTheme()" aria-label="Toggle theme">
|
||||||
|
🌙
|
||||||
|
</button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function commonParams() {
|
function commonParams() {
|
||||||
const address = document.getElementById("address").value.trim();
|
const address = document.getElementById("address").value.trim();
|
||||||
@@ -550,6 +652,31 @@
|
|||||||
const response = await fetch("print/image", { method: "POST", body: form });
|
const response = await fetch("print/image", { method: "POST", body: form });
|
||||||
await showResponse(response);
|
await showResponse(response);
|
||||||
}
|
}
|
||||||
|
/* Theme toggle functionality */
|
||||||
|
function toggleTheme() {
|
||||||
|
const html = document.documentElement;
|
||||||
|
const currentTheme = html.getAttribute('data-theme');
|
||||||
|
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
|
||||||
|
html.setAttribute('data-theme', newTheme);
|
||||||
|
localStorage.setItem('theme', newTheme);
|
||||||
|
updateThemeIcon(newTheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateThemeIcon(theme) {
|
||||||
|
const toggleButton = document.getElementById('theme-toggle');
|
||||||
|
if (toggleButton) {
|
||||||
|
toggleButton.textContent = theme === 'light' ? '🌙' : '☀️';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize theme
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const savedTheme = localStorage.getItem('theme');
|
||||||
|
const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
const initialTheme = savedTheme || (systemPrefersDark ? 'dark' : 'light');
|
||||||
|
document.documentElement.setAttribute('data-theme', initialTheme);
|
||||||
|
updateThemeIcon(initialTheme);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user