Skip to content

Commit 9d14912

Browse files
committed
revise: sidebar refactoring
1 parent 0269f0c commit 9d14912

File tree

4 files changed

+60
-14
lines changed

4 files changed

+60
-14
lines changed

Diff for: wdl-doc/src/docs_tree.rs

+20-8
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl DocsTree {
253253
/// rendered. If the node does not have a page associated with it, the
254254
/// name of the node will be rendered. All links will be relative to the
255255
/// given path.
256-
pub fn render_sidebar_component<P: AsRef<Path>>(&self, path: P) -> Markup {
256+
pub fn render_left_sidebar<P: AsRef<Path>>(&self, path: P) -> Markup {
257257
fn sidebar_recurse(node: &Node, base: &Path) -> Markup {
258258
html! {
259259
@if let Some(page) = node.page() {
@@ -280,7 +280,7 @@ impl DocsTree {
280280
let base = path.as_ref().parent().unwrap();
281281

282282
html! {
283-
div class="top-0 border left-0 h-full w-1/6 p-4 dark:bg-slate-900 dark:text-white" {
283+
div class="top-0 border h-fit left-0 min-w-[280px] w-[280px] p-4 dark:bg-slate-900 dark:text-white overflow-x-scroll" {
284284
h1 class="text-2xl text-center" { "Sidebar" }
285285
p class="" { (root.name()) }
286286
ul class="" {
@@ -297,6 +297,16 @@ impl DocsTree {
297297
}
298298
}
299299

300+
/// Render a right sidebar component.
301+
pub fn render_right_sidebar(&self) -> Markup {
302+
html! {
303+
div class="top-0 border h-screen sticky right-0 min-w-[240px] w-[240px] p-4 bottom-4 object-right dark:bg-red-900 dark:text-white" {
304+
h1 class="text-2xl text-center" { "Sidebar" }
305+
p class="" { "Right Sidebar" }
306+
}
307+
}
308+
}
309+
300310
/// Render every page in the tree.
301311
pub fn render_all(&self) -> anyhow::Result<()> {
302312
let root = self.root();
@@ -316,7 +326,7 @@ impl DocsTree {
316326
let root = self.root();
317327
let index_path = root.path().join("index.html");
318328

319-
let sidebar = self.render_sidebar_component(&index_path);
329+
let left_sidebar = self.render_left_sidebar(&index_path);
320330
let content = html! {
321331
div class="" {
322332
h3 class="" { "Home" }
@@ -349,10 +359,11 @@ impl DocsTree {
349359
let html = full_page(
350360
"Home",
351361
html! {
352-
(sidebar)
353-
div class="p-4 items-center" {
362+
(left_sidebar)
363+
div class="p-4 flex" {
354364
(content)
355365
}
366+
(self.render_right_sidebar())
356367
},
357368
self.stylesheet_relative_to(root.path()).as_deref(),
358369
);
@@ -376,15 +387,16 @@ impl DocsTree {
376387

377388
let stylesheet =
378389
self.stylesheet_relative_to(path.parent().expect("path should have a parent"));
379-
let sidebar = self.render_sidebar_component(&path);
390+
let left_sidebar = self.render_left_sidebar(&path);
380391

381392
let html = full_page(
382393
page.name(),
383394
html! {
384-
(sidebar)
385-
div class="p-4" {
395+
(left_sidebar)
396+
div class="p-4 flex" {
386397
(content)
387398
}
399+
(self.render_right_sidebar())
388400
},
389401
stylesheet.as_deref(),
390402
);

Diff for: wdl-doc/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ pub(crate) fn full_page<P: AsRef<Path>>(
8484
) -> Markup {
8585
html! {
8686
(DOCTYPE)
87-
html class="dark size-full" {
87+
html class="dark" {
8888
(header(page_title, stylesheet))
89-
body class="flex dark size-full dark:bg-slate-950 dark:text-white p-4" {
89+
body class="flex size-full dark:bg-slate-950 dark:text-white p-4" {
9090
(body)
9191
}
9292
}

Diff for: wdl-doc/theme/dist/style.css

+37-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
--font-sans: "DM Sans";
66
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
77
"Courier New", monospace;
8+
--color-red-900: oklch(0.396 0.141 25.723);
89
--color-slate-900: oklch(0.208 0.042 265.755);
910
--color-slate-950: oklch(0.129 0.042 264.695);
1011
--color-white: #fff;
@@ -164,9 +165,18 @@
164165
.relative {
165166
position: relative !important;
166167
}
168+
.sticky {
169+
position: sticky !important;
170+
}
167171
.top-0 {
168172
top: calc(var(--spacing) * 0) !important;
169173
}
174+
.right-0 {
175+
right: calc(var(--spacing) * 0) !important;
176+
}
177+
.bottom-4 {
178+
bottom: calc(var(--spacing) * 4) !important;
179+
}
170180
.left-0 {
171181
left: calc(var(--spacing) * 0) !important;
172182
}
@@ -186,11 +196,23 @@
186196
width: 100% !important;
187197
height: 100% !important;
188198
}
189-
.h-full {
190-
height: 100% !important;
199+
.h-fit {
200+
height: fit-content !important;
201+
}
202+
.h-screen {
203+
height: 100vh !important;
204+
}
205+
.w-\[240px\] {
206+
width: 240px !important;
207+
}
208+
.w-\[280px\] {
209+
width: 280px !important;
191210
}
192-
.w-1\/6 {
193-
width: calc(1/6 * 100%) !important;
211+
.min-w-\[240px\] {
212+
min-width: 240px !important;
213+
}
214+
.min-w-\[280px\] {
215+
min-width: 280px !important;
194216
}
195217
.table-auto {
196218
table-layout: auto !important;
@@ -204,10 +226,16 @@
204226
.items-center {
205227
align-items: center !important;
206228
}
229+
.overflow-x-scroll {
230+
overflow-x: scroll !important;
231+
}
207232
.border {
208233
border-style: var(--tw-border-style) !important;
209234
border-width: 1px !important;
210235
}
236+
.object-right {
237+
object-position: right !important;
238+
}
211239
.p-4 {
212240
padding: calc(var(--spacing) * 4) !important;
213241
}
@@ -224,6 +252,11 @@
224252
font-size: var(--text-2xl) !important;
225253
line-height: var(--tw-leading, var(--text-2xl--line-height)) !important;
226254
}
255+
.dark\:bg-red-900 {
256+
&:where(.dark, .dark *) {
257+
background-color: var(--color-red-900) !important;
258+
}
259+
}
227260
.dark\:bg-slate-900 {
228261
&:where(.dark, .dark *) {
229262
background-color: var(--color-slate-900) !important;

Diff for: wdl-doc/theme/src/main.css

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/* Custom theme variables */
1111
@theme {
1212
--font-sans: "DM Sans";
13+
--sidebar-width: 280px;
1314
}
1415

1516
/* Scan Rust source code */

0 commit comments

Comments
 (0)