NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

hero.vue 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template lang="pug">
  2. .hero.f-col(v-if="showHero")
  3. iframe(
  4. v-if="isPlaying"
  5. :src="`https://www.youtube.com/embed/${heroIdFromUrl}?autoplay=1`"
  6. frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope"
  7. allowfullscreen
  8. ).embedded
  9. .blank.f-col(v-else)
  10. h3(v-if="heroText") {{ heroText }}
  11. button(v-if="showPlaybutton" @click="isPlaying = true") play
  12. </template>
  13. <script>
  14. import { mapState } from 'vuex'
  15. export default {
  16. data() {
  17. return {
  18. heroHeight: 0,
  19. isPlaying: false
  20. }
  21. },
  22. computed: {
  23. ...mapState({
  24. showHero: state => state.hero.url,
  25. heroText: state => state.hero.text,
  26. showPlaybutton: state => state.hero.playbutton,
  27. }),
  28. heroIdFromUrl() {
  29. const url = this.showHero.split('/')
  30. return url.pop()
  31. }
  32. },
  33. methods: {
  34. onResize() {
  35. this.heroHeight = this.$el.offsetWidth / 1.8
  36. }
  37. },
  38. mounted() {
  39. this.heroHeight = this.$el.offsetWidth / 1.8
  40. this.$nextTick(() => { window.addEventListener('resize', this.onResize) })
  41. },
  42. watch: {
  43. heroHeight() {
  44. Object.assign(this.$el.style, {height: this.heroHeight + 'px'})
  45. }
  46. },
  47. beforeUnmount() {
  48. window.removeEventListener('resize', this.onResize)
  49. },
  50. }
  51. </script>
  52. <style lang="postcss">
  53. .hero
  54. background-color: rebeccapurple
  55. min-height: 35%
  56. width: 100%
  57. .embedded
  58. height: 100%
  59. width: 100%
  60. </style>