modularised webserver and auth systems
This commit is contained in:
@@ -3,11 +3,11 @@ package account
|
||||
import "projectreshoot/pkg/contexts"
|
||||
|
||||
templ ChangeBio(err string, bio string) {
|
||||
{{ user := contexts.CurrentUser(ctx) }}
|
||||
{{
|
||||
user := contexts.GetUser(ctx)
|
||||
if bio == "" {
|
||||
bio = user.Bio
|
||||
}
|
||||
if bio == "" {
|
||||
bio = user.Bio
|
||||
}
|
||||
}}
|
||||
<form
|
||||
hx-post="/change-bio"
|
||||
@@ -16,40 +16,39 @@ templ ChangeBio(err string, bio string) {
|
||||
x-data={ templ.JSFuncCall("bioComponent", bio, user.Bio, err).CallInline }
|
||||
>
|
||||
<script>
|
||||
function bioComponent(newBio, oldBio, err) {
|
||||
return {
|
||||
bio: newBio,
|
||||
initialBio: oldBio,
|
||||
err: err,
|
||||
bioLenText: '',
|
||||
updateTextArea() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.bio) {
|
||||
this.$refs.bio.style.height = 'auto';
|
||||
this.$refs.bio.style.height = `
|
||||
${this.$refs.bio.scrollHeight+20}px`;
|
||||
};
|
||||
this.bioLenText = `${this.bio.length}/128`;
|
||||
});
|
||||
},
|
||||
resetBio() {
|
||||
this.bio = this.initialBio;
|
||||
this.err = "",
|
||||
this.updateTextArea();
|
||||
},
|
||||
init() {
|
||||
this.$nextTick(() => {
|
||||
// this timeout makes sure the textarea resizes on
|
||||
// page render correctly. seems 20ms is the sweet
|
||||
// spot between a noticable delay and not working
|
||||
setTimeout(() => {
|
||||
this.updateTextArea();
|
||||
}, 20);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
function bioComponent(newBio, oldBio, err) {
|
||||
return {
|
||||
bio: newBio,
|
||||
initialBio: oldBio,
|
||||
err: err,
|
||||
bioLenText: "",
|
||||
updateTextArea() {
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.bio) {
|
||||
this.$refs.bio.style.height = "auto";
|
||||
this.$refs.bio.style.height = `
|
||||
${this.$refs.bio.scrollHeight + 20}px`;
|
||||
}
|
||||
this.bioLenText = `${this.bio.length}/128`;
|
||||
});
|
||||
},
|
||||
resetBio() {
|
||||
this.bio = this.initialBio;
|
||||
((this.err = ""), this.updateTextArea());
|
||||
},
|
||||
init() {
|
||||
this.$nextTick(() => {
|
||||
// this timeout makes sure the textarea resizes on
|
||||
// page render correctly. seems 20ms is the sweet
|
||||
// spot between a noticable delay and not working
|
||||
setTimeout(() => {
|
||||
this.updateTextArea();
|
||||
}, 20);
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<div
|
||||
class="flex flex-col"
|
||||
>
|
||||
|
||||
@@ -3,11 +3,11 @@ package account
|
||||
import "projectreshoot/pkg/contexts"
|
||||
|
||||
templ ChangeUsername(err string, username string) {
|
||||
{{ user := contexts.CurrentUser(ctx) }}
|
||||
{{
|
||||
user := contexts.GetUser(ctx)
|
||||
if username == "" {
|
||||
username = user.Username
|
||||
}
|
||||
if username == "" {
|
||||
username = user.Username
|
||||
}
|
||||
}}
|
||||
<form
|
||||
hx-post="/change-username"
|
||||
@@ -18,18 +18,18 @@ templ ChangeUsername(err string, username string) {
|
||||
).CallInline }
|
||||
>
|
||||
<script>
|
||||
function usernameComponent(newUsername, oldUsername, err) {
|
||||
return {
|
||||
username: newUsername,
|
||||
initialUsername: oldUsername,
|
||||
err: err,
|
||||
resetUsername() {
|
||||
this.username = this.initialUsername;
|
||||
this.err = "";
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
function usernameComponent(newUsername, oldUsername, err) {
|
||||
return {
|
||||
username: newUsername,
|
||||
initialUsername: oldUsername,
|
||||
err: err,
|
||||
resetUsername() {
|
||||
this.username = this.initialUsername;
|
||||
this.err = "";
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<div
|
||||
class="flex flex-col sm:flex-row"
|
||||
>
|
||||
|
||||
@@ -8,7 +8,7 @@ templ AccountContainer(subpage string) {
|
||||
@resize.window="big = window.innerWidth >= 768"
|
||||
>
|
||||
@SelectMenu(subpage)
|
||||
<div class="mt-5 w-full md:ml-[200px] ml-[40px] transition-all duration-300">
|
||||
<div class="mt-5 w-full md:ml-[200px] ml-10 transition-all duration-300">
|
||||
<div
|
||||
class="pl-5 text-2xl text-subtext1 border-b
|
||||
border-overlay0 w-[90%] mx-auto"
|
||||
|
||||
Reference in New Issue
Block a user