redesign profile template

This commit is contained in:
f0x 2023-05-10 20:18:49 +02:00
parent 2a44a49979
commit c200c79bcd
3 changed files with 280 additions and 261 deletions

View file

@ -16,274 +16,246 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
header { .page {
a img { grid-template-columns: 1fr minmax(auto, 60rem) 1fr;
height: 5rem; grid-template-columns: 1fr min(92%, 65rem) 1fr;
}
} }
main { main.profile {
background: $gray2;
background: transparent; background: transparent;
padding-top: 0; padding: 0.5rem;
border-radius: $br;
display: grid;
grid-template-rows: auto auto;
grid-template-columns: 35fr 65fr;
grid-template-areas:
"header header"
"about toots";
gap: 1rem;
} }
.profile { main.profile .header {
grid-area: header;
background: $bg-accent; background: $bg-accent;
display: grid;
grid-template-columns: 100%;
gap: 0.5rem;
margin-bottom: 0.2rem;
overflow-x: hidden;
position: relative;
border-radius: $br; border-radius: $br;
box-shadow: $boxshadow; overflow: hidden;
border: $boxshadow-border;
.headerimage { .header-image {
width: 100%; position: relative;
aspect-ratio: 3 / 1; padding-top: 33.33%; /* aspect-ratio 1/3 */
max-height: 16rem;
overflow: hidden;
box-shadow: $boxshadow;
img { img {
position: absolute;
top: 0;
left: 0;
right: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
border-radius: $br-inner $br-inner 0 0;
} }
} }
.basic { /*
height: 8.5rem; Basic info container has the user's avatar, display- and username, and role
margin-top: -6.5rem; It's partially overlapped over the header image, by a negative margin-top
*/
.basic-info {
$avatar-size: 8.5rem;
$name-size: 3rem;
$username-size: 2rem;
$overlap: calc($avatar-size - $name-size - $username-size);
position: relative;
display: grid; display: grid;
grid-template-columns: 1rem 8.5rem 1fr; box-sizing: border-box;
grid-template-rows: 3rem 3rem 2.5rem; grid-template-columns: $avatar-size auto 1fr;
grid-template-rows: $overlap $name-size auto;
grid-template-areas: grid-template-areas:
". avatar ." "avatar . ."
"filler2 avatar displayname" "avatar displayname displayname"
". avatar username"; "avatar username role";
#profile-basic-filler2 { margin: 1rem;
grid-area: filler2; margin-top: calc(-1 * $overlap);
background: $bg-trans; gap: 0 1rem;
}
.avatar { .avatar {
align-self: end;
box-sizing: border-box;
height: 8.5rem;
width: 8.5rem;
grid-area: avatar; grid-area: avatar;
background: $bg; height: $avatar-size;
width: $avatar-size;
border: 0.2rem solid $avatar-border; border: 0.2rem solid $avatar-border;
padding: 0;
border-radius: $br; border-radius: $br;
position: relative; overflow: hidden; /* prevents image extending beyond rounded borders */
box-shadow: $boxshadow;
img { img {
object-fit: cover;
border-radius: $br-inner;
width: 100%;
height: 100%; height: 100%;
width: 100%;
object-fit: cover;
} }
} }
a, div {
color: inherit;
text-decoration: none;
}
.displayname { .displayname {
grid-area: displayname; grid-area: displayname;
font-weight: bold; line-height: $name-size;
font-size: 2rem; font-size: 2rem;
line-height: 3rem; font-weight: bold;
background: $bg-trans;
word-break: break-all;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
max-height: 6rem;
padding: 0 0.5rem;
} }
.usernamecontainer { .username {
height: 2.5rem; min-width: 0;
display: grid;
grid-template-columns: auto 1fr;
grid-area: username; grid-area: username;
/* justify-content: space-between; */ line-height: $username-size;
padding: 0;
gap: 0.5rem; font-size: 1rem;
position: relative; font-weight: bold;
color: $fg-accent; color: $fg-accent;
user-select: all;
}
.role {
grid-area: role;
align-self: center;
justify-self: start;
border: 0.13rem solid $gray1;
border-radius: $br;
padding: 0.3rem;
line-height: 1.1rem;
font-size: 0.9rem;
font-variant: small-caps;
font-weight: bold; font-weight: bold;
.username { &.admin {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
user-select: all;
line-height: 2.5rem;
padding-left: 0;
margin-left: 0.5rem;
}
.role {
justify-self: start;
align-self: center;
line-height: 1.1rem;
font-size: 0.9rem;
margin-right: 0.2rem;
padding: 0.2rem;
margin-top: 0.1rem;
padding-top: 0.1rem;
border: 0.1rem solid $gray1;
border-radius: $br;
font-variant: small-caps;
}
.role.admin {
background: $gray1; background: $gray1;
color: $orange2; color: $orange2;
border-color: $orange2; border-color: $orange2;
} }
.role.moderator { &.moderator {
background: $gray1; background: $gray1;
color: $blue2; color: $blue2;
border-color: $blue1; border-color: $blue1;
} }
} }
} }
}
@media screen and (max-width: 600px) { main.profile {
& { .col-header {
gap: 0.1rem;
}
.basic {
margin-top: calc(-22vw + 1rem);
height: initial;
display: flex;
flex-direction: column;
#profile-basic-filler2 {
display: none;
}
.avatar {
align-self: flex-start;
margin-left: 1rem;
height: 22vw;
width: 22vw;
}
.displayname {
padding-left: 1rem;
font-size: 1.5rem;
line-height: 2rem;
margin-top: 0.5rem;
align-self: stretch;
}
.usernamecontainer {
padding-left: 1rem;
.username {
margin-left: 0;
}
}
}
}
.detailed {
display: flex; display: flex;
flex-direction: column; justify-content: start;
flex: 1 1 25em; gap: 2rem;
align-items: center;
h2 { margin: 0;
margin-top: 0; background: $gray4;
border-top-left-radius: $br;
border-top-right-radius: $br;
padding: 0.75rem;
h3 {
font-size: 1.2rem;
line-height: 1.3rem;
margin: 0;
} }
.bio { &.pinned {
margin-top: 0; margin: 0 1rem;
margin-bottom: 0.5rem; display: grid;
margin-left: 1rem; grid-template-columns: auto 1fr;
margin-right: 1rem; gap: 1rem;
word-break: break-word;
a { a {
color: $acc1; justify-self: end;
text-decoration: underline;
} }
} }
} }
} }
.accountstats { main.profile .toots {
display: flex; grid-area: toots;
flex-wrap: wrap;
border-radius: 0 0 $br $br;
border-top: 0.1rem solid $bg;
.entry-group { display: flex;
flex: 1 1 auto; flex-direction: column;
min-width: 50%; gap: 0.4rem;
.col-header {
margin: 0;
background: $gray4;
border-top-left-radius: $br;
border-top-right-radius: $br;
padding: 0.75rem;
}
.toot {
padding-top: 0.75rem;
box-shadow: none;
border: none;
.contentgrid {
padding: 0 0.75rem;
}
.info {
padding: 0.3rem 0.75rem;
}
&:first-child {
border-radius: 0;
}
}
}
main.profile .about-user {
grid-area: about;
border-radius: $br;
overflow: hidden;
.col-header {
margin-bottom: -0.25rem;
}
.fields {
background: $gray4;
display: flex; display: flex;
flex-direction: column;
padding: 0.5rem;
padding-top: 0.25rem;
.field {
padding: 0.25rem;
display: flex;
flex-direction: column;
border-bottom: 0.1rem solid $gray2;
word-break: break-all;
&:first-child {
border-top: 0.1rem solid $gray2;
}
b {
color: $fg-accent;
}
}
} }
.entry { .bio {
white-space: nowrap; background: $gray4;
width: 50%; padding: 0 0.75rem;
margin: 1.2rem 0.5rem; padding-bottom: 0.75rem;
text-align: center;
}
}
.nothinghere {
margin-left: 1rem;
}
.backnextlinks {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
a {
padding: 1rem;
} }
.next { .accountstats {
margin-left: auto; background: $bg-accent;
padding: 0.75rem;
display: grid;
grid-template-columns: auto 1fr;
gap: 0.25rem 1rem;
} }
} }
.toot, .toot:last-child {
box-shadow: $boxshadow;
}
#recent, #pinned {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
margin: 1rem;
.rss-icon {
font-size: 1.45em;
object-fit: contain;
vertical-align: middle;
color: $orange2;
/* can't size a single-color background, so we use a linear-gradient that's effectively white */
background: linear-gradient(to right, $white1 100%, transparent 0) no-repeat center center;
background-size: 1.2rem 1.4rem;
}
}

