pinafore/routes/_components/status/StatusRelativeDate.html

48 lines
1.4 KiB
HTML
Raw Normal View History

<a class="status-relative-date {{isStatusInNotification ? 'status-in-notification' : '' }}"
href="/statuses/{{originalStatusId}}"
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 { mark, stop } from '../../_utils/marks'
2018-02-13 18:12:52 +00:00
import timeago from 'timeago.js'
const timeagoInstance = timeago()
export default {
computed: {
createdAtDate: (originalStatus) => originalStatus.created_at,
relativeDate: (createdAtDate) => {
mark('compute relativeDate')
2018-02-13 18:12:52 +00:00
let res = timeagoInstance.format(createdAtDate)
stop('compute relativeDate')
return res
},
focusKey: (uuid) => `status-relative-date-${uuid}`
}
}
</script>