pinafore/routes/_components/status/StatusAuthor.html
2018-02-09 22:01:44 -08:00

99 lines
2.6 KiB
HTML

<a
class="status-author-name {{getClass(isStatusInNotification)}}"
href="/accounts/{{status.account.id}}"
>
{{status.account.display_name || status.account.username}}
</a>
<span class="status-author-handle {{getClass(isStatusInNotification)}}"
>
{{'@' + status.account.acct}}
</span>
{{#if isStatusInOwnThread}}
<ExternalLink class="status-author-date" href="{{status.url}}" showIcon="true">
<time datetime={{createdAtDate}} title="{{relativeDate}}">{{relativeDate}}</time>
</ExternalLink>
{{else}}
<a class="status-author-date {{getClass(isStatusInNotification)}}"
href="/statuses/{{status.id}}"
>
<time datetime={{createdAtDate}} title="{{relativeDate}}">{{relativeDate}}</time>
</a>
{{/if}}
<style>
.status-author {
grid-area: author;
align-items: center;
min-width: 0;
}
.status-author-name {
grid-area: author-name;
align-self: center;
margin-left: 5px;
font-size: 1.1em;
min-width: 0;
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.status-author-name, .status-author-name:hover, .status-author-name:visited {
color: var(--body-text-color);
}
.status-author-handle {
grid-area: author-handle;
align-self: center;
margin-left: 5px;
color: var(--deemphasized-text-color);
font-size: 1.1em;
min-width: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.status-author-date {
grid-area: author-date;
align-self: center;
margin-left: 5px;
margin-right: 10px;
font-size: 1.1em;
text-align: right;
white-space: nowrap;
}
.status-author-date, .status-author-date:hover, .status-author-date:visited {
color: var(--deemphasized-text-color);
}
.status-author-in-notification, .status-author-in-notification:hover, .status-author-in-notification:visited {
color: var(--very-deemphasized-text-color);
}
</style>
<script>
import IntlRelativeFormat from 'intl-relativeformat'
import ExternalLink from '../ExternalLink.html'
import { mark, stop } from '../../_utils/marks'
const relativeFormat = new IntlRelativeFormat('en-US');
export default {
helpers: {
getClass: isStatusInNotification => isStatusInNotification ? 'status-author-in-notification' : ''
},
computed: {
createdAtDate: (status) => status.created_at,
relativeDate: (createdAtDate) => {
mark('compute relativeDate')
let res = relativeFormat.format(new Date(createdAtDate))
stop('compute relativeDate')
return res
}
},
components: {
ExternalLink
}
}
</script>