✨ Personalize
This commit is contained in:
@ -107,6 +107,12 @@
|
||||
display: unset;
|
||||
}
|
||||
|
||||
.columns-two {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.wrapper-card {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
|
@ -78,10 +78,66 @@
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.logo {
|
||||
margin-left: -8px;
|
||||
margin-bottom: -8px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-block-start: 0.33em;
|
||||
margin-block-end: 0.33em;
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
.caption {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.action-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.8rem 0;
|
||||
}
|
||||
|
||||
.action-form-buttons {
|
||||
display: flex;
|
||||
justify-content: end;
|
||||
margin-top: 8px;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.block-field {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.responsive-hidden {
|
||||
display: unset;
|
||||
}
|
||||
|
||||
.columns-two {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.divider {
|
||||
margin: 1rem 0.2rem;
|
||||
border-top: 1px solid var(--md-sys-color-on-surface);
|
||||
border-left: none !important;
|
||||
border-right: none !important;
|
||||
border-bottom: none !important;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.wrapper-card {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.responsive-title-gap {
|
||||
height: calc(56px + 0.44rem);
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</html>
|
||||
|
@ -64,12 +64,4 @@
|
||||
<md-filled-button type="submit">{{.i18n.next}}</md-filled-button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.columns-two {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
</style>
|
||||
</div>
|
@ -3,11 +3,14 @@
|
||||
<link rel="stylesheet" href="https://unpkg.com/@tailwindcss/typography@0.1.2/dist/typography.min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@1.4.6/dist/utilities.min.css">
|
||||
|
||||
<div class="left-part name-card">
|
||||
{{$bannerLength := len .userinfo.Banner}} {{if gt $bannerLength 0}}
|
||||
<div class="banner-container">
|
||||
{{if gt (len .userinfo.Banner) 0}}
|
||||
<img src="/api/avatar/{{.userinfo.Banner}}" alt="Banner" class="banner">
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{$avatarLength := len .userinfo.Avatar}} {{if gt $avatarLength 0}}
|
||||
<div class="left-part name-card">
|
||||
{{if gt (len .userinfo.Avatar) 0}}
|
||||
<img src="/api/avatar/{{.userinfo.Avatar}}" alt="Avatar" class="avatar">
|
||||
{{else}}
|
||||
<div class="avatar empty">
|
||||
@ -19,7 +22,7 @@
|
||||
<h2 class="username">{{.userinfo.Nick}}</h2>
|
||||
<h6 class="nickname">@{{.userinfo.Name}}</h6>
|
||||
</div>
|
||||
{{$descriptionLength := len .userinfo.Description}} {{if gt $descriptionLength 0}}
|
||||
{{if gt (len .userinfo.Description) 0}}
|
||||
<div class="description">{{.userinfo.Description}}</div>
|
||||
{{else}}
|
||||
<div class="description empty">No description yet.</div>
|
||||
@ -36,7 +39,7 @@
|
||||
Personalize
|
||||
<span slot="icon" class="material-symbols-outlined">palette</span>
|
||||
</md-filled-tonal-button>
|
||||
<md-filled-tonal-button class="action" href="/users/me/security">
|
||||
<md-filled-tonal-button disabled class="action" href="/users/me/security">
|
||||
Security
|
||||
<span slot="icon" class="material-symbols-outlined">security</span>
|
||||
</md-filled-tonal-button>
|
||||
@ -66,6 +69,18 @@
|
||||
color: var(--md-sys-color-on-secondary);
|
||||
}
|
||||
|
||||
.banner-container {
|
||||
grid-column: span 2;
|
||||
}
|
||||
|
||||
.banner {
|
||||
display: block;
|
||||
object-fit: cover;
|
||||
border-radius: 28px;
|
||||
height: 180px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.name-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
138
pkg/views/users/personalize.gohtml
Normal file
138
pkg/views/users/personalize.gohtml
Normal file
@ -0,0 +1,138 @@
|
||||
<div class="left-part">
|
||||
<img class="logo" alt="Logo" src="/favicon.png" width="64" height="64"/>
|
||||
|
||||
<h1 class="title">Personalize</h1>
|
||||
<p class="caption">Personalize your account, and make us provide better service for you.</p>
|
||||
</div>
|
||||
|
||||
<div class="right-part">
|
||||
<div class="responsive-title-gap"></div>
|
||||
|
||||
<div class="action-form">
|
||||
<div class="input-label">Avatar</div>
|
||||
<input
|
||||
id="avatar-input"
|
||||
class="block-field"
|
||||
name="avatar"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
placeholder="Avatar"
|
||||
>
|
||||
|
||||
<div class="input-label">Banner</div>
|
||||
<input
|
||||
id="banner-input"
|
||||
class="block-field"
|
||||
name="banner"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
placeholder="Banner"
|
||||
>
|
||||
</div>
|
||||
|
||||
<hr class="divider"/>
|
||||
|
||||
<form class="action-form" action="/users/me/personalize" method="POST">
|
||||
<div class="columns-two">
|
||||
<md-outlined-text-field
|
||||
class="block-field"
|
||||
name="name"
|
||||
type="text"
|
||||
autocomplete="username"
|
||||
label="Username"
|
||||
disabled
|
||||
value="{{.userinfo.Name}}"
|
||||
>
|
||||
</md-outlined-text-field>
|
||||
|
||||
<md-outlined-text-field
|
||||
class="block-field"
|
||||
name="nick"
|
||||
type="text"
|
||||
autocomplete="nickname"
|
||||
label="Nickname"
|
||||
value="{{.userinfo.Nick}}"
|
||||
>
|
||||
</md-outlined-text-field>
|
||||
</div>
|
||||
|
||||
<div class="columns-two">
|
||||
<md-outlined-text-field
|
||||
class="block-field"
|
||||
name="first_name"
|
||||
type="text"
|
||||
autocomplete="given_name"
|
||||
label="First Name"
|
||||
value="{{if gt (len .userinfo.Profile.FirstName) 0}}{{.userinfo.Profile.FirstName}}{{end}}"
|
||||
>
|
||||
</md-outlined-text-field>
|
||||
|
||||
<md-outlined-text-field
|
||||
class="block-field"
|
||||
name="last_name"
|
||||
type="text"
|
||||
autocomplete="family_name"
|
||||
label="Last Name"
|
||||
value="{{if gt (len .userinfo.Profile.LastName) 0}}{{.userinfo.Profile.LastName}}{{end}}"
|
||||
>
|
||||
</md-outlined-text-field>
|
||||
</div>
|
||||
|
||||
<md-outlined-text-field
|
||||
class="block-field"
|
||||
name="birthday"
|
||||
type="date"
|
||||
label="Birthday"
|
||||
value="{{if ne .birthday nil}}{{.birthday}}{{end}}"
|
||||
>
|
||||
</md-outlined-text-field>
|
||||
|
||||
<md-outlined-text-field
|
||||
class="block-field"
|
||||
name="description"
|
||||
type="textarea"
|
||||
autocomplete="off"
|
||||
label="Description"
|
||||
value="{{if gt (len .userinfo.Description) 0}}{{.userinfo.Description}}{{end}}"
|
||||
style="resize: vertical"
|
||||
>
|
||||
</md-outlined-text-field>
|
||||
|
||||
<div class="action-form-buttons">
|
||||
<md-text-button type="button" href="/users/me">{{.i18n.back}}</md-text-button>
|
||||
<md-filled-button type="submit">{{.i18n.apply}}</md-filled-button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.input-label {
|
||||
font-size: 14px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
document.getElementById("avatar-input").addEventListener("input", (evt) => {
|
||||
if (!evt.target.files) return
|
||||
const data = new FormData();
|
||||
data.set("avatar", evt.target.files[0])
|
||||
fetch("/api/users/me/avatar", {
|
||||
method: "PUT",
|
||||
body: data,
|
||||
}).then(() => {
|
||||
location.href = "/users/me"
|
||||
})
|
||||
})
|
||||
document.getElementById("banner-input").addEventListener("input", (evt) => {
|
||||
if (!evt.target.files) return
|
||||
const data = new FormData();
|
||||
data.set("banner", evt.target.files[0])
|
||||
fetch("/api/users/me/banner", {
|
||||
method: "PUT",
|
||||
body: data,
|
||||
}).then(() => {
|
||||
location.href = "/users/me"
|
||||
})
|
||||
})
|
||||
</script>
|
Reference in New Issue
Block a user