Content-Length: 739224 | pFad | https://github.com/postgresml/postgresml/commit/8788c2b3667ab3f83335e511a82a1d7001e8abec

C7 Make parent nav links clickable (#1064) · postgresml/postgresml@8788c2b · GitHub
Skip to content

Commit 8788c2b

Browse files
authored
Make parent nav links clickable (#1064)
1 parent 2ef3ddc commit 8788c2b

File tree

9 files changed

+41
-38
lines changed

9 files changed

+41
-38
lines changed

pgml-dashboard/src/api/docs.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,15 @@ async fn doc_handler(path: PathBuf, cluster: &Cluster) -> Result<ResponseOk, Sta
5353
let guides = markdown::parse_summary_into_nav_links(&mdast)
5454
.expect("could not extract nav links from table of contents");
5555

56-
render(cluster, &path, guides, "Guides", &Path::new("docs"), &config::docs_dir()).await
56+
render(
57+
cluster,
58+
&path,
59+
guides,
60+
"Guides",
61+
&Path::new("docs"),
62+
&config::docs_dir(),
63+
)
64+
.await
5765
}
5866

5967
#[get("/blog/<path..>", rank = 10)]

pgml-dashboard/src/components/inputs/select/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::components::stimulus::stimulus_action::{StimulusAction, StimulusEvents};
22
use crate::components::stimulus::stimulus_target::StimulusTarget;
3+
use crate::types::CustomOption;
34
use pgml_components::component;
45
use pgml_components::Component;
56
use sailfish::TemplateOnce;
6-
use crate::types::CustomOption;
77

88
#[derive(TemplateOnce, Default)]
99
#[template(path = "inputs/select/template.html")]

pgml-dashboard/src/components/nav/template.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626

2727
<% if link.nav.is_some() { %>
2828
<ul class="nav flex-column justify-content-end flex-grow-1 ps-5">
29-
29+
3030
<% for link in link.nav.unwrap().links.iter() {
3131
let active = if link.active {
3232
"active"
3333
} else {
3434
""
3535
};
36-
36+
3737
let aria = if link.active {
3838
r#"area-current="page""#
3939
} else {
@@ -48,10 +48,10 @@
4848
<span class="nav-link-name"><%= link.name %></span>
4949
</a>
5050
</li>
51-
51+
5252
<% } %>
5353
</ul>
54-
54+
5555
<% } %>
5656
</li>
5757
<% } %>

pgml-dashboard/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use sailfish::TemplateOnce;
1313
use sqlx::PgPool;
1414
use std::collections::HashMap;
1515

16-
pub mod types;
1716
pub mod api;
1817
pub mod components;
1918
pub mod fairings;
@@ -22,6 +21,7 @@ pub mod guards;
2221
pub mod models;
2322
pub mod responses;
2423
pub mod templates;
24+
pub mod types;
2525
pub mod utils;
2626

2727
use guards::{Cluster, ConnectedCluster};

pgml-dashboard/src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,7 @@ mod test {
285285
#[rocket::async_test]
286286
async fn test_docs() {
287287
let client = Client::tracked(rocket().await).await.unwrap();
288-
let response = client
289-
.get("/docs/guides/README")
290-
.dispatch()
291-
.await;
288+
let response = client.get("/docs/guides/README").dispatch().await;
292289
assert_eq!(response.status().code, 200);
293290
}
294291

pgml-dashboard/src/templates/docs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ impl NavLink {
4242
//github.com/ Automatically expand the link and it's parents
4343
//github.com/ when one of the children is visible.
4444
pub fn should_open(&mut self, path: &str) -> bool {
45+
self.open = self.href.contains(&path);
4546
let open = if self.children.is_empty() {
46-
self.open = self.href.contains(&path);
4747
self.open
4848
} else {
4949
for child in self.children.iter_mut() {

pgml-dashboard/src/utils/markdown.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ use url::Url;
2626
use crate::templates::docs::NavLink;
2727
use std::fmt;
2828

29-
pub struct MarkdownHeadings {
30-
}
29+
pub struct MarkdownHeadings {}
3130

3231
impl MarkdownHeadings {
3332
pub fn new() -> Self {
34-
Self {
35-
}
33+
Self {}
3634
}
3735
}
3836

@@ -583,7 +581,7 @@ pub fn get_sub_links(list: &markdown::mdast::List) -> Result<Vec<NavLink>> {
583581
.unwrap();
584582
let parent = NavLink::new(text.value.as_str())
585583
.href(&url);
586-
links.push(parent)
584+
links.push(parent);
587585
}
588586
_ => error!("unhandled link child: {:?}", node),
589587
}
@@ -1074,8 +1072,8 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena<AstNode<'a>>) -> anyho
10741072
r#"
10751073
<ul class="nav nav-tabs">
10761074
"#
1077-
.to_string()
1078-
.into(),
1075+
.to_string()
1076+
.into(),
10791077
)))));
10801078

