Container.vue 878 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!--
  2. Container principal pour l'affichage d'une ou plusieurs alertes
  3. -->
  4. <template>
  5. <main class="alertContainer">
  6. <LayoutAlertContent
  7. v-for="(alert, key) in alerts"
  8. :key="key"
  9. class="alertContent"
  10. :alert="alert"
  11. />
  12. </main>
  13. </template>
  14. <script lang="ts">
  15. import { defineComponent, computed, ComputedRef, useContext } from '@nuxtjs/composition-api'
  16. import { Alert } from '~/types/interfaces'
  17. export default defineComponent({
  18. setup () {
  19. const { store } = useContext()
  20. const alerts: ComputedRef<Array<Alert>> = computed(() => {
  21. return store.state.page.alerts
  22. })
  23. return {
  24. alerts
  25. }
  26. }
  27. })
  28. </script>
  29. <style scoped>
  30. .alertContainer {
  31. position: fixed;
  32. bottom: 0;
  33. right: 20px;
  34. z-index: 1000;
  35. }
  36. .alertContainer > .alertContent {
  37. position: relative;
  38. margin-bottom: 10px;
  39. }
  40. </style>