improving styling, fixing bugs with profile, login error handling

This commit is contained in:
metacryst
2026-03-19 07:41:18 -05:00
parent 3a5214ed45
commit 5a56dfa051
9 changed files with 107 additions and 45 deletions

View File

@@ -5,6 +5,10 @@
"ios": { "ios": {
"allowsBackForwardNavigationGestures": true "allowsBackForwardNavigationGestures": true
}, },
"server": {
"url": "http://sam.local:5173",
"cleartext": true
},
"plugins": { "plugins": {
"SplashScreen": { "SplashScreen": {
"launchAutoHide": true "launchAutoHide": true

View File

@@ -44,7 +44,7 @@ class AuthPage extends Shadow {
this.rerender(); this.rerender();
}) })
p("Signup") p("Sign Up")
.fontWeight(this.selectedPage === 2 ? "bold" : "normal") .fontWeight(this.selectedPage === 2 ? "bold" : "normal")
.padding(0.75, em) .padding(0.75, em)
.borderRadius(12, px) .borderRadius(12, px)
@@ -54,6 +54,7 @@ class AuthPage extends Shadow {
this.rerender(); this.rerender();
}) })
}) })
.fontFamily("Arial")
.padding(0.25, em) .padding(0.25, em)
.borderRadius(12, px) .borderRadius(12, px)
.background("var(--accent)") .background("var(--accent)")
@@ -61,7 +62,7 @@ class AuthPage extends Shadow {
.horizontalAlign("center") .horizontalAlign("center")
.margin("auto") .margin("auto")
.marginTop(7.5, em) .marginTop(7.5, em)
.marginBottom(0, em) .marginBottom(2, em)
.gap(0.5, em) .gap(0.5, em)
switch (this.selectedPage) { switch (this.selectedPage) {

View File

@@ -29,12 +29,14 @@ class Login extends Shadow {
.marginVertical(1, em) .marginVertical(1, em)
.padding(1, em) .padding(1, em)
.styles(this.inputStyles) .styles(this.inputStyles)
input("Password", "70vw") input("Password", "70vw")
.attr({ name: "password", type: "password" }) .attr({ name: "password", type: "password" })
.margin("auto") .margin("auto")
.marginVertical(1, em) .marginVertical(1, em)
.padding(1, em) .padding(1, em)
.styles(this.inputStyles) .styles(this.inputStyles)
HStack(() => { HStack(() => {
button("==>") button("==>")
.padding(1, em) .padding(1, em)
@@ -44,6 +46,13 @@ class Login extends Shadow {
.color("var(--text)") .color("var(--text)")
.border("1px solid var(--accent)") .border("1px solid var(--accent)")
.boxSizing("border-box") .boxSizing("border-box")
.onTouch(function (start) {
if (start) {
this.style.backgroundColor = "var(--accent)"
} else {
this.style.backgroundColor = "var(--searchbackground)"
}
})
}) })
.width(70, vw) .width(70, vw)
.margin("auto") .margin("auto")
@@ -52,23 +61,57 @@ class Login extends Shadow {
.paddingRight(2, em) .paddingRight(2, em)
.marginVertical(1, em) .marginVertical(1, em)
.border("1px solid transparent") .border("1px solid transparent")
p("")
.dynamicText("errortype", "Please enter a valid {{}}.")
.margin("auto")
.marginTop(1, em)
.color("var(--text)")
.fontFamily("Arial")
.opacity(.7)
.padding(0.5, em)
.backgroundColor("var(--darkred)")
.display("none")
}) })
}) })
.height(100, pct) .height(100, pct)
.onSubmit(async (e) => { .onSubmit(async (e) => {
e.preventDefault(); e.preventDefault();
const data = new FormData(e.target); const data = {
email: e.target.$('[name="email"]').value,
password: e.target.$('[name="password"]').value,
};
await this.requestLogin(data); await this.requestLogin(data);
}) })
} }
isValidEmail = (email) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
isValidPassword = (password) => password.length >= 7;
async requestLogin(data) { async requestLogin(data) {
const emailValid = this.isValidEmail(data.email.trim() || "");
const passValid = this.isValidPassword(data.password.trim() || "");
if (!emailValid || !passValid) {
console.log("invalid", emailValid)
const errorType = !emailValid ? 'email' : 'password';
this.$("p")
.display("")
.attr({ errorType });
return;
} else {
this.$("p").style.display = "none"
}
const res = await fetch(`${util.HOST}/login`, { const res = await fetch(`${util.HOST}/login`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json", "X-Client": "mobile" }, headers: { "Content-Type": "application/json", "X-Client": "mobile" },
body: JSON.stringify({ body: JSON.stringify({
email: data.get("email"), email: data["email"],
password: data.get("password") password: data["password"]
}) })
}); });

View File

@@ -25,12 +25,13 @@ class Profile extends Shadow {
render() { render() {
ZStack(() => { ZStack(() => {
p("X") p("< Back")
.color("var(--quillred") .color("var(--darkred)")
.fontSize(4, em) .fontSize(1.5, em)
.position("absolute") .position("absolute")
.top(0.5, rem) .fontFamily("Arial")
.right(2, rem) .top(2, rem)
.left(2, rem)
.zIndex(1001) .zIndex(1001)
.onClick(() => { .onClick(() => {
$("appwindowcontainer-").closeProfile() $("appwindowcontainer-").closeProfile()

View File

@@ -81,12 +81,13 @@
input::placeholder { input::placeholder {
font-family: Arial; font-family: Arial;
} }
html, html,
body { body {
padding: 0; padding: 0;
margin: 0; margin: 0;
font-family: Arial;
} }
body { body {

View File

@@ -118,7 +118,6 @@ class Jobs extends Shadow {
} }
checkForUpdates(currentJobs, fetchedJobs) { checkForUpdates(currentJobs, fetchedJobs) {
console.log(currentJobs, fetchedJobs)
if (currentJobs.length !== fetchedJobs.length) return true; if (currentJobs.length !== fetchedJobs.length) return true;
const currentMap = new Map(currentJobs.map(job => [job.id, job])); const currentMap = new Map(currentJobs.map(job => [job.id, job]));

View File

@@ -15,9 +15,9 @@ class AppWindowContainer extends Shadow {
.width(100, pct) .width(100, pct)
.gap(0) .gap(0)
if (this.isProfileOpen) {
Profile() Profile()
} .display("none")
.zIndex(3)
}) })
.height(100, pct) .height(100, pct)
.overflowY("hidden") .overflowY("hidden")
@@ -26,13 +26,11 @@ class AppWindowContainer extends Shadow {
} }
openProfile() { openProfile() {
this.isProfileOpen = true this.$("profile-").display("")
this.rerender()
} }
closeProfile() { closeProfile() {
this.isProfileOpen = false this.$("profile-").display("none")
this.rerender()
} }
} }

View File

@@ -6,14 +6,11 @@ class Sidebar extends Shadow {
return p(text) return p(text)
.fontSize(1.5, em) .fontSize(1.5, em)
.fontWeight("bold") .fontWeight("bold")
.fontFamily("Sedan SC") .fontFamily("Arial")
.marginLeft(2, em) .marginLeft(2, em)
.fontStyle("italic") .onClick(function (done) {
.onClick(function () { // BUG -- Fires twice every time if(done) {
if(this.innerText === "Home") { if (this.innerText === "Logout") {
window.navigateTo("/")
return
} else if (this.innerText === "Logout") {
$("sidebar-").close() $("sidebar-").close()
global.onLogout() global.onLogout()
return return
@@ -22,15 +19,13 @@ class Sidebar extends Shadow {
$("sidebar-").close() $("sidebar-").close()
return return
} }
window.navigateTo(this.innerText.toLowerCase().replace(/\s+/g, "")) }
}) })
} }
render() { render() {
VStack(() => { VStack(() => {
this.SidebarItem("Profile") this.SidebarItem("Profile")
this.SidebarItem("Home")
this.SidebarItem("Map")
this.SidebarItem("Logout") this.SidebarItem("Logout")
}) })
.gap(2, em) .gap(2, em)

View File

@@ -1,6 +1,7 @@
/* /*
Sam Russell Sam Russell
Captured Sun Captured Sun
2.19.26 - Adding dynamicText()
2.16.26 - Adding event objects to the onTouch callbacks 2.16.26 - Adding event objects to the onTouch callbacks
1.16.26 - Moving nav event dispatch out of pushState, adding null feature to attr() 1.16.26 - Moving nav event dispatch out of pushState, adding null feature to attr()
1.5.26 - Switching verticalAlign and horizontalAlign names, adding borderVertical and Horizontal 1.5.26 - Switching verticalAlign and horizontalAlign names, adding borderVertical and Horizontal
@@ -691,6 +692,24 @@ HTMLElement.prototype.horizontalAlign = function (value) {
/* Elements */ /* Elements */
HTMLElement.prototype.dynamicText = function(attr, template) {
// Set initial text if attr already has a value
if (attr !== attr.toLowerCase()) {
throw new Error(`quill: dynamicText() attr "${attr}" must be lowercase`);
}
if (this.getAttribute(attr)) {
this.innerText = template.replace('{{}}', this.getAttribute(attr));
}
new MutationObserver(() => {
console.log("mutateing")
const value = this.getAttribute(attr);
this.innerText = template.replace('{{}}', value ?? '');
}).observe(this, { attributes: true, attributeFilter: [attr] });
return this
};
quill.setChildren = function(el, innerContent) { quill.setChildren = function(el, innerContent) {
if(typeof innerContent === "string") { if(typeof innerContent === "string") {
el.innerText = innerContent el.innerText = innerContent
@@ -1204,5 +1223,6 @@ HTMLElement.prototype.attr = function(attributes) {
this.setAttribute(key, value); this.setAttribute(key, value);
} }
} }
return this; return this;
}; };