123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <template>
- <div class='thread_display'>
- <avatar-icon
- ref='avatar'
- :user='thread.User'
- size='small'
- class='thread_display__icon'
- @click='goToUser'
- ></avatar-icon>
- <div style='width: 100%;' @click='goToThread'>
- <div class='thread_display__header'>
- <span class='thread_display__name'>
- {{thread.name}}
- </span>
- <div class='thread_display__meta_bar'>
- <div>
- By
- <span class='thread_display__username' ref='username'>{{threadUsername}}</span>
- in
- <span class='thread_display__category' ref='category'>{{thread.Category.name}}</span>
- ·
- <span class='thread_display__date'>{{thread.createdAt | formatDate}}</span>
- </div>
- </div>
- </div>
- <div class='thread_display__replies_bar'>
- <div
- class='thread_display__latest_reply'
- v-if='thread.Posts.length === 2'
- >
- <span class='fa fa-reply fa-fw'></span>
- <span class='thread_display__latest_reply__text'>Latest reply by</span>
- <span class='thread_display__username'>{{replyUsername}}</span>
- ·
- <span class='thread_display__date'>{{thread.Posts[1].createdAt | formatDate}}</span>
- </div>
- <span style='cursor: default;' v-else>No replies</span>
- <div class='thread_display__replies' title='Replies to thread'>
- <span class='fa fa-comment-o fa-fw'></span>
- {{thread.postsCount - 1}}
- </div>
- </div>
- <div class='thread_display__content'>
- {{thread.Posts[0].content | stripTags | truncate(150)}}
- </div>
- </div>
- </div>
- </template>
- <script>
- import AvatarIcon from './AvatarIcon'
- export default {
- name: 'ThreadDisplay',
- props: ['thread'],
- components: {
- AvatarIcon
- },
- computed: {
- threadUsername () {
- if(this.thread.User) {
- return this.thread.User.username
- } else {
- return '[deleted]'
- }
- },
- replyUsername () {
- if(this.thread.Posts[1].User) {
- return this.thread.Posts[1].User.username
- } else {
- return '[deleted]'
- }
- }
- },
- methods: {
- goToUser () {
- this.$router.push('/user/' + this.thread.User.username)
- },
- goToThread () {
- this.$router.push('/thread/' + this.thread.slug + '/' + this.thread.id)
- }
- }
- }
- </script>
- <style lang='scss' scoped>
- @import '../assets/scss/variables.scss';
- .thread_display {
- background-color: #fff;
- border: thin solid $color__gray--darker;
- border-radius: 0.25rem;
- cursor: pointer;
- display: flex;
- margin-bottom: 1rem;
- padding: 0.75rem;
- position: relative;
- transition: background-color 0.2s, box-shadow 0.2s;
- &:hover {
- @extend .shadow_border--hover;
- }
- @at-root #{&}__icon {
- margin-right: 0.5rem;
- }
- @at-root #{&}__username,
- #{&}__category,
- #{&}__date {
- color: $color--text__primary;
- }
- @at-root #{&}__header {
- display: flex;
- justify-content: space-between;
- }
- @at-root #{&}__name {
- font-weight: 500;
- font-size: 1.25rem;
- }
- @at-root #{&}__meta_bar {
- display: flex;
- color: $color--gray__darkest;
- justify-content: space-between;
- }
- @at-root #{&}__replies_bar {
- display: flex;
- justify-content: space-between;
- }
- @at-root #{&}__latest_reply {
- color: $color--text__secondary;
- .fa {
- color: $color--text__primary;
- font-size: 0.75rem;
- }
- }
- @at-root #{&}__replies {
- width: 4rem;
- text-align: right;
- }
-
- @at-root #{&}__content {
- margin-top: 0.5rem;
- word-break: break-all;
- }
- }
- @media (max-width: 420px) {
- .thread_display {
- @at-root #{&}__header {
- flex-direction: column;
- }
- @at-root #{&}__meta_bar {
- font-size: 0.9rem;
- margin-bottom: 0.25rem;
- }
- @at-root #{&}__content {
- display: none;
- }
- @at-root #{&}__replies_bar {
- position: relative;
- left: -3.25rem;
- width: calc(100% + 3.25rem);
- }
- @at-root #{&}__latest_reply {
- .fa {
- margin-right: 0.25rem;
- }
- @at-root #{&}__text {
- display: none;
- }
- }
- }
- }
- </style>
|