click to show toot thread

This commit is contained in:
Nolan Lawson 2018-02-10 11:00:56 -08:00
parent 473ddfaa85
commit 08c19691a9
2 changed files with 23 additions and 2 deletions

View File

@ -1,6 +1,7 @@
<article class="status-article {{getClasses(originalStatus, timelineType, isStatusInOwnThread)}}" <article class="status-article {{getClasses(originalStatus, timelineType, isStatusInOwnThread)}}"
tabindex="0" tabindex="0" on:click="onClickOrKeydown(event)" on:keydown="onClickOrKeydown(event)"
aria-posinset="{{index}}" aria-setsize="{{length}}" aria-posinset="{{index}}" aria-setsize="{{length}}"
aria-label="Status by {{originalStatus.account.display_name || originalStatus.account.username}}"
on:recalculateHeight> on:recalculateHeight>
{{#if (notification && (notification.type === 'reblog' || notification.type === 'favourite')) || status.reblog}} {{#if (notification && (notification.type === 'reblog' || notification.type === 'favourite')) || status.reblog}}
<StatusHeader :notification :status :isStatusInNotification /> <StatusHeader :notification :status :isStatusInNotification />
@ -28,6 +29,7 @@
<style> <style>
.status-article { .status-article {
cursor: pointer;
max-width: calc(100vw - 40px); max-width: calc(100vw - 40px);
padding: 10px 20px; padding: 10px 20px;
display: grid; display: grid;
@ -84,6 +86,7 @@
import StatusSpoiler from './StatusSpoiler.html' import StatusSpoiler from './StatusSpoiler.html'
import { store } from '../../_store/store' import { store } from '../../_store/store'
import identity from 'lodash/identity' import identity from 'lodash/identity'
import { goto } from 'sapper/runtime.js'
export default { export default {
components: { components: {
@ -108,6 +111,24 @@
].filter(identity).join(' ') ].filter(identity).join(' ')
} }
}, },
methods: {
onClickOrKeydown(e) {
let { type, keyCode } = e
let { localName, parentElement } = e.target
if ((type === 'click' || (type === 'keydown' && keyCode === 13)) &&
localName !== 'a' &&
localName !== 'button' &&
parentElement.localName !== 'a' &&
parentElement.localName !== 'button' &&
parentElement.parentElement.localName !== 'a' &&
parentElement.parentElement.localName !== 'button') {
e.preventDefault()
e.stopPropagation()
goto(`/statuses/${this.get('statusId')}`)
}
}
},
computed: { computed: {
originalStatus: (status) => status.reblog ? status.reblog : status, originalStatus: (status) => status.reblog ? status.reblog : status,
statusId: (originalStatus) => originalStatus.id, statusId: (originalStatus) => originalStatus.id,

View File

@ -1,6 +1,6 @@
<a class="status-relative-date {{isStatusInNotification ? 'status-in-notification' : '' }}" <a class="status-relative-date {{isStatusInNotification ? 'status-in-notification' : '' }}"
href="/statuses/{{status.id}}"> href="/statuses/{{status.id}}">
<time datetime={{createdAtDate}} title="{{relativeDate}}">{{relativeDate}}</time> <time datetime={{createdAtDate}} title="{{relativeDate}}" aria-label="{{relativeDate}} click to show thread">{{relativeDate}}</time>
</a> </a>
<style> <style>
.status-relative-date { .status-relative-date {