Skip to content

Commit ef17d06

Browse files
committed
(docs/ui): Add custom themes and CSS fixes
The book now has two custom themes. We also fixed how some elements are positioned/displayed to improve the UI.
1 parent 3682ddd commit ef17d06

File tree

7 files changed

+51
-12
lines changed

7 files changed

+51
-12
lines changed

docs/book/book.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ src = "src"
55
title = "The Kubebuilder Book"
66

77
[output.html]
8+
default-theme = "light"
9+
preferred-dark-theme = "navy"
810
smart-punctuation = true
911
additional-css = ["theme/css/markers.css", "theme/css/custom.css", "theme/css/version-dropdown.css"]
1012
git-repository-url = "https://github.com/kubernetes-sigs/kubebuilder"
@@ -21,4 +23,3 @@ command = "./markerdocs.sh"
2123

2224
[context.deploy-preview.environment]
2325
environment = { GO_VERSION = "1.23" }
24-

docs/book/src/logos/favicon.png

-2.75 KB
Binary file not shown.

docs/book/src/logos/kb-icon.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/book/src/logos/kb-logo-one-line.svg

Lines changed: 1 addition & 0 deletions
Loading
-4.17 KB
Binary file not shown.

docs/book/theme/css/custom.css

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,46 @@
1-
.menu-title img {
2-
vertical-align: bottom;
1+
/* Adds a thin border to the sidebar (aesthetics) */
2+
#sidebar {
3+
border-right: 1px solid var(--theme-popup-border);
34
}
45

5-
#sidebar-toggle-anchor:checked .page-wrapper {
6-
margin-inline-start: calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width));
6+
/* Sets the size of the logo on the menu bar */
7+
.large-logo-img {
8+
height: 50px;
9+
}
10+
11+
/* Centers the logo on the menu bar */
12+
.menu-title {
13+
display: flex;
14+
align-items: center; /* vertical centering */
15+
justify-content: center; /* horizontal centering */
16+
}
17+
18+
/* Fixes first header sliding under the menu bar when selected */
19+
.content {
20+
overflow-y: clip;
21+
}
22+
23+
/* Fixes contrast in codeblocks */
24+
pre > .hljs {
25+
border: 1px solid var(--theme-popup-border);
26+
border-radius: 6px;
27+
}
28+
29+
/* Fixes scrollbar background color */
30+
html {
31+
scrollbar-color: var(--scrollbar) transparent;
32+
}
33+
34+
/* Fixes links formatting */
35+
.content a {
36+
text-decoration: solid underline var(--links);
37+
}
38+
39+
/* custom light theme */
40+
.light {
41+
--sidebar-bg: #eef5ff;
42+
--sidebar-fg: #334155;
43+
--sidebar-non-existant: #7b8da8;
44+
--sidebar-active: #466bb3;
45+
--sidebar-spacer: #c9d3e0;
746
}

docs/book/theme/index.hbs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<meta name="viewport" content="width=device-width, initial-scale=1">
2222
<meta name="theme-color" content="#ffffff" />
2323

24-
<link rel="shortcut icon" href="{{ path_to_root }}/logos/favicon.png">
24+
<link rel="shortcut icon" href="{{ path_to_root }}/logos/kb-icon.svg">
2525
<link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
2626
<link rel="stylesheet" href="{{ path_to_root }}css/general.css">
2727
<link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
@@ -119,10 +119,7 @@
119119
</button>
120120
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
121121
<li role="none"><button role="menuitem" class="theme" id="light">{{ theme_option "Light" }}</button></li>
122-
<li role="none"><button role="menuitem" class="theme" id="rust">{{ theme_option "Rust" }}</button></li>
123-
<li role="none"><button role="menuitem" class="theme" id="coal">{{ theme_option "Coal" }}</button></li>
124-
<li role="none"><button role="menuitem" class="theme" id="navy">{{ theme_option "Navy" }}</button></li>
125-
<li role="none"><button role="menuitem" class="theme" id="ayu">{{ theme_option "Ayu" }}</button></li>
122+
<li role="none"><button role="menuitem" class="theme" id="navy">{{ theme_option "Dark" }}</button></li>
126123
</ul>
127124
{{#if search_enabled}}
128125
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
@@ -140,10 +137,10 @@
140137
<a href="https://book-v2.book.kubebuilder.io/"target="_blank" rel="noopener noreferrer">v2-book</a>
141138
<a href="https://book-v1.book.kubebuilder.io/"target="_blank" rel="noopener noreferrer">v1-book</a>
142139
</div>
143-
</div>
140+
</div>
144141
</div>
145142

146-
<h1 class="menu-title"><img alt="{{ book_title }}" src="{{ path_to_root }}/logos/logo-single-line.png"></h1>
143+
<h1 class="menu-title"><img alt="{{ book_title }}" class="large-logo-img" src="{{ path_to_root }}/logos/kb-logo-one-line.svg"></h1>
147144

148145
<div class="right-buttons">
149146
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">

0 commit comments

Comments
 (0)