pinafore/src/routes/_components/status/Notification.html
2019-08-03 13:49:37 -07:00

90 lines
3 KiB
HTML

{#if status}
<Status {index} {length} {timelineType} {timelineValue} {focusSelector}
{status} {notification} {enableShortcuts} on:recalculateHeight
/>
{:else}
<article id={elementId}
class={className}
tabindex="0"
aria-posinset={index + 1}
aria-setsize={length}
aria-label={ariaLabel}
>
<StatusHeader {notification} {notificationId} {status} {statusId} {timelineType}
{account} {accountId} {uuid} isStatusInNotification="true" />
{#if enableShortcuts}
<Shortcut scope={shortcutScope} key="p" on:pressed="openAuthorProfile()" />
<Shortcut scope={shortcutScope} key="m" on:pressed="mentionAuthor()" />
{/if}
</article>
{/if}
<style>
.notification-article {
width: 560px;
max-width: calc(100vw - 40px);
padding: 10px 20px;
border-bottom: 1px solid var(--main-border);
}
@media (max-width: 767px) {
.notification-article {
padding: 10px 10px;
max-width: calc(100vw - 20px);
width: 580px;
}
}
</style>
<script>
import Status from './Status.html'
import StatusHeader from './StatusHeader.html'
import Shortcut from '../shortcut/Shortcut.html'
import { store } from '../../_store/store'
import { getAccountAccessibleName } from '../../_a11y/getAccountAccessibleName'
import { goto } from '../../../../__sapper__/client'
import { composeNewStatusMentioning } from '../../_actions/mention'
import { classname } from '../../_utils/classname'
import { createStatusOrNotificationUuid } from '../../_utils/createStatusOrNotificationUuid'
export default {
components: {
Status,
StatusHeader,
Shortcut
},
data: () => ({
enableShortcuts: null
}),
store: () => store,
computed: {
account: ({ notification }) => notification.account,
accountId: ({ account }) => account.id,
notificationId: ({ notification }) => notification.id,
status: ({ notification }) => notification.status,
statusId: ({ status }) => status && status.id,
uuid: ({ $currentInstance, timelineType, timelineValue, notificationId, statusId }) => (
createStatusOrNotificationUuid($currentInstance, timelineType, timelineValue, notificationId, statusId)
),
elementId: ({ uuid }) => uuid,
shortcutScope: ({ elementId }) => elementId,
ariaLabel: ({ status, account, $omitEmojiInDisplayNames }) => (
!status && `${getAccountAccessibleName(account, $omitEmojiInDisplayNames)} followed you, @${account.acct}`
),
className: ({ $underlineLinks }) => (classname(
'notification-article',
'shortcut-list-item',
'focus-after',
$underlineLinks && 'underline-links'
))
},
methods: {
openAuthorProfile () {
const { accountId } = this.get()
goto(`/accounts/${accountId}`)
},
async mentionAuthor () {
const { account } = this.get()
await composeNewStatusMentioning(account)
}
}
}
</script>