10811079
parent.insert_after(n);
@@ -1136,7 +1134,7 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena<AstNode<'a>>) -> anyho
11361134
active = if tab.active { "show active" } else { "" },
11371135
id = tab.id
11381136
)
1139-
.into(),
1137+
.into(),
11401138
),
11411139
))));
11421140

@@ -1337,8 +1335,7 @@ impl SearchIndex {
13371335
}
13381336

13391337
pub fn documents() -> Vec<PathBuf> {
1340-
let guides =
1341-
glob::glob(&(config::docs_dir() + "/guides/**/*.md")).expect("glob failed");
1338+
let guides = glob::glob(&(config::docs_dir() + "/guides/**/*.md")).expect("glob failed");
13421339
let blogs = glob::glob(&(config::blogs_dir() + "/blog/**/*.md")).expect("glob failed");
13431340
guides
13441341
.chain(blogs)

pgml-dashboard/static/css/scss/components/_navs.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,9 @@
198198
&:focus:not(:hover) {
199199
color: #{$gray-100}
200200
}
201-
202201
}
203202
[aria-expanded=false] {
204-
span.material-symbols-outlined {
205-
transform: rotate(-90deg);
206-
}
203+
transform: rotate(-90deg);
207204
}
208205
@include media-breakpoint-down(xxl) {
209206
border-radius: 0px;
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<div class="nav flex-column" role="tablist" aria-orientation="vertical">
2-
<% if !children.is_empty() {
2+
<%
3+
let color = if open {
4+
"purple"
5+
} else {
6+
""
7+
};
8+
9+
if children.is_empty() {
10+
%>
11+
<a class="nav-link px-0 text-break <%- color %>" href="<%- href %>"><%- title %></a>
12+
<% } else {
313
let aria = if open {
414
"true"
515
} else {
@@ -12,23 +22,17 @@
1222
"false"
1323
};
1424
%>
15-
<a class="nav-link px-0 d-flex justify-content-between align-items-center text-break" data-bs-toggle="collapse" href="#doc-<%= id %>" role="button" aria-expanded="<%- aria %>" aria-controls="doc-<%= id %>">
16-
<span><%= title %></span><span class="material-symbols-outlined">expand_more</span>
17-
</a>
25+
26+
<span class="px-0 d-flex justify-content-between align-items-center text-break" >
27+
<a class="nav-link px-0 text-break <%- color %>" href="<%- href %>"><%- title %></a>
28+
<span class="material-symbols-outlined" data-bs-toggle="collapse" href="#doc-<%= id %>" role="button" aria-expanded="<%- aria %>" aria-controls="doc-<%= id %>">expand_more</span>
29+
</span>
1830
<div class="collapse <%- show %> ps-3" id="doc-<%= id %>">
1931
<div class="nav flex-column" role="tablist" aria-orentation="vertical">
2032
<% for child in children.into_iter() { %>
2133
<%- child.render_once().unwrap() %>
2234
<% } %>
2335
</div>
2436
</div>
25-
<% } else {
26-
let color = if open {
27-
"purple"
28-
} else {
29-
""
30-
};
31-
%>
32-
<a class="nav-link px-0 text-break <%- color %>" href="<%- href %>"><%- title %></a>
3337
<% } %>
3438
</div>

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/postgresml/postgresml/commit/8788c2b3667ab3f83335e511a82a1d7001e8abec

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy