Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions Documentation/templates-src/NetCord/src/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import AnchorJs from "anchor-js";
import { render, html, nothing, TemplateResult } from "lit-html";
// import { unsafeStatic, } from 'lit-html/static.js'
import { breakWordLit, meta, isExternalHref, loc, options } from "./helper";
import { themePicker } from "./theme";
import { TocNode } from "./toc";
Expand Down Expand Up @@ -71,13 +70,28 @@ export async function renderNavbar(): Promise<NavItem[]> {
const iconsForm = html` <form class="icons">
${icons?.map(
(i) =>
html`<a
class="btn border-0 icon-tooltip"
href="${i.href ?? nothing}"
@click="${i.onclick ?? nothing}"
tooltip="${i.tooltip}"
><i class="${i.icon}"></i
></a>`,
{
if (i.href) {
return html`<a
class="btn border-0 icon-tooltip"
href="${i.href}"
aria-label="${i.tooltip}"
tooltip="${i.tooltip}"
><i class="${i.icon}"></i
></a>`;
} else if (i.onclick) {
return html`<button
type="button"
class="btn border-0 icon-tooltip"
aria-label="${i.tooltip}"
@click="${i.onclick}"
tooltip="${i.tooltip}"
><i class="${i.icon}"></i
></button>`;
}

return nothing;
},
)}
${await themePicker(renderCore)}
</form>`;
Expand Down
6 changes: 4 additions & 2 deletions Documentation/templates-src/NetCord/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ export async function themePicker(refresh: () => void) {
const theme = getTheme();
const icon = theme === "light" ? "sun" : "moon";

return html`<a
return html`<button
type="button"
class="btn border-0 icon-tooltip"
aria-label="Toggle theme"
@click="${toggleTheme}"
tooltip="Toggle theme"
><i class="bi bi-${icon}"></i
></a>`;
></button>`;

function toggleTheme(e) {
e.preventDefault();
Expand Down