List.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div class="header-news">
  3. <v-row v-if="loading" dense >
  4. <v-col cols="3" v-for="n in 4" :key="n">
  5. <v-skeleton-loader
  6. max-height="141"
  7. class="mx-auto custom-skeleton-story"
  8. type="image"
  9. ></v-skeleton-loader>
  10. </v-col>
  11. </v-row>
  12. <div class="header-news__wrapper">
  13. <div class="header-news__slider">
  14. <div class="header-news-slider js-slider-h-news" >
  15. <client-only>
  16. <!-- TODO #slick сторис : переделать сортировку -->
  17. <VueSlickCarousel
  18. v-if="stories.length"
  19. class="header-news-slider__list"
  20. adaptiveHeight
  21. :arrows="true"
  22. :slidesToShow="4"
  23. :draggable="false"
  24. :touchMove="false"
  25. :responsive="[{
  26. breakpoint: 1024,
  27. settings: {
  28. draggable: true,
  29. touchMove: true,
  30. slidesToScroll: 4
  31. }
  32. }]"
  33. >
  34. <div
  35. v-for="(storie, i) in stories"
  36. :key="storie.alias"
  37. class="header-news-slider__item"
  38. >
  39. <div
  40. class="header-news-slider__item-link"
  41. @click="toggleModal(i)"
  42. >
  43. >
  44. <div
  45. class="header-news-slider__item-img"
  46. :style="
  47. 'background-image: url(' + (storie.preview_image ? storie.preview_image.url : '') + ')'
  48. "
  49. ></div>
  50. <div class="header-news-slider__title" v-html=" storie.title"></div>
  51. </div>
  52. </div>
  53. <template #prevArrow="arrowOption">
  54. <button
  55. class="
  56. button button_h-slider button_h-slider-prev
  57. js-slider-next
  58. slick-arrow
  59. "
  60. style=""
  61. >
  62. <BaseIcon :name="'h-slider-prev'" clear />
  63. </button>
  64. </template>
  65. <template #nextArrow="arrowOption">
  66. <button
  67. class="
  68. button button_h-slider button_h-slider-next
  69. js-slider-next
  70. slick-arrow
  71. "
  72. style=""
  73. >
  74. <BaseIcon :name="'h-slider-next'" clear />
  75. </button>
  76. </template>
  77. </VueSlickCarousel></client-only>
  78. </div>
  79. </div>
  80. <modal :classes="'storie__modal'" scrollable name="storie" :v-scroll-lock="modalOpen"> <HeaderNewsStorie :num="index" /> </modal>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import "vue-slick-carousel/dist/vue-slick-carousel.css";
  86. import VueSlickCarousel from "vue-slick-carousel";
  87. import { mapGetters } from "vuex"
  88. export default {
  89. components: {
  90. VueSlickCarousel,
  91. },
  92. data() {
  93. return {
  94. loading: true,
  95. modalOpen: false,
  96. index: 0,
  97. };
  98. },
  99. mounted() {
  100. this.loading = false
  101. },
  102. async fetch() {
  103. await this.$store.dispatch("modules/news/setStories")
  104. },
  105. methods: {
  106. toggleModal(params) {
  107. this.index = params
  108. this.$modal.show('storie')
  109. this.modalOpen = !this.modalOpen
  110. },
  111. },
  112. computed:{
  113. ...mapGetters({
  114. stories: "modules/news/stories",
  115. })
  116. },
  117. beforeRouteUpdate(to, from, next) {
  118. this.$modal.hide('storie')
  119. next()
  120. },
  121. async asyncData({ $axios }) {
  122. const stories = $axios
  123. .$get("news/story")
  124. .then((res) => {
  125. return res.data;
  126. })
  127. .catch((err) => {
  128. console.error('Error load story');
  129. });
  130. return { stories };
  131. }
  132. };
  133. </script>
  134. <style lang="less">
  135. .header-news {
  136. &__wrapper {
  137. display: flex;
  138. }
  139. }
  140. .header-news-slider__item-link {
  141. height: 100%;
  142. }
  143. .header-news-slider__item {
  144. max-width: 131px;
  145. height: 141px;
  146. margin-right: 9px;
  147. }
  148. .header-news-slider__title {
  149. overflow: hidden;
  150. text-overflow: ellipsis;
  151. display: -webkit-box;
  152. -webkit-box-orient: vertical;
  153. -webkit-line-clamp: 5; /* number of lines to show */
  154. /*line-height: 16px;*/ /* fallback */
  155. max-height: calc(16px * 6); /* fallback */
  156. box-sizing: content-box;
  157. padding-bottom: 0;
  158. margin-bottom: 8px;
  159. font-size: 14px;
  160. line-height: 120%;
  161. }
  162. .storie {
  163. &__modal {
  164. height: 100vh !important;
  165. width: 100% !important;
  166. left: 0 !important;
  167. top: 0 !important;
  168. }
  169. }
  170. .custom-skeleton-story {
  171. width: 131px;
  172. @media screen and (min-width:768px) and (max-width:1300px) {
  173. width: 125px;
  174. }
  175. @media screen and (max-width:600px) {
  176. width: 80px;
  177. }
  178. @media screen and (max-width:360px) {
  179. width: 70px;
  180. }
  181. }
  182. </style>