Skip to content

Commit 7118495

Browse files
committed
chore: add styles for toast
1 parent 43ad820 commit 7118495

File tree

4 files changed

+88
-3
lines changed

4 files changed

+88
-3
lines changed

adminforth/modules/styles.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ export const styles = () => ({
238238
lightThreeDotsMenuBodyText: "#111827",
239239
lightThreeDotsMenuBodyTextHover: "#111827",
240240

241+
lightToastBackground: "#FFFFFF",
242+
lightToastCloseIcon: "#9CA3AF",
243+
lightToastCloseIconHover: "#111827",
244+
lightToastCloseIconBackground: "#FFFFFF",
245+
lightToastCloseIconBackgroundHover: "#F3F4F6",
246+
lightToastCloseIconFocusRing: "#D1D5DB",
247+
lightToastText: "#6B7280",
241248

242249

243250
// colors for dark theme
@@ -467,6 +474,14 @@ export const styles = () => ({
467474
darkThreeDotsMenuBodyText: "#9CA3AF",
468475
darkThreeDotsMenuBodyTextHover: "#FFFFFF",
469476

477+
darkToastBackground: "#1F2937",
478+
darkToastCloseIcon: "#6B7280",
479+
darkToastCloseIconHover: "#FFFFFF",
480+
darkToastCloseIconBackground: "#1F2937",
481+
darkToastCloseIconBackgroundHover: "#374151",
482+
darkToastCloseIconFocusRing: "#374151",
483+
darkToastText: "#9CA3AF",
484+
470485
},
471486
boxShadow: {
472487
customLight: "0 4px 8px rgba(0, 0, 0, 0.1)", // Lighter shadow

adminforth/spa/src/components/Toast.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22

33

4-
<div class="flex items-center w-full p-4 text-gray-500 rounded-lg shadow-lg dark:text-gray-400 dark:bg-gray-800 bg-white"
4+
<div class="flex items-center w-full p-4 rounded-lg shadow-lg dark:text-darkToastText dark:bg-darkToastBackground bg-lightToastBackground text-lightToastText"
55
role="alert"
66
:class="
77
{
8-
'danger': 'bg-red-100',
8+
'danger': 'bg-red-100 ',
99
}[toast.variant]
1010
"
1111
>
@@ -36,7 +36,7 @@
3636

3737
<div class="ms-3 text-sm font-normal max-w-xs pr-2" v-if="toast.messageHtml" v-html="toast.messageHtml"></div>
3838
<div class="ms-3 text-sm font-normal max-w-xs pr-2" v-else>{{toast.message}}</div>
39-
<button @click="closeToast" type="button" class="ms-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700" >
39+
<button @click="closeToast" type="button" class="ms-auto -mx-1.5 -my-1.5 bg-lightToastCloseIconBackground text-lightToastCloseIcon hover:text-lightToastCloseIconHover rounded-lg focus:ring-2 focus:ring-lightToastCloseIconFocusRing p-1.5 hover:bg-lightToastCloseIconBackgroundHover inline-flex items-center justify-center h-8 w-8 dark:text-darkToastCloseIcon dark:hover:text-darkToastCloseIconHover dark:bg-darkToastCloseIconBackground dark:hover:bg-darkToastCloseIconBackgroundHover dark:focus:ring-darkToastCloseIconFocusRing" >
4040
<svg class="w-3 h-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
4141
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
4242
</svg>

dev-demo/custom/Dash.vue

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,58 @@
228228
:min="1"
229229
:max="100"
230230
/>
231+
232+
<Toast
233+
:toast="{
234+
id: '1',
235+
variant: 'info',
236+
message: 'This is an info toast',
237+
timeout: 'unlimited'
238+
}"
239+
@close="() => {}"
240+
/>
241+
242+
<Toast
243+
:toast="{
244+
id: '2',
245+
variant: 'danger',
246+
message: 'This is a danger toast',
247+
timeout: 'unlimited'
248+
}"
249+
@close="() => {}"
250+
/>
251+
252+
<Toast
253+
:toast="{
254+
id: '3',
255+
variant: 'warning',
256+
message: 'This is a warning toast',
257+
timeout: 'unlimited'
258+
}"
259+
@close="() => {}"
260+
/>
261+
262+
<Toast
263+
:toast="{
264+
id: '4',
265+
variant: 'success',
266+
message: 'This is a success toast',
267+
timeout: 'unlimited'
268+
}"
269+
@close="() => {}"
270+
/>
271+
272+
<Toast
273+
:toast="{
274+
id: '5',
275+
variant: 'info',
276+
messageHtml: '<b>This is HTML toast</b><br><i>with custom content</i>',
277+
timeout: 'unlimited'
278+
}"
279+
@close="() => {}"
280+
/>
281+
282+
231283
</div>
232284

233285

@@ -255,6 +307,7 @@ import { Skeleton } from '@/afcl';
255307
import { Spinner } from '@/afcl';
256308
import { IconSearchOutline } from '@iconify-prerendered/vue-flowbite'
257309
import CustomRangePicker from "@/components/CustomRangePicker.vue";
310+
import Toast from '@/components/Toast.vue';
258311
259312
const files: Ref<File[]> = ref([])
260313

dev-demo/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,14 @@ export const admin = new AdminForth({
362362
ThreeDotsMenuBodyText: "alias:lightThreeDotsMenuIconDots",
363363
ThreeDotsMenuBodyTextHover: "alias:lightlightThreeDotsMenuIconDots opacity:0.8",
364364

365+
ToastBackground: "alias:lightPrimary opacity:0.6",
366+
ToastCloseIcon: "alias:lightPrimary darken",
367+
ToastCloseIconHover: "alias:lightToastCloseIcon darken",
368+
ToastCloseIconBackground: "alias:lightToastCloseIcon lighten",
369+
ToastCloseIconBackgroundHover: "alias:lightToastCloseIcon opacity:0.6",
370+
ToastCloseIconFocusRing: "alias:lightToastCloseIcon",
371+
ToastText: "alias:lightPrimary inverse",
372+
365373
},
366374
dark: {
367375
primary: '#bd1a76',
@@ -552,6 +560,15 @@ export const admin = new AdminForth({
552560
ThreeDotsMenuBodyBackgroundHover: "alias:darkThreeDotsMenuBodyBackground darken",
553561
ThreeDotsMenuBodyText: "alias:darkThreeDotsMenuIconDots",
554562
ThreeDotsMenuBodyTextHover: "alias:darkThreeDotsMenuIconDots opacity:0.8",
563+
564+
ToastBackground: "alias:darkPrimary opacity:0.6",
565+
ToastCloseIcon: "alias:darkPrimary darken",
566+
ToastCloseIconHover: "alias:darkToastCloseIcon darken",
567+
ToastCloseIconBackground: "alias:darkToastCloseIcon opacity:0.6",
568+
ToastCloseIconBackgroundHover: "alias:darkToastCloseIcon lighten",
569+
ToastCloseIconFocusRing: "alias:darkToastCloseIcon",
570+
ToastText: "alias:darkPrimary inverse",
571+
555572
}
556573
}
557574
},

0 commit comments

Comments
 (0)