hummingbird-me/kitsu-web

View on GitHub
app/templates/components/media/media-reaction-card.hbs

Summary

Maintainability
Test Coverage
{{#if (is-self reaction.user)}}
  <a href="javascript:void(0)" class="reaction-votes {{if isUpvoted "upvoted"}} hint--rounded hint--right hint--bounce" aria-label={{t "media-reaction.self-vote"}}>
    {{svg-jar "upvote"}}
    {{reaction.upVotesCount}}
  </a>
{{else}}
  <a href="#" {{action "toggleVote"}} class="reaction-votes {{if isUpvoted "upvoted"}}">
    {{svg-jar "upvote"}}
    {{reaction.upVotesCount}}
  </a>
{{/if}}

{{#if (or (is-self reaction.user) canDelete (and session.hasUser (not (is-self reaction.user))))}}
  <div class="reaction-card-actions">
    <span class="more-wrapper">
      <a href="#" class="more-drop" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        {{svg-jar "more"}}
      </a>

      <div class="dropdown-menu dropdown-menu-right">
        {{! Copy Permalink }}
        <a class="dropdown-item" href="#" data-clipboard-text={{concat host (href-to "media-reactions" reaction.id)}} {{action "trackEngagement" "click"}}>
          {{t "media.show.reactions.copy"}}
        </a>

        {{! Edit }}
        {{#if (is-self reaction.user)}}
          <a href="#" {{action (toggle "editModalOpened" this)}}>{{t "media-reaction.edit"}}</a>
          {{#if editModalOpened}}
            {{to-elsewhere named="modal" send=(component "modals/media-reaction"
              media=reaction.media
              libraryEntry=reaction.libraryEntry.content
              modalId="reaction-modal"
              onClose=(toggle-action "editModalOpened" this)
            )}}
          {{/if}}
        {{/if}}

        {{! Delete }}
        {{#if canDelete}}
          <a href="#" {{action (toggle "deleteModalOpened" this)}}>{{t "media.show.reactions.delete"}}</a>
          {{#if deleteModalOpened}}
            {{to-elsewhere named="modal" send=(component "modals/confirm-action"
              onConfirm=(action "deleteReaction")
              onClose=(toggle-action "deleteModalOpened" this)
            )}}
          {{/if}}
        {{/if}}

        {{! Report }}
        {{#if (and session.hasUser (not (is-self reaction.user)))}}
          <a href="#" {{action (toggle "reportingReaction" this)}}>{{t "media.show.reactions.report"}}</a>
          {{#if reportingReaction}}
            {{to-elsewhere named="modal" send=(component "modals/report-content"
              content=reaction
              onClose=(toggle-action "reportingReaction" this)
            )}}
          {{/if}}
        {{/if}}
      </div>
    </span>
  </div>
{{/if}}

<div class="reaction-content">
  <span class="reaction-media-info">
    <a href={{href-to (concat media.modelType ".show") media.slug}} class="reaction-media-title">{{media.yearlessTitle}}</a>
    <span class="reaction-media-subtype">{{t (concat "media-shared.types." media.modelType "." (to-lower media.subtype))}}</span>
    {{#if media.year}}
      &middot;
      <span class="reaction-media-year">{{media.year}}</span>
    {{/if}}
  </span>
  <a href={{href-to "media-reactions" reaction.id}} class="reaction-copy">{{reaction.reaction}}</a>
</div>
<div class="poster-image" style={{posterImageStyle}}></div>
<div class="overlay"></div>