]> git.ipfire.org Git - people/ms/westferry.git/commitdiff
frontend: Add a simple notification component master
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 10 May 2025 15:12:28 +0000 (15:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 10 May 2025 15:12:28 +0000 (15:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
frontend/src/components/Notification.vue [new file with mode: 0644]
frontend/src/views/DemoView.vue

diff --git a/frontend/src/components/Notification.vue b/frontend/src/components/Notification.vue
new file mode 100644 (file)
index 0000000..817feb5
--- /dev/null
@@ -0,0 +1,25 @@
+<script setup lang="ts">
+       import { ref } from "vue";
+
+       defineProps<{
+               title?: string,
+               isClosable?: boolean,
+       }>()
+
+       // Should this notification be shown?
+       const show = ref(true);
+</script>
+
+<template>
+       <div class="notification" v-if="show">
+               <button v-if="isClosable" class="delete" @click="show = false"></button>
+
+               <!-- Title -->
+               <p v-if="title">
+                       <strong>{{ title }}</strong>
+               </p>
+
+               <!-- Content -->
+               <slot />
+       </div>
+</template>
index e1cde6b2d1a8058ce55bba01b62635b27581acd5..7bb81f195675c537fee358aad02b54b735303e49 100644 (file)
@@ -3,6 +3,7 @@
 -->
 
 <script setup lang="ts">
+       import Notification from "../components/Notification.vue"
        import Section from "../components/Section.vue"
 </script>
 
        <Section :title="$t('This Is A Section')">
                <p>{{ $t("The section can have any content...") }}</p>
        </Section>
+
+       <Section :title="$t('Notifications')">
+               <Notification>
+                       {{ $t("This is a regular notification.") }}
+               </Notification>
+
+               <Notification :title="$t('Title')">
+                       {{ $t("This notification has a title.") }}
+               </Notification>
+
+               <Notification is-closable>
+                       {{ $t("This notification can be closed.") }}
+               </Notification>
+       </Section>
 </template>