mirror of
https://github.com/lone-cloud/prism
synced 2026-06-03 19:54:44 -07:00
theme switcher
This commit is contained in:
parent
19a23b8ec1
commit
11769218b9
5 changed files with 141 additions and 28 deletions
1
NOTICE
1
NOTICE
|
|
@ -11,6 +11,7 @@ The Android application (android/) contains modified code from:
|
||||||
Licensed under Apache License 2.0
|
Licensed under Apache License 2.0
|
||||||
|
|
||||||
Major modifications:
|
Major modifications:
|
||||||
|
|
||||||
- Completely replaced HTTP/WebSocket polling with Signal-based push delivery
|
- Completely replaced HTTP/WebSocket polling with Signal-based push delivery
|
||||||
- Removed all user authentication, attachment downloads, and action buttons
|
- Removed all user authentication, attachment downloads, and action buttons
|
||||||
- Removed Firebase, certificate pinning, and instant delivery features
|
- Removed Firebase, certificate pinning, and instant delivery features
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,50 @@
|
||||||
|
:root {
|
||||||
|
--bg-primary: #f5f5f5;
|
||||||
|
--bg-secondary: #fdfdfd;
|
||||||
|
--text-primary: #000;
|
||||||
|
--text-secondary: #666;
|
||||||
|
--border-color: rgba(0, 0, 0, 0.1);
|
||||||
|
--accent: #8159b8;
|
||||||
|
--success: #28a745;
|
||||||
|
--error: #dc3545;
|
||||||
|
--spinner-track: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--bg-primary: #1a1a1a;
|
||||||
|
--bg-secondary: #2d2d2d;
|
||||||
|
--text-primary: #e0e0e0;
|
||||||
|
--text-secondary: #a0a0a0;
|
||||||
|
--border-color: rgba(255, 255, 255, 0.1);
|
||||||
|
--success: #28a745;
|
||||||
|
--error: #ef4444;
|
||||||
|
--spinner-track: #4a4a4a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="light"] {
|
||||||
|
--bg-primary: #f5f5f5;
|
||||||
|
--bg-secondary: #fdfdfd;
|
||||||
|
--text-primary: #000;
|
||||||
|
--text-secondary: #666;
|
||||||
|
--border-color: rgba(0, 0, 0, 0.1);
|
||||||
|
--success: #28a745;
|
||||||
|
--error: #dc3545;
|
||||||
|
--spinner-track: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="dark"] {
|
||||||
|
--bg-primary: #1a1a1a;
|
||||||
|
--bg-secondary: #2d2d2d;
|
||||||
|
--text-primary: #e0e0e0;
|
||||||
|
--text-secondary: #a0a0a0;
|
||||||
|
--border-color: rgba(255, 255, 255, 0.1);
|
||||||
|
--success: #28a745;
|
||||||
|
--error: #ef4444;
|
||||||
|
--spinner-track: #4a4a4a;
|
||||||
|
}
|
||||||
|
|
||||||
/* CSS Reset */
|
/* CSS Reset */
|
||||||
*,
|
*,
|
||||||
*::before,
|
*::before,
|
||||||
|
|
@ -46,16 +93,17 @@ body {
|
||||||
font-family: system-ui;
|
font-family: system-ui;
|
||||||
max-width: 50rem;
|
max-width: 50rem;
|
||||||
margin: 1.25rem auto;
|
margin: 1.25rem auto;
|
||||||
padding: 1.25rem;
|
padding: 0 1.25rem 1.25rem;
|
||||||
background: #f5f5f5;
|
background: var(--bg-primary);
|
||||||
|
color: var(--text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
background: white;
|
background: var(--bg-secondary);
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
padding: 1.25rem;
|
padding: 1.25rem;
|
||||||
margin-bottom: 1.25rem;
|
margin-bottom: 1.25rem;
|
||||||
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.1);
|
box-shadow: 0 0.125rem 0.25rem var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
|
|
@ -87,16 +135,18 @@ h2 {
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
background: #333;
|
background: var(--bg-secondary);
|
||||||
color: white;
|
color: var(--text-primary);
|
||||||
padding: 0.375rem 0.625rem;
|
padding: 0.375rem 0.625rem;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
transition: opacity 0.2s;
|
transition: opacity 0.2s;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-item .tooltip::after {
|
.status-item .tooltip::after {
|
||||||
|
|
@ -106,7 +156,7 @@ h2 {
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
border: 0.3125rem solid transparent;
|
border: 0.3125rem solid transparent;
|
||||||
border-top-color: #333;
|
border-top-color: var(--bg-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-item:hover .tooltip {
|
.status-item:hover .tooltip {
|
||||||
|
|
@ -114,14 +164,33 @@ h2 {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.theme-toggle {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 1.5rem;
|
||||||
|
right: 1.5rem;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
padding: 0;
|
||||||
|
line-height: 1;
|
||||||
|
opacity: 0.4;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-toggle:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
.status-ok {
|
.status-ok {
|
||||||
background: #d4edda;
|
background: var(--success);
|
||||||
color: #155724;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-error {
|
.status-error {
|
||||||
background: #f8d7da;
|
background: var(--error);
|
||||||
color: #721c24;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.endpoint-list {
|
.endpoint-list {
|
||||||
|
|
@ -135,7 +204,7 @@ h2 {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.5rem 0.75rem;
|
padding: 0.5rem 0.75rem;
|
||||||
background: #f8f9fa;
|
background: var(--bg-primary);
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
margin-bottom: 0.375rem;
|
margin-bottom: 0.375rem;
|
||||||
}
|
}
|
||||||
|
|
@ -147,29 +216,31 @@ h2 {
|
||||||
|
|
||||||
.btn-delete {
|
.btn-delete {
|
||||||
padding: 0.375rem 0.75rem;
|
padding: 0.375rem 0.75rem;
|
||||||
background: #dc3545;
|
background: var(--error);
|
||||||
color: white;
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transition: filter 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-delete:hover {
|
.btn-delete:hover {
|
||||||
background: #c82333;
|
filter: brightness(0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-cancel {
|
.btn-cancel {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
padding: 0.5rem 1rem;
|
padding: 0.5rem 1rem;
|
||||||
background: #6c757d;
|
background: var(--text-secondary);
|
||||||
color: white;
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transition: filter 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-cancel:hover {
|
.btn-cancel:hover {
|
||||||
background: #5a6268;
|
filter: brightness(0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
.unlink-details {
|
.unlink-details {
|
||||||
|
|
@ -211,21 +282,22 @@ h2 {
|
||||||
.link-button {
|
.link-button {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 0.625rem 1.25rem;
|
padding: 0.625rem 1.25rem;
|
||||||
background: #8159b8;
|
background: var(--accent);
|
||||||
color: white;
|
color: white;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
margin-top: 0.625rem;
|
margin-top: 0.625rem;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transition: filter 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.link-button:hover {
|
.link-button:hover {
|
||||||
background: #6b4a99;
|
filter: brightness(0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading {
|
.loading {
|
||||||
color: #666;
|
color: var(--text-secondary);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
|
@ -234,8 +306,8 @@ h2 {
|
||||||
.spinner {
|
.spinner {
|
||||||
width: 1.25rem;
|
width: 1.25rem;
|
||||||
height: 1.25rem;
|
height: 1.25rem;
|
||||||
border: 0.125rem solid #e0e0e0;
|
border: 0.125rem solid var(--spinner-track);
|
||||||
border-top-color: #8159b8;
|
border-top-color: var(--accent);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
animation: spin 0.8s linear infinite;
|
animation: spin 0.8s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
@ -248,6 +320,6 @@ h2 {
|
||||||
|
|
||||||
.loading-subtitle {
|
.loading-subtitle {
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
color: #666;
|
color: var(--text-secondary);
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,11 @@
|
||||||
<link rel="manifest" href="/manifest.json">
|
<link rel="manifest" href="/manifest.json">
|
||||||
<link rel="stylesheet" href="/index.css">
|
<link rel="stylesheet" href="/index.css">
|
||||||
<script src="/htmx.min.js"></script>
|
<script src="/htmx.min.js"></script>
|
||||||
|
<script src="/theme.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<button id="theme-toggle" class="theme-toggle"></button>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div id="health-status"
|
<div id="health-status"
|
||||||
hx-get="/fragment/health"
|
hx-get="/fragment/health"
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,6 @@
|
||||||
"src": "/favicon.webp",
|
"src": "/favicon.webp",
|
||||||
"sizes": "32x32",
|
"sizes": "32x32",
|
||||||
"type": "image/webp",
|
"type": "image/webp",
|
||||||
"purpose": "any"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "/icon-512.webp",
|
|
||||||
"sizes": "512x512",
|
|
||||||
"type": "image/webp",
|
|
||||||
"purpose": "any maskable"
|
"purpose": "any maskable"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
43
server/public/theme.js
Normal file
43
server/public/theme.js
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
const themes = ['system', 'light', 'dark'];
|
||||||
|
let currentIndex = 0;
|
||||||
|
|
||||||
|
const savedTheme = localStorage.getItem('theme') || 'system';
|
||||||
|
currentIndex = themes.indexOf(savedTheme);
|
||||||
|
if (currentIndex === -1) currentIndex = 0;
|
||||||
|
|
||||||
|
function applyTheme(theme) {
|
||||||
|
if (theme === 'system') {
|
||||||
|
document.documentElement.removeAttribute('data-theme');
|
||||||
|
} else {
|
||||||
|
document.documentElement.setAttribute('data-theme', theme);
|
||||||
|
}
|
||||||
|
localStorage.setItem('theme', theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.cycleTheme = () => {
|
||||||
|
currentIndex = (currentIndex + 1) % themes.length;
|
||||||
|
const newTheme = themes[currentIndex];
|
||||||
|
applyTheme(newTheme);
|
||||||
|
updateButtonText(newTheme);
|
||||||
|
};
|
||||||
|
|
||||||
|
function updateButtonText(theme) {
|
||||||
|
const btn = document.getElementById('theme-toggle');
|
||||||
|
if (btn) {
|
||||||
|
btn.textContent = theme === 'system' ? '🌓' : theme === 'light' ? '☀️' : '🌙';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
applyTheme(savedTheme);
|
||||||
|
|
||||||
|
if (document.readyState === 'loading') {
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
updateButtonText(themes[currentIndex]);
|
||||||
|
const btn = document.getElementById('theme-toggle');
|
||||||
|
if (btn) btn.addEventListener('click', window.cycleTheme);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
updateButtonText(themes[currentIndex]);
|
||||||
|
const btn = document.getElementById('theme-toggle');
|
||||||
|
if (btn) btn.addEventListener('click', window.cycleTheme);
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue