Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 64 additions & 5 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,29 @@ fn write_landing_page(site: &Path) {
<title>Rust Training Books</title>
<style>
:root {{
--bg: #f6f8fb;
--card-bg: #ffffff;
--accent: #c2410c;
--text: #1f2937;
--muted: #5f6b7a;
--border: rgba(15, 23, 42, 0.08);
--border-hover: rgba(15, 23, 42, 0.14);
--shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
--clr-bridge: #16a34a;
--clr-deep-dive: #0891b2;
--clr-advanced: #d97706;
--clr-expert: #9333ea;
--clr-practices: #0f766e;
}}
html[data-theme="dark"] {{
--bg: #1a1a2e;
--card-bg: #16213e;
--accent: #e94560;
--text: #eee;
--muted: #a8a8b3;
--border: rgba(255,255,255,0.05);
--border-hover: rgba(255,255,255,0.1);
--shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
--clr-bridge: #4ade80;
--clr-deep-dive: #22d3ee;
--clr-advanced: #fbbf24;
Expand All @@ -223,6 +241,26 @@ fn write_landing_page(site: &Path) {
flex-direction: column;
align-items: center;
padding: 3rem 1rem;
transition: background-color 0.2s ease, color 0.2s ease;
}}
.theme-toggle {{
position: fixed;
top: 1rem;
right: 1rem;
border: 1px solid var(--border);
background: var(--card-bg);
color: var(--text);
border-radius: 999px;
padding: 0.45rem 0.8rem;
font: inherit;
font-size: 0.85rem;
cursor: pointer;
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}}
.theme-toggle:hover {{ border-color: var(--border-hover); }}
.theme-toggle:focus-visible {{
outline: 2px solid var(--accent);
outline-offset: 2px;
}}
h1 {{ font-size: 2.5rem; margin-bottom: 0.5rem; }}
h1 span {{ color: var(--accent); }}
Expand Down Expand Up @@ -253,14 +291,14 @@ fn write_landing_page(site: &Path) {
padding: 1.5rem 1.5rem 1.5rem 1.25rem;
text-decoration: none;
color: var(--text);
transition: transform 0.15s, box-shadow 0.15s;
border: 1px solid rgba(255,255,255,0.05);
transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background-color 0.2s ease;
border: 1px solid var(--border);
border-left: 4px solid var(--stripe);
}}
.card:hover {{
transform: translateY(-4px);
box-shadow: 0 8px 25px color-mix(in srgb, var(--stripe) 30%, transparent);
border-color: rgba(255,255,255,0.08);
box-shadow: var(--shadow);
border-color: var(--border-hover);
border-left-color: var(--stripe);
}}
.card h2 {{ font-size: 1.2rem; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }}
Expand All @@ -278,13 +316,14 @@ fn write_landing_page(site: &Path) {
font-size: 0.55rem; font-weight: 700; letter-spacing: 0.08em;
text-transform: uppercase; padding: 0.15em 0.55em;
border-radius: 4px; white-space: nowrap; flex-shrink: 0;
color: var(--bg); background: var(--stripe);
color: #fff; background: var(--stripe);
}}

footer {{ margin-top: 3rem; color: var(--muted); font-size: 0.85rem; }}
</style>
</head>
<body>
<button class="theme-toggle" type="button" id="theme-toggle" aria-label="Switch to dark theme">Dark theme</button>
<h1>🦀 <span>Rust</span> Training Books</h1>
<p class="subtitle">Pick the guide that matches your background</p>

Expand All @@ -300,6 +339,26 @@ fn write_landing_page(site: &Path) {
{cards}
</div>
<footer>Built with <a href="https://rust-lang.github.io/mdBook/" style="color:var(--accent)">mdBook</a></footer>
<script>
(() => {{
const key = "rust-training-theme";
const root = document.documentElement;
const button = document.getElementById("theme-toggle");
const apply = (theme) => {{
const dark = theme === "dark";
root.dataset.theme = dark ? "dark" : "light";
button.textContent = dark ? "Light theme" : "Dark theme";
button.setAttribute("aria-label", dark ? "Switch to light theme" : "Switch to dark theme");
}};
const stored = localStorage.getItem(key);
apply(stored === "dark" ? "dark" : "light");
button.addEventListener("click", () => {{
const next = root.dataset.theme === "dark" ? "light" : "dark";
localStorage.setItem(key, next);
apply(next);
}});
}})();
</script>
</body>
</html>
"##
Expand Down