working on popup state management
This commit is contained in:
@@ -5,6 +5,26 @@ const login_status = document.getElementById("login-status")
|
||||
|
||||
const signup_form = document.getElementById("signup-form") as HTMLFormElement
|
||||
|
||||
class PopupState {
|
||||
logged_in: boolean
|
||||
|
||||
visible_section: string
|
||||
page_sections: Map<string, HTMLElement>
|
||||
|
||||
constructor(logged_in: boolean, page_sections: Map<string, HTMLElement>, visible_section: string) {
|
||||
this.logged_in = logged_in
|
||||
this.page_sections = page_sections
|
||||
this.visible_section = visible_section
|
||||
}
|
||||
|
||||
setVisibleSection(section_id: string) {
|
||||
this.visible_section = section_id
|
||||
this.page_sections.forEach((element, id) => {
|
||||
element.style.visibility = id === section_id ? "visible" : "collapse"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (localStorage.getItem("accessToken")) {
|
||||
login_status.setAttribute("style", "visibility: visible;")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user