notifications setting
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import util from "../util"
|
import util from "../util"
|
||||||
|
import "./Toggle.js"
|
||||||
|
|
||||||
class Sidebar extends Shadow {
|
class Sidebar extends Shadow {
|
||||||
SIDEBAR_WIDTH
|
SIDEBAR_WIDTH
|
||||||
@@ -66,9 +67,12 @@ class Sidebar extends Shadow {
|
|||||||
|
|
||||||
this.SidebarItem("Logout")
|
this.SidebarItem("Logout")
|
||||||
|
|
||||||
|
VStack(() => {
|
||||||
|
Toggle("Enable Push Notifications")
|
||||||
|
.marginLeft(1, em)
|
||||||
|
|
||||||
button("Delete Account")
|
button("Delete Account")
|
||||||
.fontSize(0.9, em)
|
.fontSize(0.9, em)
|
||||||
.marginTop("auto")
|
|
||||||
.marginBottom(2, em)
|
.marginBottom(2, em)
|
||||||
.background("var(--darkred)")
|
.background("var(--darkred)")
|
||||||
.paddingVertical(1, em)
|
.paddingVertical(1, em)
|
||||||
@@ -77,6 +81,9 @@ class Sidebar extends Shadow {
|
|||||||
.color("var(--text)")
|
.color("var(--text)")
|
||||||
.onTap((done) => this.deleteAccount())
|
.onTap((done) => this.deleteAccount())
|
||||||
})
|
})
|
||||||
|
.marginTop("auto")
|
||||||
|
.gap(2, em)
|
||||||
|
})
|
||||||
.gap(1, em)
|
.gap(1, em)
|
||||||
.paddingTop(15, vh)
|
.paddingTop(15, vh)
|
||||||
.paddingHorizontal(1, em)
|
.paddingHorizontal(1, em)
|
||||||
|
|||||||
50
src/components/Toggle.js
Normal file
50
src/components/Toggle.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
css(`
|
||||||
|
.toggle-input {
|
||||||
|
appearance: none;
|
||||||
|
width: 44px;
|
||||||
|
height: 24px;
|
||||||
|
background: #ccc;
|
||||||
|
border-radius: 12px;
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-input::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
background: white;
|
||||||
|
border-radius: 50%;
|
||||||
|
top: 2px;
|
||||||
|
left: 2px;
|
||||||
|
transition: left 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-input:checked {
|
||||||
|
background: var(--darkred);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-input:checked::after {
|
||||||
|
left: 22px;
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
class Toggle extends Shadow {
|
||||||
|
render() {
|
||||||
|
HStack(() => {
|
||||||
|
input("", "44px", "24px")
|
||||||
|
.attr({ type: "checkbox", checked: global.profile.preferences.notifications ? "" : null, class: "toggle-input"})
|
||||||
|
.onChange(async (e) => {
|
||||||
|
await server.updateNotificationPreferences(global.profile.id, e.target.checked)
|
||||||
|
})
|
||||||
|
p("Enable Push Notifications")
|
||||||
|
.color("var(--text)")
|
||||||
|
})
|
||||||
|
.verticalAlign("center")
|
||||||
|
.gap(10, px)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
register(Toggle)
|
||||||
Reference in New Issue
Block a user