mirror of
https://github.com/nolanlawson/pinafore
synced 2024-12-13 10:48:19 +01:00
47 lines
1.4 KiB
HTML
47 lines
1.4 KiB
HTML
<a class="status-relative-date {{isStatusInNotification ? 'status-in-notification' : '' }}"
|
||
href="/statuses/{{status.id}}"
|
||
focus-key="{{focusKey}}"
|
||
>
|
||
<time datetime={{createdAtDate}} title="{{relativeDate}}" aria-label="{{relativeDate}} – click to show thread">{{relativeDate}}</time>
|
||
</a>
|
||
<style>
|
||
.status-relative-date {
|
||
grid-area: relative-date;
|
||
align-self: center;
|
||
margin-left: 5px;
|
||
margin-right: 10px;
|
||
font-size: 1.1em;
|
||
text-align: right;
|
||
white-space: nowrap;
|
||
}
|
||
.status-relative-date, .status-relative-date:hover, .status-relative-date:visited {
|
||
color: var(--deemphasized-text-color);
|
||
}
|
||
|
||
.status-relative-date.status-in-notification,
|
||
.status-relative-date.status-in-notification:hover,
|
||
.status-relative-date.status-in-notification:visited {
|
||
color: var(--very-deemphasized-text-color);
|
||
}
|
||
|
||
</style>
|
||
<script>
|
||
import IntlRelativeFormat from 'intl-relativeformat'
|
||
import { mark, stop } from '../../_utils/marks'
|
||
|
||
const relativeFormat = new IntlRelativeFormat('en-US');
|
||
|
||
export default {
|
||
computed: {
|
||
createdAtDate: (status) => status.created_at,
|
||
statusId: (status) => status.id,
|
||
relativeDate: (createdAtDate) => {
|
||
mark('compute relativeDate')
|
||
let res = relativeFormat.format(new Date(createdAtDate))
|
||
stop('compute relativeDate')
|
||
return res
|
||
},
|
||
focusKey: (statusId) => `status-relative-date-${statusId}`
|
||
}
|
||
}
|
||
</script> |