Better style

This commit is contained in:
ef3d0c3e 2024-10-31 00:10:28 +01:00
parent 0f9cf7057a
commit 2eb355ac5e
5 changed files with 75 additions and 23 deletions

View file

@ -24,7 +24,7 @@
> This issue is getting a bit too heated, locking right now > This issue is getting a bit too heated, locking right now
```Markdown, Given by the following ```Markdown, Given by the following
> Nest quotes can be nested > Quotes can be nested
>> Here's a subquote >> Here's a subquote
>>>[author=With author, cite=With cite] >>>[author=With author, cite=With cite]
>>> Here's another subquote >>> Here's another subquote

View file

@ -1,6 +1,6 @@
@import ../template.nml @import ../template.nml
@nav.previous = Code @nav.previous = Blockquote
%<make_doc({"Code"}, "Code", "Code")>% %<make_doc({"Blocks"}, "Code", "Code")>%
# Blockquotes # Blockquotes

View file

@ -27,7 +27,7 @@ end
>@ >@
@@style.section = { @@style.section = {
"link_pos": "Before", "link_pos": "After",
"link": [" ", "🔗 ", " "] "link": [" ", "🔗 ", " "]
} }

View file

@ -40,6 +40,7 @@ impl NavEntries {
fn process( fn process(
target: Target, target: Target,
doc_path: &String,
categories: &Vec<&str>, categories: &Vec<&str>,
did_match: bool, did_match: bool,
result: &mut String, result: &mut String,
@ -48,9 +49,15 @@ impl NavEntries {
) { ) {
// Orphans = Links // Orphans = Links
for entry in &entry.entries { for entry in &entry.entries {
let style = if doc_path == &entry.path {
" class=\"navbar-entry-current\""
} else {
" class=\"navbar-entry\""
}
.to_string();
result.push_str( result.push_str(
format!( format!(
r#"<li><a href="{}">{}</a></li>"#, r#"<li {style}><a href="{}">{}</a></li>"#,
Compiler::sanitize(target, entry.path.as_str()), Compiler::sanitize(target, entry.path.as_str()),
Compiler::sanitize(target, entry.title.as_str()) Compiler::sanitize(target, entry.title.as_str())
) )
@ -68,19 +75,37 @@ impl NavEntries {
result.push_str("<li>"); result.push_str("<li>");
result.push_str( result.push_str(
format!( format!(
"<details{}><summary>{}</summary>", "<details{}><summary class=\"navbar-category\">{}</summary>",
["", " open"][is_match as usize], ["", " open"][is_match as usize],
Compiler::sanitize(target, name) Compiler::sanitize(target, name)
) )
.as_str(), .as_str(),
); );
result.push_str("<ul>"); result.push_str("<ul>");
process(target, categories, is_match, result, ent, depth + 1); process(
target,
doc_path,
categories,
is_match,
result,
ent,
depth + 1,
);
result.push_str("</ul></details></li>"); result.push_str("</ul></details></li>");
} }
} }
process(target, &categories, true, &mut result, self, 0); process(
target,
doc_borrow
.get_variable("compiler.output")
.unwrap_or(&String::new()),
&categories,
true,
&mut result,
self,
0,
);
result += r#"</ul></div>"#; result += r#"</ul></div>"#;
} }

View file

@ -48,6 +48,10 @@ em {
background-color: #191f26; background-color: #191f26;
} }
a {
color: #55c3df;
}
a.inline-code { a.inline-code {
padding-left: .1em; padding-left: .1em;
padding-right: .1em; padding-right: .1em;
@ -63,7 +67,7 @@ a.inline-code {
left: 0; left: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;
width: max(calc((100vw - 99ch) / 2 - 15vw), 24ch); width: max(calc((100vw - 99ch) / 2 - 12vw), 24ch);
height: 100vh; height: 100vh;
position: fixed; position: fixed;
margin-right: 1em; margin-right: 1em;
@ -72,10 +76,9 @@ a.inline-code {
box-sizing: border-box; box-sizing: border-box;
overscroll-behavior-y: contain; overscroll-behavior-y: contain;
background-color: #161a26; background-color: #242526;
color: #aaa; color: #d0d0d0;
font-size: 0.9em;
font-weight: bold; font-weight: bold;
} }
@ -88,23 +91,47 @@ a.inline-code {
} }
} }
.navbar a { .navbar li {
color: #ffb454; display: block;
position: relative;
padding-left: .25em;
margin-left: 5%;
width: 90%;
margin-top: 0.066em;
margin-bottom: 0.066em;
}
li.navbar-entry:hover, summary.navbar-category:hover
{
background-color: #2f3031;
border-radius: 5px;
}
li.navbar-entry-current
{
background-color: #2f3031;
border-radius: 5px;
}
li.navbar-entry a {
color: #d0d0d0;
text-decoration: none; text-decoration: none;
font-weight: normal; font-weight: normal;
} }
.navbar li { li.navbar-entry-current a {
display: block; color: #55ffb4;
position: relative;
padding-left: 1em; text-decoration: none;
margin-left: 0em; font-weight: normal;
} }
.navbar ul { .navbar ul {
margin-left: 0em; margin-left: 0em;
padding-left: 0; padding-left: 0;
line-height: 1.66em;
} }
.navbar summary{ .navbar summary{
@ -125,15 +152,15 @@ a.inline-code {
outline: 1px dotted #000; outline: 1px dotted #000;
} }
.navbar summary:before { .navbar summary:after {
content: "+"; content: "+";
color: #ffb454; color: #55ffb4;
float: left; float: left;
text-align: center; text-align: center;
width: 1em; width: 1em;
} }
.navbar details[open] > summary:before { .navbar details[open] > summary:after {
content: ""; content: "";
} }