PostReply.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <info-tooltip class='post_reply' :class='{"post_reply--hover": hover, "post_reply--first": first}'>
  3. <template slot='content'>
  4. <div style='margin-top: -0.25rem;'>
  5. <div class='post_reply__username'>{{user.username}}</div>
  6. <div class='post_reply__date'>{{post.createdAt | formatDate('date|time', ' - ')}}</div>
  7. </div>
  8. <div class='post_reply__content'>{{post.content | stripTags | truncate(100)}}</div>
  9. </template>
  10. <div
  11. slot='display'
  12. class='post_reply__display'
  13. @click='$emit("click")'
  14. >
  15. <div
  16. class='post_reply__letter'
  17. :style='{"background-color": user.color}'
  18. >
  19. {{user.letter}}
  20. </div>
  21. </div>
  22. </info-tooltip>
  23. </template>
  24. <script>
  25. import InfoTooltip from './InfoTooltip'
  26. export default {
  27. name: 'PostReply',
  28. props: ['post', 'hover', 'first'],
  29. components: { InfoTooltip },
  30. computed: {
  31. user () {
  32. if(this.post.User) {
  33. return Object.assign({
  34. letter: this.post.User.username[0]
  35. }, this.post.User)
  36. } else {
  37. return {
  38. letter: ' ',
  39. color: null,
  40. username: '[deleted]'
  41. }
  42. }
  43. }
  44. }
  45. }
  46. </script>
  47. <style lang='scss'>
  48. @import '../assets/scss/variables.scss';
  49. .post_reply {
  50. transition: all 0.2s;
  51. margin-left: -0.4rem;
  52. &:first-child {
  53. margin-left: 0rem;
  54. }
  55. @at-root #{&}--hover {
  56. margin: 0 0.125rem;
  57. }
  58. @at-root #{&}--first {
  59. margin-left: 0;
  60. }
  61. @at-root #{&}__date {
  62. display: inline-block;
  63. color: $color__gray--darkest;
  64. font-size: 0.8rem;
  65. }
  66. @at-root #{&}__username {
  67. display: inline-block;
  68. font-size: 0.9rem;
  69. color: #000;
  70. }
  71. @at-root #{&}__content {
  72. *:first-child, *:last-child {
  73. margin: 0;
  74. }
  75. p {
  76. margin: 0.25rem 0;
  77. }
  78. }
  79. @at-root #{&}__display {
  80. display: inline-flex;
  81. align-items: baseline;
  82. border: 0.125rem solid $color__gray--darkest;
  83. justify-content: center;
  84. position: relative;
  85. border-radius: 1rem;
  86. cursor: pointer;
  87. @at-root #{&}--no_hover {
  88. pointer-events: none;
  89. }
  90. }
  91. @at-root #{&}__letter {
  92. height: 1.25rem;
  93. width: 1.25rem;
  94. line-height: 1.25rem;
  95. @include text($font--role-emphasis, 0.9rem)
  96. text-align: center;
  97. border-radius: 100%;
  98. background-color: $color__gray--darkest;
  99. color: #fff;
  100. }
  101. }
  102. </style>