commit 8f1288c2
Updated styling
Changed files
| M | static/app.js before |
| M | static/style.css before |
| M | templates/master.tmpl before |
diff --git a/static/app.js b/static/app.js
index 9ad04e4..20a3d0e 100644
--- a/static/app.js
+++ b/static/app.js
@@ -103,10 +103,38 @@
});
}
+ // Light/dark theme toggle. The effective theme is applied to the document
+ // by an inline script in <head> before first paint; here we only reflect it
+ // in the button and let the user switch and persist a choice.
+ function setupThemeToggle() {
+ var btn = document.querySelector(".theme-toggle");
+ if (!btn) return;
+ var root = document.documentElement;
+
+ function current() {
+ return root.getAttribute("data-theme") === "dark" ? "dark" : "light";
+ }
+ function render() {
+ var dark = current() === "dark";
+ btn.textContent = dark ? "☀️" : "🌙"; // sun / moon
+ btn.setAttribute("aria-label", "Switch to " + (dark ? "light" : "dark") + " theme");
+ btn.setAttribute("aria-pressed", dark ? "true" : "false");
+ }
+
+ render();
+ btn.addEventListener("click", function () {
+ var next = current() === "dark" ? "light" : "dark";
+ root.setAttribute("data-theme", next);
+ try { localStorage.setItem("theme", next); } catch (e) { /* private mode: no persistence */ }
+ render();
+ });
+ }
+
document.addEventListener("DOMContentLoaded", function () {
highlight();
renderMarkdown();
setupLogToggle();
setupViewToggle();
+ setupThemeToggle();
});
})();
diff --git a/static/style.css b/static/style.css
index 0ed38b1..08420e1 100644
--- a/static/style.css
+++ b/static/style.css
@@ -1,10 +1,56 @@
:root {
--bg: #ffffff;
+ --bg-subtle: #f6f8fa;
--fg: #1f2328;
--muted: #656d76;
--border: #d0d7de;
+ --border-subtle: #eaeef2;
--link: #0969da;
--code-bg: #f6f8fa;
+ --accent-soft: #ddf4ff;
+ --row-hover: #f6f8fa;
+ --shadow: 0 1px 3px rgba(27, 31, 36, 0.08), 0 0 1px rgba(27, 31, 36, 0.12);
+ --diff-add: #e6ffec;
+ --diff-del: #ffebe9;
+ --radius: 8px;
+}
+
+/* Explicit dark theme (chosen via the top-bar toggle, persisted in
+ localStorage and applied by an inline script before first paint). */
+:root[data-theme="dark"] {
+ --bg: #0d1117;
+ --bg-subtle: #161b22;
+ --fg: #e6edf3;
+ --muted: #8b949e;
+ --border: #30363d;
+ --border-subtle: #21262d;
+ --link: #4493f8;
+ --code-bg: #161b22;
+ --accent-soft: #163356;
+ --row-hover: #161b22;
+ --shadow: 0 1px 3px rgba(1, 4, 9, 0.5), 0 0 1px rgba(1, 4, 9, 0.6);
+ --diff-add: #12261e;
+ --diff-del: #25171c;
+}
+
+/* Fallback for clients without JS: follow the OS preference when no
+ explicit choice has been recorded on the document. */
+@media (prefers-color-scheme: dark) {
+ :root:not([data-theme]) {
+ --bg: #0d1117;
+ --bg-subtle: #161b22;
+ --fg: #e6edf3;
+ --muted: #8b949e;
+ --border: #30363d;
+ --border-subtle: #21262d;
+ --link: #4493f8;
+ --code-bg: #161b22;
+ --accent-soft: #163356;
+ --row-hover: #161b22;
+ --shadow: 0 1px 3px rgba(1, 4, 9, 0.5), 0 0 1px rgba(1, 4, 9, 0.6);
+ --diff-add: #12261e;
+ --diff-del: #25171c;
+ }
}
* { box-sizing: border-box; }
@@ -14,7 +60,8 @@ body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
color: var(--fg);
background: var(--bg);
- line-height: 1.5;
+ line-height: 1.55;
+ -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
@@ -23,87 +70,210 @@ a:hover { text-decoration: underline; }
.topbar {
display: flex;
align-items: center;
- gap: 0.75rem;
- padding: 0.75rem 1.25rem;
+ gap: 1rem;
+ padding: 0.75rem 1.5rem;
border-bottom: 1px solid var(--border);
- background: var(--code-bg);
+ background: var(--bg-subtle);
+ position: sticky;
+ top: 0;
+ z-index: 10;
+ backdrop-filter: saturate(1.2);
+}
+.topbar a { color: var(--fg); }
+.topbar .brand {
+ font-weight: 700;
+ display: inline-flex;
+ align-items: center;
+ gap: 0.4rem;
+}
+.topbar .brand::before {
+ content: "";
+ display: inline-block;
+ width: 1.1rem;
+ height: 1.1rem;
+ background: var(--link);
+ -webkit-mask: no-repeat center / contain
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M15.7 7.3 8.7.3a1 1 0 0 0-1.4 0L5.8 1.8l1.9 1.9a1.2 1.2 0 0 1 1.5 1.5l1.8 1.8a1.2 1.2 0 1 1-.7.7L8.6 6a1.2 1.2 0 0 1-.3.2v4.3a1.2 1.2 0 1 1-1 0V6.2a1.2 1.2 0 0 1-.6-1.6L4.8 2.7.3 7.3a1 1 0 0 0 0 1.4l7 7a1 1 0 0 0 1.4 0l7-7a1 1 0 0 0 0-1.4Z'/%3E%3C/svg%3E");
+ mask: no-repeat center / contain
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M15.7 7.3 8.7.3a1 1 0 0 0-1.4 0L5.8 1.8l1.9 1.9a1.2 1.2 0 0 1 1.5 1.5l1.8 1.8a1.2 1.2 0 1 1-.7.7L8.6 6a1.2 1.2 0 0 1-.3.2v4.3a1.2 1.2 0 1 1-1 0V6.2a1.2 1.2 0 0 1-.6-1.6L4.8 2.7.3 7.3a1 1 0 0 0 0 1.4l7 7a1 1 0 0 0 1.4 0l7-7a1 1 0 0 0 0-1.4Z'/%3E%3C/svg%3E");
}
-.topbar .brand { font-weight: 700; }
.topbar .sep { color: var(--muted); }
-.topbar .repo-nav { margin-left: auto; display: flex; gap: 1rem; }
+.topbar .repo-nav { margin-left: auto; display: flex; gap: 0.25rem; }
+.topbar .repo-nav a {
+ padding: 0.25rem 0.6rem;
+ border-radius: 6px;
+ color: var(--muted);
+}
+.topbar .repo-nav a:hover { background: var(--row-hover); color: var(--fg); text-decoration: none; }
+.theme-toggle {
+ background: transparent;
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ padding: 0.25rem 0.55rem;
+ font-size: 1rem;
+ line-height: 1;
+ cursor: pointer;
+ color: var(--fg);
+}
+.theme-toggle:hover { border-color: var(--link); }
+.theme-toggle.push { margin-left: auto; }
-main { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1.25rem; }
+main { max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem; }
-h1 { font-size: 1.4rem; word-break: break-all; }
+h1 { font-size: 1.5rem; word-break: break-all; margin-top: 0; }
+h2 { font-size: 1.15rem; }
.meta, .actions, .tags { color: var(--muted); font-size: 0.9rem; }
-.actions a { font-size: 0.9rem; }
-.tags a { display: inline-block; padding: 0 0.4rem; border: 1px solid var(--muted); border-radius: 3px; }
-.commit-notice { color: var(--muted); font-size: 0.9rem; font-family: monospace; }
+.actions { display: flex; flex-wrap: wrap; gap: 0.25rem 0.6rem; align-items: center; }
+.actions a {
+ font-size: 0.85rem;
+ padding: 0.15rem 0.55rem;
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ color: var(--fg);
+}
+.actions a:hover { background: var(--row-hover); text-decoration: none; }
+.tags a {
+ display: inline-block;
+ padding: 0.1rem 0.5rem;
+ margin: 0.1rem 0.15rem 0.1rem 0;
+ border: 1px solid var(--border);
+ border-radius: 999px;
+ font-size: 0.8rem;
+ background: var(--bg-subtle);
+}
+.tags a:hover { border-color: var(--link); text-decoration: none; }
+.commit-notice {
+ color: var(--muted);
+ font-size: 0.85rem;
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
+ background: var(--accent-soft);
+ border-radius: 6px;
+ padding: 0.35rem 0.6rem;
+ display: inline-block;
+}
-.repo-list { list-style: none; padding: 0; }
-.repo-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
+.repo-list { list-style: none; padding: 0; margin: 1rem 0; }
+.repo-list li {
+ padding: 0;
+ border: none;
+}
+.repo-list li a {
+ display: block;
+ padding: 0.7rem 0.9rem;
+ border: 1px solid var(--border);
+ border-radius: var(--radius);
+ margin-bottom: 0.5rem;
+ font-weight: 600;
+ transition: border-color 0.1s ease, background 0.1s ease;
+}
+.repo-list li a::before { content: "\1F4C1"; margin-right: 0.5rem; }
+.repo-list li a:hover { border-color: var(--link); background: var(--row-hover); text-decoration: none; }
table { width: 100%; border-collapse: collapse; }
-table.tree td, table.log td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); }
+table.tree, table.log {
+ border: 1px solid var(--border);
+ border-radius: var(--radius);
+ overflow: hidden;
+ margin-top: 1rem;
+}
+table.tree td, table.log td {
+ padding: 0.5rem 0.75rem;
+ border-bottom: 1px solid var(--border-subtle);
+}
+table.tree tr:last-child td, table.log tr:last-child td { border-bottom: none; }
+table.tree tr:hover td, table.log tr:hover td { background: var(--row-hover); }
table.tree .size, table.log .date, table.log .author { color: var(--muted); white-space: nowrap; }
table.tree .size { text-align: right; }
-.log-controls { margin: 0 0 0.75rem; }
-.log-toggle { font-size: 0.85rem; color: var(--fg); background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.25rem 0.6rem; cursor: pointer; }
-.log-toggle[aria-pressed="true"] { border-color: var(--link); color: var(--link); }
-.commit-body { margin: 0.5rem 0 0; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
+table.tree .name a.dir::before { content: "\1F4C1"; margin-right: 0.4rem; }
+
+.log-controls, .tree-controls { margin: 0 0 0.25rem; }
+.log-toggle, .view-toggle {
+ font-size: 0.85rem;
+ color: var(--fg);
+ background: var(--bg-subtle);
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ padding: 0.3rem 0.7rem;
+ cursor: pointer;
+ transition: border-color 0.1s ease, color 0.1s ease;
+}
+.log-toggle:hover, .view-toggle:hover { border-color: var(--link); }
+.log-toggle[aria-pressed="true"], .view-toggle[aria-pressed="true"] { border-color: var(--link); color: var(--link); }
+.commit-body { margin: 0.5rem 0 0; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; color: var(--muted); }
.dir { font-weight: 600; }
.submodule { color: var(--muted); }
-.tree-controls { margin: 0 0 0.75rem; }
-.view-toggle { font-size: 0.85rem; color: var(--fg); background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0.25rem 0.6rem; cursor: pointer; }
-.view-toggle[aria-pressed="true"] { border-color: var(--link); color: var(--link); }
-
-.tree-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
+.tree-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.tree-grid[hidden] { display: none; }
-.tree-grid .tile { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0.4rem; padding: 0.6rem; border: 1px solid var(--border); border-radius: 6px; text-align: center; word-break: break-word; }
+.tree-grid .tile {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: flex-end;
+ gap: 0.4rem;
+ padding: 0.75rem;
+ border: 1px solid var(--border);
+ border-radius: var(--radius);
+ text-align: center;
+ word-break: break-word;
+ color: var(--fg);
+ transition: border-color 0.1s ease, background 0.1s ease;
+}
+a.tile:hover { border-color: var(--link); background: var(--row-hover); text-decoration: none; }
.tree-grid .tile-icon { font-size: 1.8rem; line-height: 1; }
.tree-grid .tile-name { font-size: 0.85rem; }
-.tree-grid img.thumb { max-width: 100%; max-height: 120px; object-fit: contain; }
+.tree-grid img.thumb { max-width: 100%; max-height: 120px; object-fit: contain; border-radius: 4px; }
pre.code {
background: var(--code-bg);
border: 1px solid var(--border);
- border-radius: 6px;
+ border-radius: var(--radius);
padding: 1rem;
overflow-x: auto;
}
pre.code code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
+.hljs { background: transparent; }
.checkout {
border: 1px solid var(--border);
- border-radius: 6px;
+ border-radius: var(--radius);
padding: 1rem 1.5rem;
- margin-top: 1rem;
+ margin-top: 1.5rem;
+ background: var(--bg-subtle);
+ box-shadow: var(--shadow);
}
-.checkout h2 { font-size: 1rem; margin: 0 0 0.5rem; }
-.checkout .clone-line { margin: 0.35rem 0; }
-.checkout .clone-label { display: inline-block; width: 3.5rem; color: var(--muted); font-size: 0.85rem; }
+.checkout h2 { font-size: 1rem; margin: 0 0 0.75rem; }
+.checkout .clone-line { margin: 0.4rem 0; }
+.checkout .clone-label { display: inline-block; width: 5rem; color: var(--muted); font-size: 0.85rem; }
.checkout code {
- background: var(--code-bg);
+ background: var(--bg);
border: 1px solid var(--border);
- border-radius: 4px;
- padding: 0.15rem 0.4rem;
+ border-radius: 6px;
+ padding: 0.25rem 0.5rem;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.85rem;
}
.readme {
border: 1px solid var(--border);
- border-radius: 6px;
- padding: 1.5rem;
- margin-top: 1rem;
+ border-radius: var(--radius);
+ padding: 1.75rem 2rem;
+ margin-top: 1.5rem;
+ box-shadow: var(--shadow);
}
-.readme pre { background: var(--code-bg); padding: 1rem; border-radius: 6px; overflow-x: auto; }
-.readme code { background: var(--code-bg); padding: 0.1rem 0.3rem; border-radius: 4px; }
+.readme > :first-child { margin-top: 0; }
+.readme h1, .readme h2 { border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.3rem; }
+.readme pre { background: var(--code-bg); padding: 1rem; border-radius: var(--radius); overflow-x: auto; }
+.readme code { background: var(--code-bg); padding: 0.15rem 0.35rem; border-radius: 4px; font-size: 0.9em; }
.readme pre code { background: none; padding: 0; }
+.readme img { max-width: 100%; }
+.readme table { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 1rem 0; }
+.readme th, .readme td { padding: 0.4rem 0.75rem; border: 1px solid var(--border-subtle); }
+.readme blockquote { margin: 1rem 0; padding: 0 1rem; color: var(--muted); border-left: 3px solid var(--border); }
-table.blame { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }
+table.blame { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.blame td { padding: 0 0.5rem; border: none; vertical-align: top; }
+table.blame tr:hover td { background: var(--row-hover); }
table.blame .commit { color: var(--link); }
table.blame .author { color: var(--muted); white-space: nowrap; }
table.blame .lineno { color: var(--muted); text-align: right; user-select: none; }
@@ -111,22 +281,48 @@ table.blame .line pre { margin: 0; white-space: pre; }
.log .msg { width: 100%; }
.binary { color: var(--muted); }
-.lang-detected { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; }
-.fileimg img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--code-bg); }
+.lang-detected { color: var(--muted); font-size: 0.8rem; margin-top: 0.35rem; }
+.fileimg img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--code-bg); }
table.tree .status { font-family: ui-monospace, monospace; color: var(--muted); width: 1.5rem; }
table.tree .before { margin-left: 0.5rem; font-size: 0.8rem; color: var(--muted); }
.diff {
border: 1px solid var(--border);
- border-radius: 6px;
+ border-radius: var(--radius);
overflow-x: auto;
margin-top: 1rem;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.82rem;
}
.diff > div { white-space: pre; padding: 0 0.5rem; min-height: 1.2em; }
-.diff .d-add { background: #e6ffec; }
-.diff .d-del { background: #ffebe9; }
-.diff .d-hunk { background: var(--code-bg); color: var(--muted); }
-.diff .d-file { background: var(--code-bg); font-weight: 600; }
+.diff .d-add { background: var(--diff-add); }
+.diff .d-del { background: var(--diff-del); }
+.diff .d-hunk { background: var(--bg-subtle); color: var(--muted); }
+.diff .d-file { background: var(--bg-subtle); font-weight: 600; }
+
+:root[data-theme="dark"] .hljs-doctag, :root[data-theme="dark"] .hljs-keyword,
+:root[data-theme="dark"] .hljs-meta .hljs-keyword, :root[data-theme="dark"] .hljs-template-tag,
+:root[data-theme="dark"] .hljs-template-variable, :root[data-theme="dark"] .hljs-type,
+:root[data-theme="dark"] .hljs-variable.language_ { color: #ff7b72; }
+:root[data-theme="dark"] .hljs-title, :root[data-theme="dark"] .hljs-title.class_,
+:root[data-theme="dark"] .hljs-title.class_.inherited__, :root[data-theme="dark"] .hljs-title.function_ { color: #d2a8ff; }
+:root[data-theme="dark"] .hljs-attr, :root[data-theme="dark"] .hljs-attribute,
+:root[data-theme="dark"] .hljs-literal, :root[data-theme="dark"] .hljs-meta,
+:root[data-theme="dark"] .hljs-number, :root[data-theme="dark"] .hljs-operator,
+:root[data-theme="dark"] .hljs-selector-attr, :root[data-theme="dark"] .hljs-selector-class,
+:root[data-theme="dark"] .hljs-selector-id, :root[data-theme="dark"] .hljs-variable { color: #79c0ff; }
+:root[data-theme="dark"] .hljs-meta .hljs-string, :root[data-theme="dark"] .hljs-regexp,
+:root[data-theme="dark"] .hljs-string { color: #a5d6ff; }
+:root[data-theme="dark"] .hljs-built_in, :root[data-theme="dark"] .hljs-symbol { color: #ffa657; }
+:root[data-theme="dark"] .hljs-code, :root[data-theme="dark"] .hljs-comment,
+:root[data-theme="dark"] .hljs-formula { color: #8b949e; }
+:root[data-theme="dark"] .hljs-name, :root[data-theme="dark"] .hljs-quote,
+:root[data-theme="dark"] .hljs-selector-pseudo, :root[data-theme="dark"] .hljs-selector-tag { color: #7ee787; }
+:root[data-theme="dark"] .hljs-subst { color: #e6edf3; }
+:root[data-theme="dark"] .hljs-section { color: #1f6feb; font-weight: 700; }
+:root[data-theme="dark"] .hljs-bullet { color: #f2cc60; }
+:root[data-theme="dark"] .hljs-emphasis { color: #e6edf3; font-style: italic; }
+:root[data-theme="dark"] .hljs-strong { color: #e6edf3; font-weight: 700; }
+:root[data-theme="dark"] .hljs-addition { color: #aff5b4; background-color: #033a16; }
+:root[data-theme="dark"] .hljs-deletion { color: #ffdcd7; background-color: #67060c; }
diff --git a/templates/master.tmpl b/templates/master.tmpl
index 0fc5a8f..6622685 100644
--- a/templates/master.tmpl
+++ b/templates/master.tmpl
@@ -9,8 +9,9 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= title %> · git</title>
-<link rel="stylesheet" href="/static/style.css">
+<script>(function(){try{var t=localStorage.getItem("theme");if(t!=="light"&&t!=="dark")t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";document.documentElement.setAttribute("data-theme",t);}catch(e){}})();</script>
<link rel="stylesheet" href="/static/highlight.css">
+<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<header class="topbar">
@@ -29,6 +30,7 @@
<a href="/repos/<%= repo %>/tags/">tags</a>
</nav>
<% end %>
+<button type="button" class="theme-toggle<% if (content.repo.length() == 0) %> push<% end %>" aria-label="Toggle theme">🌙</button>
</header>
<main><% include content_body() %></main>
<script src="/static/highlight.min.js"></script>