Skip to content

Commit 438316f

Browse files
committed
refactor: rework stylesheet
1 parent 56dfeb0 commit 438316f

21 files changed

+291
-134
lines changed

src/html/comrak_adapters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl HighlightAdapter {
5959

6060
if self.show_line_numbers {
6161
Ok(format!(
62-
r##"<div class="border-r-2 border-stone-300 pr-1 text-right flex-none">{line_numbers}</div><div class="grow overflow-x-auto">{lines}</div>"##
62+
r##"<div class="lineNumbers">{line_numbers}</div><div class="grow overflow-x-auto">{lines}</div>"##
6363
))
6464
} else {
6565
Ok(lines)

src/html/jsdoc.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,17 +377,15 @@ pub fn markdown_to_html(
377377
if toc.is_empty() {
378378
None
379379
} else {
380-
let mut toc_content = vec![String::from(
381-
r#"<ul class="space-y-2 block overflow-y-auto h-full">"#,
382-
)];
380+
let mut toc_content = vec![String::from(r#"<nav class="toc"><ul>"#)];
383381

384382
let mut current_level = 1;
385383

386384
for (level, heading, anchor) in toc {
387385
match current_level.cmp(&level) {
388386
Ordering::Equal => {}
389387
Ordering::Less => {
390-
toc_content.push(r#"<li><ul class="ml-4 space-y-2">"#.to_string());
388+
toc_content.push(r#"<li><ul>"#.to_string());
391389
current_level = level;
392390
}
393391
Ordering::Greater => {
@@ -397,11 +395,11 @@ pub fn markdown_to_html(
397395
}
398396

399397
toc_content.push(format!(
400-
r##"<li><a class="hover:underline block overflow-x-hidden whitespace-nowrap text-ellipsis" href="#{anchor}" title="{heading}">{heading}</a></li>"##
398+
r##"<li><a href="#{anchor}" title="{heading}">{heading}</a></li>"##
401399
));
402400
}
403401

404-
toc_content.push(String::from("</ul>"));
402+
toc_content.push(String::from("</ul></nav>"));
405403

406404
Some(toc_content.join(""))
407405
}

src/html/templates/anchor.hbs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
<a
2-
href="#{{id}}"
3-
class="anchor float-left leading-none hidden text-stone-600 ml-[-24px] p-1 pr-1 pt-1 top-0 bottom-0"
4-
aria-label="Anchor"
5-
tabIndex=-1
6-
>
1+
<a href="#{{id}}" class="anchor" aria-label="Anchor" tabIndex="-1">
72
{{~> icons/link ~}}
83
</a>

src/html/templates/breadcrumbs.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ul class="whitespace-nowrap inline-flex gap-1 items-center *:py-1 *:px-2">
1+
<ul class="breadcrumbs">
22
{{~#each parts~}}
33
{{~#if this.is_first_symbol~}}
44
<ul>
@@ -8,7 +8,7 @@
88
{{~#if @last~}}
99
{{~this.name~}}
1010
{{~else~}}
11-
<a class="text-breadcrumb underline decoration-[1.5px] decoration-breadcrumb/50 underline-offset-4 hover:decoration-breadcrumb" href="{{this.href}}">
11+
<a href="{{this.href}}">
1212
{{~this.name~}}
1313
</a>
1414
{{~/if~}}
@@ -18,7 +18,7 @@
1818
{{~#if this.is_symbol~}}
1919
<span>.</span>
2020
{{~else~}}
21-
<span class="!p-0 text-[#0F172A]">{{~> icons/arrow ~}}</span>
21+
<span class="text-[#0F172A]">{{~> icons/arrow ~}}</span>
2222
{{~/if~}}
2323
{{/unless}}
2424

src/html/templates/deprecated.hbs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
{{~#if (ne this null)~}}
2-
<div>
3-
<div class="py-1 text-red-500 flex gap-1 items-center">
4-
<span class="font-semibold leading-6">
5-
Deprecated
6-
</span>
7-
</div>
2+
<div class="deprecated">
3+
<div><span>Deprecated</span></div>
84

95
{{~#if (ne this "")~}}
10-
<div class="ml-1 pl-2 border-l-4 border-red-300">
11-
{{{this}}} {{! markdown rendering }}
12-
</div>
6+
<div>{{{this}}} {{! markdown rendering }}</div>
137
{{~/if~}}
148
</div>
159
{{~/if~}}

src/html/templates/doc_block_subtitle_class.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{~#if implements~}}
22
<div>
3-
<span class="text-stone-400 italic"> implements </span>
3+
<span class="type"> implements </span>
44
{{~#each implements~}}
55
{{{~this~}}} {{! typedef rendering }}
66
{{~#unless @last~}}
@@ -12,7 +12,7 @@
1212

1313
{{~#with extends~}}
1414
<div>
15-
<span class="text-stone-400 italic"> extends </span>
15+
<span class="type"> extends </span>
1616
{{~#if href ~}}
1717
<a class="link" href="{{href}}">
1818
{{~symbol~}}

src/html/templates/doc_block_subtitle_interface.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div>
2-
<span class="text-stone-400 italic"> extends </span>
2+
<span class="type"> extends </span>
33
{{~#each extends~}}
44
{{{~this~}}} {{! typedef rendering }}
55
{{~#unless @last~}}

src/html/templates/doc_entry.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<div class="anchorable text-sm" id="{{id}}">
1+
<div class="anchorable docEntry" id="{{id}}">
22
{{~> anchor anchor ~}}
33

4-
<div class="flex justify-between items-start">
5-
<span class="flex items-center break-words gap-2">
4+
<div class="docEntryHeader">
5+
<span>
66
{{~#if tags~}}
77
<span class="space-x-1">
88
{{~#each tags~}}

src/html/templates/doc_node_kind_icon.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<div class="flex justify-end compound_types w-[2.125rem] shrink-0">
1+
<div class="docNodeKindIcon">
22
{{~#each this~}}
3-
<div class="text-{{this.kind}} bg-{{this.kind}}/15 rounded-full size-5 font-medium text-xs leading-5 text-center align-middle shrink-0 select-none font-mono" title="{{this.title}}">
3+
<div class="text-{{this.kind}} bg-{{this.kind}}/15" title="{{this.title}}">
44
{{~this.char~}}
55
</div>
66
{{~/each~}}

src/html/templates/example.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<div class="anchorable">
1+
<div class="anchorable example">
22
{{~> anchor anchor ~}}
33

4-
<details id="{{id}}" class="group" open>
5-
<summary class="list-none flex items-center gap-2 py-2 rounded-lg w-full leading-6 cursor-pointer">
6-
<div class="text-stone-600 group-open:rotate-90 select-none">&#x25B6;</div>
4+
<details id="{{id}}" open>
5+
<summary>
6+
<div>&#x25B6;</div>
77
{{{~markdown_title~}}} {{! markdown rendering }}
88
</summary>
99
<div class="!ml-2 markdown_border">

src/html/templates/function.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<div class="space-y-2">
99
{{~#each overloads_ctx~}}
10-
<label for="{{this.overload_id}}" class="space-y-1 block px-4 py-2.5 rounded-lg border border-stone-300 cursor-pointer hover:bg-stone-100">
10+
<label for="{{this.overload_id}}" class="functionOverload">
1111
{{~> deprecated this.deprecated ~}}
1212
<code class="text-sm">
1313
<span class="font-bold">{{this.name}}</span><span class="font-medium">{{{this.summary}}} {{! typedef rendering }}</span>

src/html/templates/index_sidepanel.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{~/if~}}
88

99
{{~#if files~}}
10-
<h3 class="title">Modules</h3>
10+
<h2>Modules</h2>
1111
<ul>
1212
{{#each files}}
1313
<li>
@@ -20,11 +20,11 @@
2020
{{~/if~}}
2121

2222
{{~#if kind_partitions~}}
23-
<h3 class="title">APIs</h3>
23+
<h2>APIs</h2>
2424
<ul class="space-y-2">
2525
{{~#each kind_partitions~}}
2626
<li>
27-
<h4 class="subtitle">{{this.name}}</h4>
27+
<h3>{{this.name}}</h3>
2828
<ul>
2929
{{~#each this.symbols~}}
3030
<li>

src/html/templates/module_doc.hbs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section {{#if toc}}class="flex max-lg:flex-col-reverse gap-6"{{/if}}>
1+
<section {{#if toc}}class="tocable"{{/if}}>
22
<div class="space-y-2 flex-1 {{#if toc}}min-w-0{{/if}}">
33
{{~#if title~}}
44
<h2 class="text-lg font-semibold font-mono">{{title}}</h2>
@@ -15,8 +15,6 @@
1515
</div>
1616

1717
{{~#if toc~}}
18-
<nav class="flex-none max-w-52 text-sm max-lg:hidden sticky top-0 py-4 max-h-screen box-border">
19-
{{{~toc~}}} {{! markdown rendering ToC }}
20-
</nav>
18+
{{{~toc~}}} {{! markdown rendering ToC }}
2119
{{~/if~}}
2220
</section>

src/html/templates/namespace_section.hbs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
1+
<div class="namespaceSection">
22
{{~#each this~}}
3-
<div class="space-y-2 {{#if this.deprecated}}opacity-60{{/if}}">
4-
<div class="flex gap-2 items-center">
5-
{{!-- TODO: figure out design of tags in namespace view
6-
{{~#if tags~}}
7-
<span class="space-x-1">
8-
{{~#each tags~}}
9-
{{~> tag value=this ~}}
10-
{{~/each~}}
11-
</span>
12-
{{~/if~}} --}}
3+
<div class="namespaceItem" {{#if this.deprecated}}aria-label="deprecated"{{/if}}>
4+
<div class="namespaceItemTitle">
135
{{~> doc_node_kind_icon this.doc_node_kind_ctx ~}}
146

15-
<div class="flex justify-between gap-4 flex-1 min-w-0 items-end overflow-hidden">
16-
<a href="{{this.href}}" class="leading-tight truncate {{#if this.deprecated}}line-through decoration-2 decoration-stone-500/70 text-stone-500{{/if}}" title="{{this.name}}">
7+
<div>
8+
<a href="{{this.href}}" title="{{this.name}}">
179
{{~this.name~}}
1810
</a>
1911

2012
{{~#if this.origin_name~}}
21-
<div class="text-xs italic lg:mr-4 text-stone-400 truncate" title="{{this.origin_name}}">from {{this.origin_name}}</div>
13+
<div title="{{this.origin_name}}">from {{this.origin_name}}</div>
2214
{{~/if~}}
2315
</div>
2416
</div>
25-
<div class="block py-1 text-sm leading-5 text-stone-600 !ml-2 markdown_border">
17+
<div class="namespaceItemContent">
2618
{{~#if this.docs~}}
2719
{{{~this.docs~}}} {{! markdown rendering }}
2820
{{~else~}}

src/html/templates/pages/search.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,13 @@ function renderResults(results) {
122122
for (const result of results) {
123123
const kind = result.kind.map((kind) => {
124124
const [rustKind, title, symbol] = docNodeKindToStringVariants(kind);
125-
return `<div class="text-${rustKind} bg-${rustKind}/15 rounded-full size-5 font-medium text-xs leading-5 text-center align-middle shrink-0 select-none font-mono" title="${title}">
126-
${symbol}
127-
</div>`;
125+
return `<div class="text-${rustKind} bg-${rustKind}/15" title="${title}">${symbol}</div>`;
128126
}).join("");
129127

130128
html += `<li class="block">
131129
<a href="${pathToRoot}${result.file}/~/${result.name}.html" class="flex rounded-lg gap-4 items-center justify-between py-2 px-3 hover:bg-stone-100">
132130
<div class="flex items-center gap-2.5">
133-
<div class="flex justify-end compound_types w-[2.125rem] shrink-0">
131+
<div class="docNodeKindIcon">
134132
${kind}
135133
</div>
136134
<span class="text-sm leading-none">${result.name}</span>

src/html/templates/section.hbs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<div>
2-
<h2 class="text-xl leading-6 font-semibold py-1 mb-4">{{title}}</h2>
1+
<section class="section">
2+
<h2>{{title}}</h2>
3+
34
{{~#if (eq content.kind "namespace_section")~}}
45
{{~> namespace_section content.content ~}}
56
{{~else~}}
@@ -9,4 +10,4 @@
910
{{~/each~}}
1011
</div>
1112
{{~/if~}}
12-
</div>
13+
</section>

src/html/templates/sidepanel.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="space-y-2 max-lg:hidden peer-checked:block">
55
{{~#each partitions ~}}
66
<div>
7-
<h3 class="subtitle">{{this.name}}</h3>
7+
<h3>{{this.name}}</h3>
88
<ul>
99
{{~#each this.symbols ~}}
1010
<li>

0 commit comments

Comments
 (0)