forked from cybrespace/pinafore
		
	
		
			
				
	
	
		
			204 lines
		
	
	
		
			No EOL
		
	
	
		
			5.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			204 lines
		
	
	
		
			No EOL
		
	
	
		
			5.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<article class="status-article" tabindex="0" aria-posinset="{{index}}" aria-setsize="{{length}}" on:recalculateHeight>
 | 
						|
  {{#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"/>
 | 
						|
  {{#if status.spoiler_text}}
 | 
						|
    <div class="status-spoiler">{{status.spoiler_text}}</div>
 | 
						|
  {{/if}}
 | 
						|
  {{#if status.spoiler_text}}
 | 
						|
    <div class="status-spoiler-button">
 | 
						|
      <button type="button" on:click="onClickSpoilerButton()">Show more</button>
 | 
						|
    </div>
 | 
						|
  {{/if}}
 | 
						|
  {{#if !status.spoiler_text || spoilerShown}}
 | 
						|
    <div class="status-content">
 | 
						|
      {{{status.content}}}
 | 
						|
    </div>
 | 
						|
  {{/if}}
 | 
						|
  <Toolbar :status />
 | 
						|
  <Media mediaAttachments="{{originalMediaAttachments}}" />
 | 
						|
</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-spoiler"
 | 
						|
        "status-sidebar status-spoiler-button"
 | 
						|
        "status-sidebar status-content"
 | 
						|
        ".............. status-toolbar"
 | 
						|
        "status-media   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-spoiler {
 | 
						|
    grid-area: status-spoiler;
 | 
						|
    word-wrap: break-word;
 | 
						|
    overflow: hidden;
 | 
						|
    white-space: pre-wrap;
 | 
						|
    font-size: 1.1em;
 | 
						|
    margin: 5px;
 | 
						|
  }
 | 
						|
 | 
						|
  .status-spoiler-button {
 | 
						|
    grid-area: status-spoiler-button;
 | 
						|
    margin: 5px;
 | 
						|
  }
 | 
						|
 | 
						|
  .status-spoiler-button button {
 | 
						|
    padding: 5px 10px;
 | 
						|
    font-size: 1.1em;
 | 
						|
  }
 | 
						|
 | 
						|
  .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 10px 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)
 | 
						|
  }
 | 
						|
</style>
 | 
						|
<script>
 | 
						|
  import Avatar from './Avatar.html'
 | 
						|
  import Media from './Media.html'
 | 
						|
  import Toolbar from './Toolbar.html'
 | 
						|
  import { mark, stop } from '../_utils/marks'
 | 
						|
  import IntlRelativeFormat from 'intl-relativeformat'
 | 
						|
  const relativeFormat = new IntlRelativeFormat('en-US');
 | 
						|
 | 
						|
  export default {
 | 
						|
    components: {
 | 
						|
      Avatar,
 | 
						|
      Media,
 | 
						|
      Toolbar
 | 
						|
    },
 | 
						|
    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,
 | 
						|
      originalMediaAttachments: (originalStatus) => originalStatus.media_attachments,
 | 
						|
    },
 | 
						|
    methods: {
 | 
						|
      onClickSpoilerButton() {
 | 
						|
        this.set({spoilerShown: !this.get('spoilerShown')})
 | 
						|
        this.fire('recalculateHeight')
 | 
						|
      }
 | 
						|
    }
 | 
						|
  }
 | 
						|
</script> |