ReplyingTo.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <info-tooltip class='replying_to' @hover='loadPost'>
  3. <template slot='content'>
  4. <div style='margin-top: -0.25rem;'>
  5. <div class='replying_to__username' v-if='post'>{{post.User.username}}</div>
  6. <div class='replying_to__date' v-if='post'>{{post.createdAt | formatDate('date|time', ' - ')}}</div>
  7. </div>
  8. <div class='replying_to__content' v-if='post' v-html='post.content'></div>
  9. <template v-else>Loading...</template>
  10. </template>
  11. <div
  12. slot='display'
  13. class='replying_to__display'
  14. @click='$emit("click")'
  15. >
  16. <span class='fa fa-reply replying_to__icon'></span>
  17. {{username}}
  18. </div>
  19. </info-tooltip>
  20. </template>
  21. <script>
  22. import InfoTooltip from './InfoTooltip'
  23. import AjaxErrorHandler from '../assets/js/errorHandler'
  24. export default {
  25. name: 'ReplyingTo',
  26. props: ['replyId', 'username'],
  27. components: { InfoTooltip },
  28. data () {
  29. return {
  30. post: null
  31. }
  32. },
  33. methods: {
  34. loadPost () {
  35. if(this.post) return
  36. this.axios
  37. .get('/api/v1/post/' + this.replyId)
  38. .then((res) => {
  39. this.post = res.data
  40. })
  41. .catch(AjaxErrorHandler(this.$store))
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang='scss'>
  47. @import '../assets/scss/variables.scss';
  48. .replying_to {
  49. @at-root #{&}__icon {
  50. font-size: 0.7rem;
  51. margin-right: 0.25rem;
  52. color: rgba(0, 0, 0, 0.87);
  53. }
  54. @at-root #{&}__date {
  55. display: inline-block;
  56. color: $color__gray--darkest;
  57. font-size: 0.8rem;
  58. }
  59. @at-root #{&}__username {
  60. display: inline-block;
  61. font-size: 0.9rem;
  62. color: #000;
  63. }
  64. @at-root #{&}__content {
  65. *:first-child, *:last-child {
  66. margin: 0;
  67. }
  68. p {
  69. margin: 0.25rem 0;
  70. }
  71. }
  72. @at-root #{&}__display {
  73. display: inline-flex;
  74. cursor: pointer;
  75. align-items: baseline;
  76. }
  77. }
  78. </style>