frontend tweaks
This commit is contained in:
@@ -1,28 +1,14 @@
|
||||
import "./AppWindow.js"
|
||||
import "./AppMenu.js"
|
||||
import "./ProfileButton.js"
|
||||
import "./InputBox.js"
|
||||
import "./Sidebar.js"
|
||||
import "./components/AppWindow.js"
|
||||
import "./components/AppMenu.js"
|
||||
import "./components/ProfileButton.js"
|
||||
import "./components/InputBox.js"
|
||||
import "./components/Sidebar.js"
|
||||
|
||||
class Home extends Shadow {
|
||||
|
||||
render() {
|
||||
ZStack(() => {
|
||||
|
||||
VStack(() => {
|
||||
img(document.documentElement.classList.contains("red") ? "/_/icons/quillblack.svg" : "/_/icons/quill.svg", "2.25em")
|
||||
.paddingLeft(3, em)
|
||||
.paddingTop(5, vh)
|
||||
.onClick(() => {
|
||||
window.navigateTo("/")
|
||||
})
|
||||
})
|
||||
.paddingRight(2, em)
|
||||
.position("fixed")
|
||||
.x(0).y(0)
|
||||
.height(100, vh)
|
||||
.borderRight("0.5px solid var(--accent)")
|
||||
.zIndex(3)
|
||||
Sidebar()
|
||||
|
||||
switch(window.location.pathname) {
|
||||
case "/":
|
||||
@@ -81,7 +67,6 @@ class Home extends Shadow {
|
||||
.xRight(2, em).y(2.3, em)
|
||||
.position("fixed")
|
||||
.verticalAlign("center")
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,8 @@ class AppMenu extends Shadow {
|
||||
.trim();
|
||||
}
|
||||
HStack(() => {
|
||||
img(cssVariable("house-src"), "1.7em")
|
||||
img(cssVariable("people-src"), "1.9em")
|
||||
img(cssVariable("house-src"), "1.5em")
|
||||
img(cssVariable("people-src"), "1.7em")
|
||||
})
|
||||
.justifyContent("center")
|
||||
.gap(3.5, em)
|
||||
@@ -34,7 +34,7 @@ class AppMenu extends Shadow {
|
||||
.x(0).yBottom(0)
|
||||
.width(100, vw)
|
||||
.paddingVertical(1, em)
|
||||
.borderTop("1px solid var(--accent)")
|
||||
.borderTop("0.5px solid var(--accent)")
|
||||
.onNavigate(() => {
|
||||
if(window.location.pathname === "/") {
|
||||
this.styleMaximized()
|
||||
|
||||
@@ -1,39 +1,46 @@
|
||||
css(`
|
||||
side-bar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100vh;
|
||||
width: 16vw;
|
||||
border-right: 0.5px solid var(--accent2);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-top: 13vh;
|
||||
}
|
||||
|
||||
side-bar button {
|
||||
color: var(--darkbrown);
|
||||
margin: 1.5em;
|
||||
background-color: color-mix(in srgb, var(--accent2) 35%, var(--orange) 65%);
|
||||
border: 1px solid var(--orange);
|
||||
border-radius: 12px;
|
||||
padding: 0.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
`)
|
||||
|
||||
|
||||
class Sidebar extends HTMLElement {
|
||||
connectedCallback() {
|
||||
this.render()
|
||||
}
|
||||
|
||||
class Sidebar extends Shadow {
|
||||
render() {
|
||||
this.innerHTML = /* html */ `
|
||||
<span id="title" style="position: absolute; left: 50%; transform: translateX(-50%) " class="link" onclick='window.location.href="/"'>hyperia</span>
|
||||
<button>Main</button>
|
||||
`
|
||||
VStack(() => {
|
||||
img(document.documentElement.classList.contains("red") ? "/_/icons/quillblack.svg" : "/_/icons/quill.svg", "2.25em")
|
||||
.paddingLeft(3, em)
|
||||
.paddingTop(5, vh)
|
||||
.onClick(() => {
|
||||
window.navigateTo("/")
|
||||
})
|
||||
})
|
||||
.paddingRight(2, em)
|
||||
.position("fixed")
|
||||
.x(0).y(0)
|
||||
.height(100, vh)
|
||||
.borderRight("0.5px solid var(--accent)")
|
||||
.zIndex(3)
|
||||
.onAppear(async () => {
|
||||
if(!window.profile) {
|
||||
window.profile = await this.fetchProfile()
|
||||
this.rerender()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async fetchProfile() {
|
||||
try {
|
||||
const res = await fetch("/profile", {
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
});
|
||||
|
||||
if (!res.ok) throw new Error("Failed to fetch profile");
|
||||
|
||||
const profile = await res.json();
|
||||
console.log(profile);
|
||||
return profile
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("side-bar", Sidebar)
|
||||
register(Sidebar)
|
||||
@@ -1,5 +1,5 @@
|
||||
import Socket from "./ws/Socket.js"
|
||||
import "./components/Home.js"
|
||||
import "./Home.js"
|
||||
|
||||
import util from "./util.js"
|
||||
window.util = util
|
||||
|
||||
Reference in New Issue
Block a user