Add app layout with sidebar and header

This commit is contained in:
Gogs
2026-07-06 21:35:19 +02:00
parent 79d0976b80
commit 52aa07ab98
11 changed files with 314 additions and 75 deletions
+199 -43
View File
@@ -1,89 +1,245 @@
:root {
--bg: #0f172a;
--panel: #111827;
--panel-2: #1f2937;
--panel-3: #273244;
--border: #334155;
--text: #f8fafc;
--muted: #94a3b8;
--accent: #3b82f6;
--accent-soft: rgba(59, 130, 246, 0.16);
--success: #22c55e;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: system-ui, sans-serif;
background: #101114;
color: #eee;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: var(--bg);
color: var(--text);
}
.topbar {
padding: 20px;
background: #181a20;
border-bottom: 1px solid #2b2f3a;
.app-shell {
min-height: 100vh;
display: grid;
grid-template-columns: 230px 1fr;
}
.sidebar {
background: #0b1120;
border-right: 1px solid var(--border);
padding: 24px 16px;
}
.sidebar-nav {
display: flex;
flex-direction: column;
gap: 8px;
}
.sidebar-nav a {
color: var(--muted);
text-decoration: none;
padding: 12px 14px;
border-radius: 12px;
font-weight: 600;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
color: var(--text);
background: var(--accent-soft);
}
.app-main {
min-width: 0;
}
.app-header {
height: 82px;
background: var(--panel);
border-bottom: 1px solid var(--border);
padding: 16px 28px;
display: flex;
align-items: center;
gap: 28px;
justify-content: space-between;
gap: 24px;
}
.topbar h1 {
margin: 0;
.brand-title {
font-size: 1.45rem;
font-weight: 800;
}
.topbar nav {
display: flex;
gap: 14px;
.brand-subtitle {
color: var(--muted);
font-size: 0.85rem;
margin-top: 2px;
}
.topbar a {
color: #cfd6e6;
text-decoration: none;
.search-box input {
width: min(360px, 40vw);
background: #020617;
color: var(--text);
border: 1px solid var(--border);
border-radius: 999px;
padding: 10px 16px;
}
main {
padding: 20px;
max-width: 1100px;
margin: 0 auto;
.content {
padding: 32px;
max-width: 1280px;
}
.channel {
margin-bottom: 28px;
background: #181a20;
border: 1px solid #2b2f3a;
border-radius: 16px;
margin-bottom: 24px;
background: var(--panel);
border: 1px solid var(--border);
border-radius: 18px;
overflow: hidden;
}
.channel-header {
padding: 14px 18px;
background: #20232c;
font-size: 1.25rem;
font-weight: 700;
padding: 16px 20px;
background: var(--panel-2);
font-size: 1.2rem;
font-weight: 800;
}
.programme {
padding: 14px 18px;
border-top: 1px solid #2b2f3a;
padding: 16px 20px;
border-top: 1px solid var(--border);
}
.programme-time {
color: #9da7bd;
color: var(--muted);
font-size: 0.95rem;
margin-bottom: 4px;
margin-bottom: 5px;
}
.programme-title {
font-size: 1.1rem;
font-weight: 700;
font-weight: 800;
}
.programme-desc {
color: #c9ced8;
margin-top: 6px;
color: #cbd5e1;
margin-top: 7px;
}
.category {
display: inline-block;
margin-top: 8px;
padding: 3px 8px;
margin-top: 10px;
padding: 4px 9px;
border-radius: 999px;
background: #303545;
color: #cfd6e6;
background: var(--panel-3);
color: #dbeafe;
font-size: 0.8rem;
}
.empty {
color: #aaa;
background: #181a20;
border: 1px solid #2b2f3a;
.empty,
.notice {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 16px;
padding: 18px;
}
.notice {
border-color: #15803d;
background: rgba(34, 197, 94, 0.12);
color: #dcfce7;
margin-bottom: 18px;
}
button {
background: var(--accent);
color: white;
border: 0;
border-radius: 10px;
padding: 10px 16px;
font-weight: 800;
cursor: pointer;
}
.settings-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 18px;
}
.settings-header h2 {
margin: 0;
}
.channels-table {
width: 100%;
border-collapse: collapse;
background: var(--panel);
border: 1px solid var(--border);
border-radius: 16px;
overflow: hidden;
}
.channels-table th,
.channels-table td {
padding: 12px;
border-bottom: 1px solid var(--border);
text-align: left;
}
.channels-table th {
background: var(--panel-2);
color: #cbd5e1;
}
.channels-table input[type="text"],
.channels-table input[type="number"] {
background: #020617;
color: var(--text);
border: 1px solid var(--border);
border-radius: 8px;
padding: 7px 9px;
}
.number-input {
width: 70px;
}
.channel-id {
color: var(--muted);
font-size: 0.8rem;
margin-top: 3px;
}
@media (max-width: 900px) {
.app-shell {
grid-template-columns: 1fr;
}
.sidebar {
border-right: 0;
border-bottom: 1px solid var(--border);
}
.sidebar-nav {
flex-direction: row;
overflow-x: auto;
}
.content {
padding: 20px;
}
.app-header {
padding: 14px 20px;
}
.search-box input {
width: 160px;
}
}
+33 -6
View File
@@ -1,10 +1,8 @@
<?php
require_once '/var/www/vendor/autoload.php';
use TVGuide\Config;
use TVGuide\XmlTv;
use TVGuide\View;
require_once '/var/www/src/Config.php';
require_once '/var/www/src/XmlTv.php';
require_once '/var/www/src/View.php';
$config = new Config(
'/var/www/config/config.json',
@@ -18,13 +16,42 @@ $xmltv = new XmlTv(
$xmltv->synchronizeChannels($config);
$view = $_GET['view'] ?? $config->get('default_view', 'today');
if ($view === 'channels' && $_SERVER['REQUEST_METHOD'] === 'POST') {
$savedChannels = $config->getChannels();
foreach ($savedChannels as $id => &$channel) {
$channel['enabled'] = isset($_POST['enabled'][$id]);
$channel['favorite'] = isset($_POST['favorite'][$id]);
$channel['number'] = (int)($_POST['number'][$id] ?? $channel['number'] ?? 999999);
$channel['group'] = trim($_POST['group'][$id] ?? $channel['group'] ?? 'Unknown');
}
unset($channel);
uasort($savedChannels, function ($a, $b) {
return ((int)($a['number'] ?? 999999)) <=> ((int)($b['number'] ?? 999999));
});
$config->saveChannels($savedChannels);
header('Location: /?view=channels&saved=1');
exit;
}
[$channels, $programmes] = $xmltv->load($config);
$contentTemplate = '/var/www/templates/home.php';
$contentTemplate = $view === 'channels'
? '/var/www/templates/channels.php'
: '/var/www/templates/home.php';
View::render('layout', [
'title' => $config->get('title', 'TVGuide'),
'channels' => $channels,
'programmes' => $programmes,
'contentTemplate' => $contentTemplate,
'view' => $view,
'channelConfig' => $config->getChannels(),
'saved' => isset($_GET['saved']),
]);