From 86c038ec579eac3c7ae18252e26974e2b5f6ca9a Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Thu, 8 Aug 2024 15:09:27 -0500 Subject: [PATCH] add theming select back --- .dist/localuser.js | 11 +++++++++++ .dist/settings.js | 7 ++++++- webpage/localuser.ts | 10 ++++++++++ webpage/settings.ts | 8 +++++++- webpage/style.css | 2 +- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.dist/localuser.js b/.dist/localuser.js index 64e8a1f..681631b 100644 --- a/.dist/localuser.js +++ b/.dist/localuser.js @@ -2,6 +2,7 @@ import { Guild } from "./guild.js"; import { Direct } from "./direct.js"; import { User } from "./user.js"; import { Fullscreen } from "./fullscreen.js"; +import { setTheme } from "./login.js"; import { SnowFlake } from "./snowflake.js"; import { Message } from "./message.js"; import { Member } from "./member.js"; @@ -690,6 +691,16 @@ class Localuser { regen(); }); } + { + const tas = settings.addButton("Themes & sounds"); + { + const themes = ["Dark", "WHITE", "Light"]; + tas.addSelect("Theme:", _ => { + localStorage.setItem("theme", themes[_]); + setTheme(); + }, themes, { defaultIndex: themes.indexOf(localStorage.getItem("theme")) }); + } + } settings.show(); } /** diff --git a/.dist/settings.js b/.dist/settings.js index d2f185e..c84f72a 100644 --- a/.dist/settings.js +++ b/.dist/settings.js @@ -195,7 +195,6 @@ class SelectInput { span.textContent = this.label; div.append(span); const select = document.createElement("select"); - select.selectedIndex = this.index; select.onchange = this.onChange.bind(this); for (const thing of this.options) { const option = document.createElement("option"); @@ -203,6 +202,7 @@ class SelectInput { select.appendChild(option); } this.select = new WeakRef(select); + select.selectedIndex = this.index; div.append(select); return div; } @@ -374,6 +374,11 @@ class Options { this.options.push(options); return options; } + addSelect(label, onSubmit, selections, { defaultIndex = 0 } = {}) { + const select = new SelectInput(label, onSubmit, selections, this, { defaultIndex }); + this.options.push(select); + return select; + } addFileInput(label, onSubmit, {} = {}) { const FI = new FileInput(label, onSubmit, this, {}); this.options.push(FI); diff --git a/webpage/localuser.ts b/webpage/localuser.ts index 4f32629..f41e416 100644 --- a/webpage/localuser.ts +++ b/webpage/localuser.ts @@ -716,6 +716,16 @@ class Localuser{ regen(); }) } + { + const tas=settings.addButton("Themes & sounds"); + { + const themes=["Dark","WHITE","Light"]; + tas.addSelect("Theme:",_=>{ + localStorage.setItem("theme",themes[_]); + setTheme(); + },themes,{defaultIndex:themes.indexOf(localStorage.getItem("theme"))}); + } + } settings.show(); } /** diff --git a/webpage/settings.ts b/webpage/settings.ts index 017d5d7..f119f83 100644 --- a/webpage/settings.ts +++ b/webpage/settings.ts @@ -195,7 +195,7 @@ class SelectInput implements OptionsElement{ span.textContent=this.label; div.append(span); const select=document.createElement("select"); - select.selectedIndex=this.index; + select.onchange=this.onChange.bind(this); for(const thing of this.options){ const option = document.createElement("option"); @@ -203,6 +203,7 @@ class SelectInput implements OptionsElement{ select.appendChild(option); } this.select=new WeakRef(select); + select.selectedIndex=this.index; div.append(select); return div; } @@ -374,6 +375,11 @@ class Options implements OptionsElement{ this.options.push(options); return options; } + addSelect(label:string,onSubmit:(str:number)=>void,selections:string[],{defaultIndex=0}={}){ + const select=new SelectInput(label,onSubmit,selections,this,{defaultIndex}); + this.options.push(select); + return select; + } addFileInput(label:string,onSubmit:(files:FileList)=>void,{}={}){ const FI=new FileInput(label,onSubmit,this,{}); this.options.push(FI); diff --git a/webpage/style.css b/webpage/style.css index 775c4cb..6352cf6 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -1248,7 +1248,7 @@ span { } .settingbuttons{ padding-top:.075in; - width: 1.5in; + width: 1.75in; border-right: solid var(--message-bg-hover); gap:.04in; flex-grow: 0;