Skip to content

Commit d03844b

Browse files
authored
feat: improves toasts for mobile (#3545)
1 parent 3f86080 commit d03844b

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

assets/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ declare module 'vue' {
119119
SwarmMenu: typeof import('./components/SwarmMenu.vue')['default']
120120
Tag: typeof import('./components/common/Tag.vue')['default']
121121
TimedButton: typeof import('./components/common/TimedButton.vue')['default']
122+
ToastModal: typeof import('./components/common/ToastModal.vue')['default']
122123
Toggle: typeof import('./components/common/Toggle.vue')['default']
123124
ViewerWithSource: typeof import('./components/LogViewer/ViewerWithSource.vue')['default']
124125
ZigZag: typeof import('./components/LogViewer/ZigZag.vue')['default']
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template>
2+
<div class="toast toast-end whitespace-normal max-md:m-0 max-md:w-full">
3+
<div
4+
class="alert max-w-xl max-md:rounded-none"
5+
v-for="toast in toasts"
6+
:key="toast.id"
7+
:class="{
8+
'alert-error': toast.type === 'error',
9+
'alert-info': toast.type === 'info',
10+
'alert-warning': toast.type === 'warning',
11+
}"
12+
>
13+
<carbon:information class="size-6 shrink-0 stroke-current" v-if="toast.type === 'info'" />
14+
<carbon:warning class="size-6 shrink-0 stroke-current" v-else-if="toast.type === 'error'" />
15+
<carbon:warning class="size-6 shrink-0 stroke-current" v-else-if="toast.type === 'warning'" />
16+
<div>
17+
<h3 class="text-lg font-bold" v-if="toast.title">{{ toast.title }}</h3>
18+
<div v-html="toast.message" class="[&>a]:underline"></div>
19+
</div>
20+
<div>
21+
<button class="btn btn-circle btn-xs" @click="removeToast(toast.id)"><mdi:close /></button>
22+
</div>
23+
</div>
24+
</div>
25+
</template>
26+
<script lang="ts" setup>
27+
const { toasts, removeToast } = useToast();
28+
</script>

assets/layouts/default.vue

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,7 @@
5252
<template #fallback> Loading dependencies... </template>
5353
</Suspense>
5454
</SideDrawer>
55-
<div class="toast toast-end whitespace-normal">
56-
<div
57-
class="alert max-w-xl"
58-
v-for="toast in toasts"
59-
:key="toast.id"
60-
:class="{
61-
'alert-error': toast.type === 'error',
62-
'alert-info': toast.type === 'info',
63-
'alert-warning': toast.type === 'warning',
64-
}"
65-
>
66-
<carbon:information class="size-6 shrink-0 stroke-current" v-if="toast.type === 'info'" />
67-
<carbon:warning class="size-6 shrink-0 stroke-current" v-else-if="toast.type === 'error'" />
68-
<carbon:warning class="size-6 shrink-0 stroke-current" v-else-if="toast.type === 'warning'" />
69-
<div>
70-
<h3 class="text-lg font-bold" v-if="toast.title">{{ toast.title }}</h3>
71-
<div v-html="toast.message" class="[&>a]:underline"></div>
72-
</div>
73-
<div>
74-
<button class="btn btn-circle btn-xs" @click="removeToast(toast.id)"><mdi:close /></button>
75-
</div>
76-
</div>
77-
</div>
55+
<ToastModal />
7856
</template>
7957

8058
<script lang="ts" setup>
@@ -86,7 +64,6 @@ import SideDrawer from "@/components/common/SideDrawer.vue";
8664
const pinnedLogsStore = usePinnedLogsStore();
8765
const { pinnedLogs } = storeToRefs(pinnedLogsStore);
8866
89-
const { toasts, removeToast } = useToast();
9067
const drawer = useTemplateRef<InstanceType<typeof SideDrawer>>("drawer") as Ref<InstanceType<typeof SideDrawer>>;
9168
const { component: drawerComponent, properties: drawerProperties, width: drawerWidth } = createDrawer(drawer);
9269

0 commit comments

Comments
 (0)