semaphore/src/routes/_components/profile/AccountProfileDetails.html

118 lines
3.1 KiB
HTML

<h2 class="sr-only">{intl.statisticsAndMoreOptions}</h2>
<div class="account-profile-details">
<div class="account-profile-details-item">
<span class="account-profile-details-item-datum">
{numStatusesDisplay}
</span>
<span class="account-profile-details-item-title">
{intl.statuses}
</span>
</div>
<a class="account-profile-details-item"
href='/accounts/{account.id}/follows'
aria-label={followingLabel}
rel="prefetch"
>
<span class="account-profile-details-item-datum">
{numFollowingDisplay}
</span>
<span class="account-profile-details-item-title">
{intl.follows}
</span>
</a>
<a class="account-profile-details-item"
href='/accounts/{account.id}/followers'
aria-label={followersLabel}
rel="prefetch"
>
<span class="account-profile-details-item-datum">
{numFollowersDisplay}
</span>
<span class="account-profile-details-item-title">
{intl.followers}
</span>
</a>
</div>
<style>
.account-profile-details {
grid-area: details;
display: flex;
gap: 20px;
margin-bottom: 10px;
}
.account-profile-details-item {
display: flex;
flex-direction: row;
justify-content: center;
font-size: 1.1em;
padding: 10px 0;
}
.account-profile-details-item-datum {
color: var(--body-text-color);
margin-right: 5px;
font-weight: 600;
}
@media (max-width: 767px) {
.account-profile-details {
margin-bottom: 0;
}
.account-profile-details-item {
flex-direction: column;
margin-left: 5px;
margin-right: 5px;
}
.account-profile-details-item:last-child {
margin-right: 0;
}
.account-profile-details-item:first-child {
margin-left: 0;
}
.account-profile-details-item-title {
margin-right: 0;
text-align: center;
}
.account-profile-details-item-datum {
margin-left: 0;
text-align: center;
}
.account-profile-details-item {
font-size: 1em;
}
}
</style>
<script>
import { LOCALE } from '../../_static/intl.js'
import { formatIntl } from '../../_utils/formatIntl.js'
import { thunk } from '../../_utils/thunk.js'
const numberFormat = thunk(() => new Intl.NumberFormat(LOCALE))
export default {
computed: {
numStatuses: ({ account }) => account.statuses_count || 0,
numFollowing: ({ account }) => account.following_count || 0,
numFollowers: ({ account }) => account.followers_count || 0,
numStatusesDisplay: ({ numStatuses }) => numberFormat().format(numStatuses),
numFollowingDisplay: ({ numFollowing }) => numberFormat().format(numFollowing),
numFollowersDisplay: ({ numFollowers, $disableFollowerCounts }) => {
if ($disableFollowerCounts && numFollowers >= 10) {
return '10+'
}
return numberFormat().format(numFollowers)
},
followersLabel: ({ numFollowers }) => (
formatIntl('intl.followersLabel', { count: numFollowers })
),
followingLabel: ({ numFollowing }) => (
formatIntl('intl.followingLabel', { count: numFollowing })
)
}
}
</script>