TopPosts.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class='widgets__top_posts'>
  3. <div class='widgets__top_posts__overlay' :class='{ "widgets__top_posts__overlay--show" : loading }'>
  4. <loading-icon></loading-icon>
  5. </div>
  6. <div
  7. class='widgets__top_posts__item'
  8. :class='"widgets__top_posts__item--" + $index'
  9. v-for='(thread, $index) in data'
  10. >
  11. <div class='widgets__top_posts__item__number'>{{$index + 1}}</div>
  12. <div class='widgets__top_posts__item__info'>
  13. <div class='widgets__top_posts__item__title'>{{thread.title}}</div>
  14. <div class='widgets__top_posts__item__views'>
  15. {{thread.views}} {{thread.views | pluralize('page view')}}
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import LoadingIcon from '../LoadingIcon'
  23. export default {
  24. name: 'TopPosts',
  25. components: { LoadingIcon },
  26. data () {
  27. return {
  28. loading: false,
  29. data: [
  30. { title: 'Post title here', views: 20 },
  31. { title: 'Another', views: 18 },
  32. { title: 'Lorem ipsum dolor sit amet loremp', views: 10 },
  33. { title: 'Post here', views: 2 }
  34. ]
  35. }
  36. }
  37. }
  38. </script>
  39. <style lang='scss' scoped>
  40. @import '../../assets/scss/variables.scss';
  41. .widgets__top_posts {
  42. background-color: #fff;
  43. width: 100%;
  44. height: 100%;
  45. overflow: auto;
  46. border-radius: 0.25rem 0.25rem 0 0;
  47. position: relative;
  48. @at-root #{&}__overlay {
  49. @include loading-overlay(#2ecc71, 0.25rem 0.25rem 0 0);
  50. }
  51. @at-root #{&}__item {
  52. display: flex;
  53. flex-direction: row;
  54. padding: 0.25rem 1rem;
  55. cursor: default;
  56. height: 25%;
  57. overflow: hidden;
  58. padding-top: 0.125rem;
  59. transition: filter 0.2s;
  60. &:hover {
  61. filter: brightness(0.9);
  62. }
  63. @for $i from 0 through 3 {
  64. @at-root #{&}--#{$i} {
  65. $alpha: null;
  66. @if $i == 3 {
  67. $alpha: 0.075;
  68. } @else {
  69. $alpha: 0.8 - ($i + 1) / 5
  70. }
  71. background-color: rgba(0, 222, 56, $alpha);
  72. }
  73. }
  74. @at-root #{&}__number {
  75. font-size: 1.75rem;
  76. font-family: $font--role-emphasis;
  77. margin-right: 1rem;
  78. width: 1rem;
  79. @include user-select(none);
  80. }
  81. @at-root #{&}__title {
  82. font-size: 1.125rem;
  83. text-overflow: ellipsis;
  84. width: 13rem;
  85. cursor: pointer;
  86. white-space: nowrap;
  87. overflow: hidden;
  88. }
  89. @at-root #{&}__views {
  90. color: $color__text--secondary;
  91. font-size: 0.9rem;
  92. margin-top: -0.125rem;
  93. }
  94. }
  95. }
  96. </style>