Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript

Use a theme label to denote current state. Have theme cover whole width

Scott Petrovic29e1d5f2e6f6
diff --git a/src/lib/ThemeManager.ts b/src/lib/ThemeManager.ts
index 1c1abb8..7bbdcd0 100644
--- a/src/lib/ThemeManager.ts
+++ b/src/lib/ThemeManager.ts
@@ -2,6 +2,7 @@ export class ThemeManager extends EventTarget {
private current_theme: 'light' | 'dark' = 'dark'
private theme_toggle_button: HTMLButtonElement | null = null
private theme_icon: HTMLElement | null = null
+ private theme_label: HTMLElement | null = null
private theme_change_event: CustomEvent | null = null
@@ -14,6 +15,13 @@ export class ThemeManager extends EventTarget {
// Get DOM elements
this.theme_toggle_button = document.querySelector('#theme-toggle')
this.theme_icon = this.theme_toggle_button?.querySelector('.theme-icon') ?? null
+ this.theme_label = this.theme_toggle_button?.querySelector('.theme-label') ?? null
+
+ if (this.theme_toggle_button !== null && this.theme_label === null) {
+ this.theme_label = document.createElement('span')
+ this.theme_label.className = 'theme-label'
+ this.theme_toggle_button.appendChild(this.theme_label)
+ }
// Load saved theme preference
this.load_theme_preference()
@@ -59,11 +67,15 @@ export class ThemeManager extends EventTarget {
}
private update_toggle_ui (): void {
- if (this.theme_icon !== null) {
+ if (this.theme_icon !== null && this.theme_label !== null) {
if (this.current_theme === 'light') {
this.theme_icon.textContent = '🌞'
+ this.theme_label.textContent = 'Light'
+ this.theme_toggle_button?.setAttribute('aria-label', 'Theme: Light')
} else {
this.theme_icon.textContent = '🌚'
+ this.theme_label.textContent = 'Dark'
+ this.theme_toggle_button?.setAttribute('aria-label', 'Theme: Dark')
}
}
}
diff --git a/src/settings-dropdown.css b/src/settings-dropdown.css
index 6375c62..6b77906 100644
--- a/src/settings-dropdown.css
+++ b/src/settings-dropdown.css
@@ -51,6 +51,11 @@
font-size: 0.95rem;
}
+#theme-toggle .theme-label {
+ font-size: 0.95rem;
+ margin-left: 0.45rem;
+}
+
.settings-dropdown-row input[type="checkbox"] {
width: 16px;
height: 16px;
diff --git a/src/styles.css b/src/styles.css
index 1be8e82..3bb251e 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -583,6 +583,7 @@ input[type="file"] {
box-shadow: none;
border-radius: 0;
padding: 0;
+ width: 100%;
}
#theme-toggle:hover {