pinafore/routes/_components/Status.html

207 lines
4.3 KiB
HTML

<article>
{{#if status.reblog}}
<div class="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="author">
<a class="author-name" href="/accounts/{{original.id}}">
{{original.display_name || original.username}}
</a>
<span class="author-handle">
@{{original.acct}}
</span>
<a class="author-relative-date" rel="noopener" target="_blank" href="{{original.url}}">
{{relativeDate}}
</a>
</div>
<div class="sidebar">
<Avatar account={{original}} />
</div>
<div class="content">{{{status.content}}}</div>
<div class="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>
</article>
<style>
article {
width: 570px;
max-width: calc(100vw - 30px);
margin: 0 auto;
padding: 10px 0;
display: grid;
grid-template-areas:
"....... boosted"
"sidebar author"
"sidebar content"
"....... toolbar";
grid-template-columns: 60px 1fr;
}
.sidebar {
grid-area: sidebar;
display: flex;
}
.author {
grid-area: author;
display: flex;
align-items: center;
margin-left: 5px;
font-size: 1.1em;
min-width: 0;
}
.author a, .author a:visited, .author a:hover, .author .author-handle {
color: var(--deemphasized-text-color);
}
.author .author-name {
min-width: 0;
flex-shrink: 1;
color: var(--body-text-color);
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.author .author-name:hover {
color: var(--body-text-color);
}
.author-handle {
min-width: 0;
flex: 1;
margin-left: 5px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.author-relative-date {
flex-shrink: 1;
text-align: right;
margin-left: 5px;
white-space: nowrap;
}
.content {
margin: 10px 5px 20px;
grid-area: content;
word-wrap: break-word;
overflow: hidden;
white-space: pre-wrap;
font-size: 0.9em;
}
:global(.content p) {
margin: 0 0 20px;
}
:global(.content p:first-child) {
margin: 0 0 20px;
}
:global(.content p:last-child) {
margin: 0;
}
.boosted span {
margin-left: 5px;
}
.boosted span, .boosted a, .boosted a:visited, .boosted a:hover {
color: var(--deemphasized-text-color);
}
.boosted {
grid-area: boosted;
margin: 5px 5px;
display: flex;
align-items: center;
}
.boosted svg {
width: 18px;
height: 18px;
fill: var(--deemphasized-text-color)
}
.toolbar {
grid-area: toolbar;
display: flex;
margin: 5px;
justify-content: space-between;
}
.toolbar button {
padding: 0;
background: none;
border: none;
}
.toolbar button svg {
width: 24px;
height: 24px;
fill: var(--action-button-fill-color);
}
.toolbar button:hover svg {
fill: var(--action-button-fill-color-hover);
}
.toolbar button:active svg {
fill: var(--action-button-fill-color-active);
}
</style>
<script>
import Avatar from './Avatar.html'
import IntlRelativeFormat from 'intl-relativeformat'
const relativeFormat = new IntlRelativeFormat('en-US');
export default {
components: {
Avatar
},
computed: {
createdAtDate: (status) => status.created_at,
relativeDate: (createdAtDate) => {
return relativeFormat.format(new Date(createdAtDate))
},
original: (status) => status.reblog ? status.reblog.account : status.account
},
methods: {
alert: function (e) {
e.preventDefault()
window.alert(e.target)
}
}
}
</script>