_slug.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div>
  3. <product-hero
  4. :title="course.title"
  5. :subtitle="course.subtitle"
  6. :author="course.author">
  7. <product-hero-card
  8. :price="course.price"
  9. :discountedPrice="course.discountedPrice"
  10. :navigateTo="course.productLink"
  11. :requirements="course.requirements"
  12. :image="course.image" />
  13. </product-hero>
  14. <div class="container">
  15. <div class="columns">
  16. <div class="column is-9">
  17. <div class="section">
  18. <div class="what-you-get">
  19. <div class="what-you-get-title">
  20. What you will learn
  21. </div>
  22. <ul class="what-you-get-items">
  23. <!-- TODO: Iterate course wsl -->
  24. <li
  25. v-for="wsl in course.wsl"
  26. :key="wsl.value"
  27. class="what-you-get-item">
  28. <span>{{wsl.value}}</span>
  29. </li>
  30. </ul>
  31. </div>
  32. </div>
  33. <div class="section course-description p-t-none">
  34. <div class="course-description-title">Course Info</div>
  35. <div class="course-description-details">
  36. <!-- TODO: use v-html for description -->
  37. <div v-html="course.description"></div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import ProductHero from '~/components/ProductHero'
  47. import ProductHeroCard from '~/components/ProductHeroCard'
  48. export default {
  49. components: {
  50. ProductHero, ProductHeroCard
  51. },
  52. computed: {
  53. course() {
  54. return this.$store.state.course.item
  55. }
  56. },
  57. async fetch({store, params}) {
  58. await store.dispatch('course/fetchCourseBySlug', params.slug)
  59. }
  60. }
  61. </script>
  62. <!-- Fetch course by Slug -->
  63. <!-- 1. create action "fetchCourseBySlug" in store/course.js -->
  64. <!-- 2. send GET request '/api/v1/products/s/:slug' -->
  65. <!-- 3. expect to receive "course" in "then" and commit it to state -->
  66. <!-- 4. get course in computed properties -->
  67. <!-- 5. Complete TODO's -->
  68. <!-- 6. Navigate to detail page from home page when clicking on "Learn More" -->
  69. <style lang="scss">
  70. .what-you-get {
  71. background-color: #f9f9f9;
  72. border: 1px solid #dedfe0;
  73. padding: 10px 15px;
  74. &-title {
  75. font-size: 26px;
  76. font-weight: bold;
  77. margin-bottom: 10px;
  78. }
  79. &-items {
  80. display: flex;
  81. align-items: flex-start;
  82. justify-content: space-between;
  83. flex-wrap: wrap;
  84. }
  85. &-item {
  86. display: flex;
  87. align-items: center;
  88. margin-bottom: 10px;
  89. font-size: 17px;
  90. width: 45%;
  91. }
  92. }
  93. .course-description {
  94. &-title {
  95. font-size: 26px;
  96. font-weight: bold;
  97. margin-bottom: 10px;
  98. }
  99. &-details {
  100. font-size: 18px;
  101. ul {
  102. list-style: disc;
  103. margin-left: 20px;
  104. }
  105. ol {
  106. margin-left: 20px;
  107. }
  108. strong {
  109. font-size: 20px;
  110. }
  111. p {
  112. min-height: 30px;
  113. }
  114. }
  115. }
  116. </style>