Skip to content

Commit

Permalink
Match website theme with C3 Handbook and Main page (#14)
Browse files Browse the repository at this point in the history
* style: Match website theme with C3 Handbook and Main page
* add: the styling for hiding icons on theme switcher
* fix: default theme loading from localstorage
  • Loading branch information
anoubluvz authored Aug 4, 2024
1 parent 54948dd commit 8b34fd7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
18 changes: 16 additions & 2 deletions .astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ declare module 'astro:content' {
? {
collection: C;
slug: ValidContentEntrySlug<C>;
}
}
: {
collection: C;
id: keyof DataEntryMap[C];
}
}
>;
// Allow generic `string` to avoid excessive type errors in the config
// if `dev` is not running to update as you edit.
Expand All @@ -185,6 +185,13 @@ declare module 'astro:content' {

type ContentEntryMap = {
"docs": {
"guide/basic-types-and-values.md": {
id: "guide/basic-types-and-values.md";
slug: "guide/basic-types-and-values";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
"guide/index.mdx": {
id: "guide/index.mdx";
slug: "guide";
Expand Down Expand Up @@ -458,6 +465,13 @@ declare module 'astro:content' {
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
"references/docs/stdlib_refcard.md": {
id: "references/docs/stdlib_refcard.md";
slug: "references/docs/stdlib_refcard";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
"references/docs/syntax.md": {
id: "references/docs/syntax.md";
slug: "references/docs/syntax";
Expand Down
14 changes: 5 additions & 9 deletions src/components/navbar.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---
---

<script lang="js">
if (
localStorage.theme === "dark" ||
(!("theme" in localStorage) &&
localStorage["starlight-theme"] === "dark" ||
(!(["starlight-theme"] in localStorage) &&
window.matchMedia("(prefers-color-scheme: dark)").matches)
) {
document.documentElement.classList.add("dark");
Expand All @@ -16,7 +12,7 @@
const HSThemeAppearance = {
init() {
const defaultTheme = "default";
let theme = localStorage.getItem("hs_theme") || defaultTheme;
let theme = localStorage.getItem("starlight-theme") || defaultTheme;

if (document.querySelector("html").classList.contains("dark")) return;
this.setAppearance(theme);
Expand All @@ -32,7 +28,7 @@
const $resetStylesEl = this._resetStylesOnLoad();

if (saveInStore) {
localStorage.setItem("hs_theme", theme);
localStorage.setItem("starlight-theme", theme);
}

if (theme === "auto") {
Expand Down Expand Up @@ -70,7 +66,7 @@
},
getOriginalAppearance() {
const defaultTheme = "default";
return localStorage.getItem("hs_theme") || defaultTheme;
return localStorage.getItem("starlight-theme") || defaultTheme;
},
};
HSThemeAppearance.init();
Expand Down

0 comments on commit 8b34fd7

Please sign in to comment.