feat: Add support for Open Graph cards (#1121)
* Add support for Open Graph cards * use <strong> and aria-hidden on image to improve a11y
This commit is contained in:
parent
8d012a96f7
commit
6bae770bf5
|
@ -25,6 +25,9 @@
|
||||||
{#if content && (showContent || contentPreloaded)}
|
{#if content && (showContent || contentPreloaded)}
|
||||||
<StatusContent {...params} shown={showContent}/>
|
<StatusContent {...params} shown={showContent}/>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if showCard }
|
||||||
|
<StatusCard {...params} />
|
||||||
|
{/if}
|
||||||
{#if showMedia }
|
{#if showMedia }
|
||||||
<StatusMediaAttachments {...params} on:recalculateHeight />
|
<StatusMediaAttachments {...params} on:recalculateHeight />
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -54,6 +57,7 @@
|
||||||
"sidebar spoiler-btn spoiler-btn spoiler-btn"
|
"sidebar spoiler-btn spoiler-btn spoiler-btn"
|
||||||
"sidebar mentions mentions mentions"
|
"sidebar mentions mentions mentions"
|
||||||
"sidebar content content content"
|
"sidebar content content content"
|
||||||
|
"sidebar card card card"
|
||||||
"sidebar media-grp media-grp media-grp"
|
"sidebar media-grp media-grp media-grp"
|
||||||
"media media media media"
|
"media media media media"
|
||||||
"....... toolbar toolbar toolbar"
|
"....... toolbar toolbar toolbar"
|
||||||
|
@ -87,6 +91,7 @@
|
||||||
"spoiler-btn spoiler-btn"
|
"spoiler-btn spoiler-btn"
|
||||||
"mentions mentions"
|
"mentions mentions"
|
||||||
"content content"
|
"content content"
|
||||||
|
"card card"
|
||||||
"media-grp media-grp"
|
"media-grp media-grp"
|
||||||
"media media"
|
"media media"
|
||||||
"details details"
|
"details details"
|
||||||
|
@ -113,6 +118,7 @@
|
||||||
import StatusAuthorHandle from './StatusAuthorHandle.html'
|
import StatusAuthorHandle from './StatusAuthorHandle.html'
|
||||||
import StatusRelativeDate from './StatusRelativeDate.html'
|
import StatusRelativeDate from './StatusRelativeDate.html'
|
||||||
import StatusDetails from './StatusDetails.html'
|
import StatusDetails from './StatusDetails.html'
|
||||||
|
import StatusCard from './StatusCard.html'
|
||||||
import StatusToolbar from './StatusToolbar.html'
|
import StatusToolbar from './StatusToolbar.html'
|
||||||
import StatusMediaAttachments from './StatusMediaAttachments.html'
|
import StatusMediaAttachments from './StatusMediaAttachments.html'
|
||||||
import StatusContent from './StatusContent.html'
|
import StatusContent from './StatusContent.html'
|
||||||
|
@ -169,6 +175,7 @@
|
||||||
StatusToolbar,
|
StatusToolbar,
|
||||||
StatusMediaAttachments,
|
StatusMediaAttachments,
|
||||||
StatusContent,
|
StatusContent,
|
||||||
|
StatusCard,
|
||||||
StatusSpoiler,
|
StatusSpoiler,
|
||||||
StatusComposeBox,
|
StatusComposeBox,
|
||||||
StatusMentions,
|
StatusMentions,
|
||||||
|
@ -253,6 +260,12 @@
|
||||||
),
|
),
|
||||||
spoilerShown: ({ $spoilersShown, uuid }) => !!$spoilersShown[uuid],
|
spoilerShown: ({ $spoilersShown, uuid }) => !!$spoilersShown[uuid],
|
||||||
replyShown: ({ $repliesShown, uuid }) => !!$repliesShown[uuid],
|
replyShown: ({ $repliesShown, uuid }) => !!$repliesShown[uuid],
|
||||||
|
showCard: ({ originalStatus, isStatusInNotification, showMedia }) => (
|
||||||
|
!isStatusInNotification &&
|
||||||
|
!showMedia &&
|
||||||
|
originalStatus.card &&
|
||||||
|
originalStatus.card.title
|
||||||
|
),
|
||||||
showMedia: ({ originalStatus, isStatusInNotification }) => (
|
showMedia: ({ originalStatus, isStatusInNotification }) => (
|
||||||
!isStatusInNotification &&
|
!isStatusInNotification &&
|
||||||
originalStatus.media_attachments &&
|
originalStatus.media_attachments &&
|
||||||
|
|
91
src/routes/_components/status/StatusCard.html
Normal file
91
src/routes/_components/status/StatusCard.html
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
<a href="{url}" class="status-card" target="_blank" rel="noopener noreferrer">
|
||||||
|
<strong class="card-title">
|
||||||
|
{title}
|
||||||
|
</strong>
|
||||||
|
{#if hasBody}
|
||||||
|
<div class="card-content">
|
||||||
|
{#if imageUrl}
|
||||||
|
<LazyImage forceSize={true} height="50" width="50" src={imageUrl} ariaHidden={true} />
|
||||||
|
{/if}
|
||||||
|
{#if description}
|
||||||
|
<span class="card-description">
|
||||||
|
{description}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</a>
|
||||||
|
<style>
|
||||||
|
.status-card {
|
||||||
|
grid-area: card;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 15px;
|
||||||
|
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
|
||||||
|
overflow: hidden;
|
||||||
|
max-width: calc(100vw - 40px);
|
||||||
|
margin: 10px 10px 10px 5px;
|
||||||
|
|
||||||
|
border: 1px solid var(--settings-list-item-border);
|
||||||
|
background: var(--settings-list-item-bg-hover);
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-card:hover {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-card :first-child {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-content {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 5px;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-title {
|
||||||
|
font-weight: 500;
|
||||||
|
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
width: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-description {
|
||||||
|
font-size: small;
|
||||||
|
line-height: 1.4;
|
||||||
|
max-height: 5.6em; /* 4 * line-height */
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-description:not(:first-child) {
|
||||||
|
margin-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
import LazyImage from '../LazyImage'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
LazyImage
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
title: ({ originalStatus }) => originalStatus.card.title,
|
||||||
|
url: ({ originalStatus }) => originalStatus.card.url,
|
||||||
|
description: ({ originalStatus }) => originalStatus.card.description,
|
||||||
|
imageUrl: ({ originalStatus }) => originalStatus.card.image,
|
||||||
|
hasBody: ({ description, imageUrl }) => description && imageUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in a new issue