pinafore/routes/_components/AccountProfile.html

316 lines
8.8 KiB
HTML
Raw Normal View History

<div class="account-profile {{headerIsMissing ? 'header-is-missing' : ''}}"
style="background-image: url({{$autoplayGifs ? account.header : account.header_static}});">
2018-01-28 22:17:37 +00:00
<div class="account-profile-grid-wrapper">
<div class="account-profile-backdrop"></div>
<div class="account-profile-grid">
<div class="account-profile-avatar">
<Avatar :account size="big" />
2018-01-28 22:17:37 +00:00
</div>
<div class="account-profile-name">
<ExternalLink href="{{account.url}}" showIcon="true" normalIconColor="true">
{{account.display_name || account.acct}}
2018-01-29 03:01:51 +00:00
</ExternalLink>
2018-01-28 22:17:37 +00:00
</div>
2018-01-29 00:34:18 +00:00
<div class="account-profile-username">
{{'@' + account.acct}}
2018-01-29 00:34:18 +00:00
</div>
2018-01-28 22:17:37 +00:00
<div class="account-profile-followed-by">
{{#if relationship && relationship.followed_by}}
<span>
Follows you
</span>
{{/if}}
</div>
<div class="account-profile-follow">
{{#if verifyCredentials && relationship && verifyCredentials.id !== relationship.id}}
<IconButton
2018-03-15 05:14:06 +00:00
label="{{followLabel}}"
href="{{followIcon}}"
2018-02-19 18:59:03 +00:00
pressable="true"
pressed="{{following}}"
2018-01-28 22:17:37 +00:00
big="true"
on:click="onFollowButtonClick()"
2018-03-23 03:18:17 +00:00
animation="{{animateFollowButton && followButtonAnimation}}"
2018-01-28 22:17:37 +00:00
/>
{{/if}}
</div>
<div class="account-profile-note">
2018-02-12 07:07:48 +00:00
{{{massagedNote}}}
2018-01-28 22:17:37 +00:00
</div>
<div class="account-profile-details">
<div class="account-profile-details-item">
<span class="account-profile-details-item-title">
Toots
</span>
<span class="account-profile-details-item-datum">
{{account.statuses_count || 0}}
</span>
</div>
<div class="account-profile-details-item">
<span class="account-profile-details-item-title">
Follows
</span>
<span class="account-profile-details-item-datum">
{{account.following_count || 0}}
</span>
</div>
<div class="account-profile-details-item">
<span class="account-profile-details-item-title">
Followers
</span>
<span class="account-profile-details-item-datum">
{{account.followers_count || 0}}
</span>
</div>
</div>
2018-01-28 08:29:45 +00:00
</div>
</div>
</div>
<style>
.account-profile {
position: relative;
background-size: cover;
background-position: center;
padding-top: 175px;
}
.account-profile.header-is-missing {
padding-top: 0;
2018-01-28 20:51:48 +00:00
background-color: #ccc;
2018-01-28 08:29:45 +00:00
}
2018-01-28 22:17:37 +00:00
.account-profile-backdrop {
2018-01-28 08:29:45 +00:00
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 5;
}
.account-profile-grid {
display: grid;
2018-01-28 20:51:48 +00:00
grid-template-areas: "avatar name followed-by follow"
2018-01-29 00:34:18 +00:00
"avatar username username follow"
"avatar note note follow"
"details details details details";
2018-01-28 08:49:51 +00:00
grid-template-columns: min-content auto 1fr min-content;
2018-01-28 08:29:45 +00:00
grid-column-gap: 10px;
2018-01-29 00:34:18 +00:00
grid-row-gap: 5px;
2018-01-29 00:44:13 +00:00
padding: 20px;
2018-01-28 08:29:45 +00:00
justify-content: center;
2018-01-28 22:17:37 +00:00
z-index: 10;
position: relative;
2018-01-28 08:29:45 +00:00
}
2018-01-28 22:05:48 +00:00
@supports (-webkit-backdrop-filter: blur(1px) saturate(1%)) or (backdrop-filter: blur(1px) saturate(1%)) {
2018-01-28 22:17:37 +00:00
:global(.account-profile-grid-wrapper) {
2018-01-28 22:05:48 +00:00
-webkit-backdrop-filter: blur(7px) saturate(110%);
backdrop-filter: blur(7px) saturate(110%);
background-color: rgba(255, 255, 255, 0.7);
2018-01-28 08:29:45 +00:00
}
}
2018-01-28 22:05:48 +00:00
@supports not ((-webkit-backdrop-filter: blur(1px) saturate(1%)) or (backdrop-filter: blur(1px) saturate(1%))) {
2018-01-28 22:17:37 +00:00
:global(.account-profile-grid-wrapper) {
2018-01-28 08:29:45 +00:00
background-color: rgba(255, 255, 255, 0.9);
}
}
2018-01-28 20:51:48 +00:00
.account-profile-followed-by {
grid-area: followed-by;
2018-01-28 08:29:45 +00:00
align-self: center;
text-transform: uppercase;
color: var(--deemphasized-text-color);
font-size: 0.8em;
}
2018-01-28 20:51:48 +00:00
.account-profile-followed-by span {
2018-01-28 08:29:45 +00:00
background: rgba(30, 30, 30, 0.2);
border-radius: 4px;
padding: 3px 5px;
2018-01-28 08:49:51 +00:00
white-space: nowrap;
2018-01-28 08:29:45 +00:00
}
.account-profile-avatar {
grid-area: avatar;
}
2018-01-29 00:34:18 +00:00
.account-profile-username {
grid-area: username;
color: var(--deemphasized-text-color);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
align-self: center;
}
2018-01-28 08:29:45 +00:00
.account-profile-follow {
grid-area: follow;
2018-01-29 00:34:18 +00:00
align-self: flex-start;
2018-01-28 08:29:45 +00:00
}
.account-profile-name {
grid-area: name;
font-size: 1.5em;
align-self: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
2018-01-28 08:49:51 +00:00
min-width: 0;
2018-01-28 08:29:45 +00:00
}
2018-01-29 03:01:51 +00:00
:global(.account-profile-name a) {
2018-01-29 01:10:03 +00:00
color: var(--body-text-color);
text-decoration: none;
}
2018-01-29 03:01:51 +00:00
:global(.account-profile-name a:hover) {
2018-01-29 01:10:03 +00:00
color: var(--body-text-color);
text-decoration: underline;
}
2018-01-28 08:29:45 +00:00
.account-profile-note {
grid-area: note;
2018-01-29 00:34:18 +00:00
padding: 10px 0;
2018-01-31 06:40:40 +00:00
font-size: 0.9em;
word-wrap: break-word;
overflow: hidden;
white-space: pre-wrap;
2018-01-28 08:29:45 +00:00
}
2018-01-31 06:40:40 +00:00
2018-01-28 08:29:45 +00:00
:global(.account-profile-note p) {
2018-01-31 06:40:40 +00:00
margin: 0 0 20px;
}
:global(.account-profile-note p:first-child) {
margin: 0 0 20px;
}
:global(.account-profile-note p:last-child) {
margin: 0;
2018-01-28 08:29:45 +00:00
}
2018-01-29 00:34:18 +00:00
.account-profile-details {
grid-area: details;
display: flex;
margin: 0 5px;
}
.account-profile-details-item {
flex: 1;
display: flex;
flex-direction: row;
padding: 5px;
justify-content: center;
font-size: 1.1em;
}
.account-profile-details-item:hover {
background: var(--button-bg-hover);
cursor: pointer;
}
.account-profile-details-item:active {
background: var(--button-bg-active);
}
.account-profile-details-item-title {
text-transform: uppercase;
color: var(--deemphasized-text-color);
margin-right: 5px;
}
.account-profile-details-item-datum {
color: var(--body-text-color);
margin-left: 5px;
font-weight: 600;
}
2018-01-29 00:34:18 +00:00
@media (max-width: 767px) {
.account-profile-name {
2018-01-31 06:40:40 +00:00
font-size: 1.3em;
2018-01-29 00:34:18 +00:00
}
.account-profile-grid {
display: grid;
grid-template-areas: "avatar name follow"
"avatar username follow"
"avatar followed-by follow"
"note note note"
"details details details";
2018-01-29 00:34:18 +00:00
grid-template-columns: min-content minmax(auto, 1fr) min-content;
grid-template-rows: min-content min-content 1fr min-content;
2018-01-31 06:40:40 +00:00
padding: 10px;
2018-01-29 00:34:18 +00:00
}
.account-profile-note {
2018-01-29 00:35:35 +00:00
padding: 5px 0;
2018-01-29 00:34:18 +00:00
}
.account-profile-username {
2018-01-31 06:40:40 +00:00
font-size: 1.1em;
2018-01-29 00:34:18 +00:00
}
.account-profile-name, .account-profile-username {
align-self: flex-start;
}
}
2018-01-28 08:29:45 +00:00
</style>
<script>
2018-01-28 20:51:48 +00:00
import IconButton from './IconButton.html'
2018-01-29 03:01:51 +00:00
import ExternalLink from './ExternalLink.html'
2018-02-09 01:56:20 +00:00
import Avatar from './Avatar.html'
import { store } from '../_store/store'
import { setAccountFollowed } from '../_actions/follow'
import { database } from '../_database/database'
2018-03-23 03:18:17 +00:00
import { FOLLOW_BUTTON_ANIMATION } from '../_static/animations'
2018-01-28 20:51:48 +00:00
2018-01-28 08:29:45 +00:00
export default {
2018-03-23 03:18:17 +00:00
methods: {
async onFollowButtonClick() {
let accountId = this.get('accountId')
2018-03-23 03:18:17 +00:00
let instanceName = this.store.get('currentInstance')
let following = this.get('following')
let followRequested = this.get('followRequested')
this.set({animateFollowButton: true})
await setAccountFollowed(accountId, !(following || followRequested))
let relationship = await database.getRelationship(instanceName, accountId)
this.set({relationship})
}
},
store: () => store,
data: () => ({
followButtonAnimation: FOLLOW_BUTTON_ANIMATION
}),
2018-01-28 08:29:45 +00:00
computed: {
accountId: (account) => account.id,
headerIsMissing: (account) => account.header.endsWith('missing.png'),
note: (account) => account.note,
2018-02-12 07:07:48 +00:00
massagedNote: (note) => {
// GNU Social / Pleroma don't add <p> tags
if (!note.startsWith('<p>')) {
note = `<p>${note}</p>`
}
return note
2018-02-19 18:59:03 +00:00
},
2018-03-15 05:14:06 +00:00
following: (relationship) => relationship && relationship.following,
followRequested: (relationship, account) => {
return relationship && relationship.requested && account && account.locked
},
2018-03-15 05:14:06 +00:00
followLabel: (following, followRequested) => {
if (following) {
return 'Unfollow'
} else if (followRequested) {
return 'Unfollow (follow requested)'
} else {
return 'Follow'
}
},
followIcon: (following, followRequested) => {
if (following) {
return '#fa-user-times'
} else if (followRequested) {
return '#fa-hourglass'
} else {
return '#fa-user-plus'
}
}
2018-01-28 20:51:48 +00:00
},
components: {
2018-01-29 03:01:51 +00:00
IconButton,
ExternalLink,
Avatar
2018-01-28 08:29:45 +00:00
}
}
</script>