SlideBackground.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <div
  3. class="slide-background"
  4. :style="backgroundStyle"
  5. >
  6. <template v-if="showGridLines">
  7. <GridLines />
  8. <GridLines :gridSize="100" gridColor="rgba(100, 100, 100, 0.35)" />
  9. </template>
  10. </div>
  11. </template>
  12. <script lang="ts">
  13. import { Ref, computed, defineComponent } from 'vue'
  14. import { useStore } from 'vuex'
  15. import { State } from '@/store'
  16. import { SlideBackground } from '@/types/slides'
  17. import GridLines from './GridLines.vue'
  18. import useSlideBackgroundStyle from '@/hooks/useSlideBackgroundStyle'
  19. export default defineComponent({
  20. name: 'slide-background',
  21. components: {
  22. GridLines,
  23. },
  24. setup() {
  25. const store = useStore<State>()
  26. const showGridLines = computed(() => store.state.showGridLines)
  27. const background: Ref<SlideBackground | undefined> = computed(() => store.getters.currentSlide.background)
  28. const { backgroundStyle } = useSlideBackgroundStyle(background)
  29. return {
  30. showGridLines,
  31. backgroundStyle,
  32. }
  33. },
  34. })
  35. </script>
  36. <style lang="scss" scoped>
  37. .slide-background {
  38. width: 100%;
  39. height: 100%;
  40. background-position: center;
  41. background-size: cover;
  42. position: absolute;
  43. }
  44. </style>