View file

@ -60,3 +60,20 @@ Array.from(document.getElementsByClassName("spoiler-label")).forEach((label) =>
label.addEventListener("click", () => { setTimeout(update, 1); }); label.addEventListener("click", () => { setTimeout(update, 1); });
} }
}); });
Array.from(document.getElementsByClassName("spoiler-details")).forEach((spoiler) => {
const button = spoiler.getElementsByClassName("button")[0];
if (button != undefined) {
function update() {
if (spoiler.open) {
button.textContent = "Show less";
} else {
button.textContent = "Show more";
}
}
update();
spoiler.addEventListener("toggle", update);
}
});

View file

@ -18,80 +18,110 @@
*/ -}} */ -}}
{{ template "header.tmpl" .}} {{ template "header.tmpl" .}}
<main>
<div class="profile"> <main class="profile">
<div class="headerimage"> <div class="header">
<div class="header-image">
{{ if .account.Header }} {{ if .account.Header }}
<img <img src="{{.account.Header}}" alt="" />
src="{{.account.Header}}"
alt="{{if .account.DisplayName}}{{.account.DisplayName}}{{else}}{{.account.Username}}{{end}}'s header"
/>
{{ end }} {{ end }}
</div> </div>
<div class="basic"> <div class="basic-info">
<div id="profile-basic-filler2"></div> <a class="avatar" href="{{.account.Avatar}}">
<a href="{{.account.Avatar}}" class="avatar"><img src="{{.account.Avatar}}" alt="{{if .account.DisplayName}}{{.account.DisplayName}}{{else}}{{.account.Username}}{{end}}'s avatar"></a> <img src="{{.account.Avatar}}" alt="">
<div class="displayname">{{if .account.DisplayName}}{{emojify .account.Emojis (escape .account.DisplayName)}}{{else}}{{.account.Username}}{{end}}</div> </a>
<div class="usernamecontainer"> <span class="displayname text-cutoff">
<div class="username">@{{ .account.Username }}@{{ .instance.AccountDomain }}</div> {{if .account.DisplayName}}
{{- /* Only render account role if 1. it's present and 2. it's not equal to the standard 'user' role */ -}} {{emojify .account.Emojis (escape .account.DisplayName)}}
{{ if and (.account.Role) (ne .account.Role.Name "user") }}<div class="role {{ .account.Role.Name }}">{{ .account.Role.Name }}</div>{{ end }} {{else}}
</div> {{.account.Username}}
</div> {{end}}
<div class="detailed"> <span class="sr-only">.</span>
<div class="bio"> </span>
{{ if .account.Note }}{{emojify .account.Emojis (noescape .account.Note)}}{{else}}This GoToSocial user hasn't written a bio yet!{{end}} <span class="username text-cutoff">@{{.account.Username}}<span class="sr-only">,
</div> </span>{{acctInstance .account.Acct}}</span>
</div> {{- /* Only render account role if 1. it's present and 2. it's not equal to the standard 'user' role */ -}}
<div class="accountstats"> {{ if and (.account.Role) (ne .account.Role.Name "user") }}
<div class="entry-group"> <div class="role {{ .account.Role.Name }}">
<div class="entry">Joined <b>{{.account.CreatedAt | timestampVague}}</b></div> <span class="sr-only">Role: </span>{{ .account.Role.Name }}
<div class="entry">Followed by <b>{{.account.FollowersCount}}</b></div>
</div>
<div class="entry-group">
<div class="entry">Following <b>{{.account.FollowingCount}}</b></div>
<div class="entry">Posted <b>{{.account.StatusesCount}}</b></div>
</div> </div>
{{ end }}
<!-- <a class="rss-icon-link" href="/@admin/feed.rss" aria-label="RSS feed">
<i class="rss-icon fa fa-rss-square" aria-hidden="true"></i>
</a> -->
</div> </div>
</div> </div>
<div class="about-user">
<div class="col-header">
<h3>About</h3>
</div>
<div class="fields">
{{ range .account.Fields }}
<div class="field">
<b>{{.Name}}</b>
<span>{{.Value}}</span>
</div>
{{ end }}
</div>
<div class="bio">
{{ if .account.Note }}
{{emojify .account.Emojis (noescape .account.Note)}}
{{else}}
This GoToSocial user hasn't written a bio yet!
{{end}}
</div>
<div class="accountstats">
<b>Joined</b><time datetime="{{.account.CreatedAt}}">{{.account.CreatedAt | timestampVague}}</time>
<b>Posts</b><span>{{.account.StatusesCount}}</span>
<b>Followed by</b><span>{{.account.FollowersCount}}</span>
<b>Following</b><span>{{.account.FollowingCount}}</span>
</div>
</div>
<div class="toots">
{{ if .pinned_statuses }} {{ if .pinned_statuses }}
<h2 id="pinned"> <div class="col-header pinned">
<span>Pinned toots</span> <h3>Pinned posts</h3>
</h2> <a href="#recent">jump to recent</a>
<div class="thread"> </div>
<section class="thread">
{{ range .pinned_statuses }} {{ range .pinned_statuses }}
<div class="toot expanded"> <article class="toot expanded" id="{{.ID}}">
{{ template "status.tmpl" .}} {{ template "status.tmpl" .}}
</div> </article>
{{ end }} {{ end }}
</section>
{{ end }}
<div class="col-header" id="recent">
<h3>Recent posts</h3>
</div> </div>
{{ end }}
<h2 id="recent"> <section class="thread">
<span>Latest public toots</span> {{ if not .statuses }}
{{ if .rssFeed }} <div data-nosnippet class="nothinghere">Nothing here!</div>
<a href="{{ .rssFeed }}" aria-label="RSS feed"> {{ else }}
<i class="rss-icon fa fa-rss-square" aria-hidden="true"></i>
</a>
{{ end }}
</h2>
{{ if not .statuses }}
<div data-nosnippet class="nothinghere">Nothing here!</div>
{{ else }}
<div class="thread">
{{ range .statuses }} {{ range .statuses }}
<div class="toot expanded"> <article class="toot expanded" id="{{.ID}}">
{{ template "status.tmpl" .}} {{ template "status.tmpl" .}}
</div> </article>
{{ end }}
{{ end }}
</section>
<div class="backnextlinks">
{{ if .show_back_to_top }}
<a href="/@{{ .account.Username }}">Back to top</a>
{{ end }}
{{ if .statuses_next }}
<a href="{{ .statuses_next }}" class="next">Show older</a>
{{ end }} {{ end }}
</div> </div>
{{ end }}
<div class="backnextlinks">
{{ if .show_back_to_top }}
<a href="/@{{ .account.Username }}">Back to top</a>
{{ end }}
{{ if .statuses_next }}
<a href="{{ .statuses_next }}" class="next">Show older</a>
{{ end }}
</div> </div>
</main> </main>
{{ template "footer.tmpl" .}}
{{ template "footer.tmpl" .}}