1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-12 18:28:03 +01:00
Pinafore-Web-Client-Frontend/routes/_components/Status.html
2018-01-19 17:29:27 -08:00

231 lines
5.8 KiB
HTML

<article class="status-article" tabindex="0" aria-posinset="{{index}}" aria-setsize="{{length}}">
{{#if status.reblog}}
<div class="status-boosted">
<svg>
<use xlink:href="#fa-retweet" />
</svg>
<span>
<a href="/accounts/{{status.account.id}}">
{{status.account.username}}
</a> boosted
</span>
</div>
{{/if}}
<div class="status-author">
<a class="status-author-name" href="/accounts/{{originalAccount.id}}">
{{originalAccount.display_name || originalAccount.username}}
</a>
<span class="status-author-handle">
@{{originalAccount.acct}}
</span>
<a class="status-author-date" rel="noopener" target="_blank" href="{{originalStatus.uri}}">
<time datetime={{createdAtDate}} title="{{relativeDate}}">{{relativeDate}}</time>
</a>
</div>
<Avatar account={{originalAccount}} className="status-sidebar"/>
<div class="status-content">{{{status.content}}}</div>
<div class="status-toolbar">
<button aria-label="Reply" aria-pressed="false" type="button">
<svg>
<use xlink:href="#fa-reply" />
</svg>
</button>
<button aria-label="Boost" aria-pressed="false" type="button">
<svg>
<use xlink:href="#fa-retweet" />
</svg>
</button>
<button aria-label="Favorite" aria-pressed="false" type="button">
<svg>
<use xlink:href="#fa-star" />
</svg>
</button>
<button aria-label="More" aria-pressed="false" type="button">
<svg>
<use xlink:href="#fa-ellipsis-h" />
</svg>
</button>
</div>
<!--<div class="status-media" style="grid-template-columns: repeat(auto-fit, minmax({{minMediaWidth}}px, 1fr));">
{{#each originalMedia as media}}
<div class="status-media-container">
<img src="{{media.preview_url}}" alt="{{media.description || ''}}"/>
</div>
{{/each}}
</div>-->
</article>
<style>
.status-article {
width: 560px;
max-width: calc(100vw - 40px);
padding: 10px 20px;
display: grid;
grid-template-areas:
".............. status-boosted"
"status-sidebar status-author"
"status-sidebar status-content"
".............. status-toolbar"
".............. status-media";
grid-template-columns: 58px 1fr;
border-bottom: 1px solid var(--main-border);
/* will-change: transform; */ /* TODO: is this necessary? */
}
:global(.status-sidebar) {
grid-area: status-sidebar;
margin: 0 10px 0 0;
}
.status-author {
grid-area: status-author;
display: flex;
align-items: center;
margin: 0 10px 0 5px;
font-size: 1.1em;
min-width: 0;
}
.status-author a, .status-author a:visited, .status-author a:hover, .status-author .status-author-handle {
color: var(--deemphasized-text-color);
}
.status-author .status-author-name {
min-width: 0;
flex-shrink: 1;
color: var(--body-text-color);
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.status-author .status-author-name:hover {
color: var(--body-text-color);
}
.status-author-handle {
min-width: 0;
flex: 1;
margin-left: 5px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.status-author-date {
flex-shrink: 1;
text-align: right;
margin-left: 5px;
white-space: nowrap;
}
.status-content {
margin: 10px 10px 20px 5px;
grid-area: status-content;
word-wrap: break-word;
overflow: hidden;
white-space: pre-wrap;
font-size: 0.9em;
}
:global(.status-content p) {
margin: 0 0 20px;
}
:global(.status-content p:first-child) {
margin: 0 0 20px;
}
:global(.status-content p:last-child) {
margin: 0;
}
.status-boosted span {
margin-left: 5px;
}
.status-boosted span, .status-boosted a, .status-boosted a:visited, .status-boosted a:hover {
color: var(--deemphasized-text-color);
}
.status-boosted {
grid-area: status-boosted;
margin: 5px 10px 5px 5px;
display: flex;
align-items: center;
}
.status-boosted svg {
width: 18px;
height: 18px;
fill: var(--deemphasized-text-color)
}
.status-toolbar {
grid-area: status-toolbar;
display: flex;
justify-content: space-between;
}
.status-toolbar button {
padding: 6px 10px;
background: none;
border: none;
}
.status-toolbar button svg {
width: 24px;
height: 24px;
fill: var(--action-button-fill-color);
}
.status-toolbar button:hover svg {
fill: var(--action-button-fill-color-hover);
}
.status-toolbar button:active svg {
fill: var(--action-button-fill-color-active);
}
/*
.status-media {
grid-area: status-media;
display: grid;
align-items: center;
justify-content: center;
justify-items: center;
}
.status-media-container {
}
.status-media-container img {
object-fit: cover;
}
*/
</style>
<script>
import Avatar from './Avatar.html'
import { mark, stop } from '../_utils/marks'
import IntlRelativeFormat from 'intl-relativeformat'
const relativeFormat = new IntlRelativeFormat('en-US');
export default {
components: {
Avatar
},
computed: {
createdAtDate: (status) => status.created_at,
relativeDate: (createdAtDate) => {
mark('compute relativeDate')
let res = relativeFormat.format(new Date(createdAtDate))
stop('compute relativeDate')
return res
},
originalStatus: (status) => status.reblog ? status.reblog : status,
originalAccount: (originalStatus) => originalStatus.account,
originalMedia: (originalStatus) => originalStatus.media_attachments,
minMediaWidth: (originalMedia) => Math.min.apply(Math, originalMedia.map(_ => _.meta.small.width))
}
}
</script>