From f003df7d58f0b840f0992dc2f676b755ac318a5d Mon Sep 17 00:00:00 2001
From: Alexis <35.alexis.pele@gmail.com>
Date: Sat, 3 May 2025 21:48:32 +0200
Subject: [PATCH] Added toast service
---
src/assets/scss/radix/_toast.scss | 91 ++++++++++
src/assets/scss/theme.scss | 2 +
src/components/maps/MapOverlay.astro | 3 +
src/components/maps/overlay/ToastService.vue | 45 +++++
src/components/maps/overlay/useToast.ts | 175 +++++++++++++++++++
5 files changed, 316 insertions(+)
create mode 100644 src/assets/scss/radix/_toast.scss
create mode 100644 src/components/maps/overlay/ToastService.vue
create mode 100644 src/components/maps/overlay/useToast.ts
diff --git a/src/assets/scss/radix/_toast.scss b/src/assets/scss/radix/_toast.scss
new file mode 100644
index 00000000..b336651e
--- /dev/null
+++ b/src/assets/scss/radix/_toast.scss
@@ -0,0 +1,91 @@
+.toast-viewport {
+ --viewport-padding: 25px;
+ position: fixed;
+ bottom: 0;
+ right: 0;
+ display: flex;
+ flex-direction: column;
+ padding: var(--viewport-padding);
+ gap: 10px;
+ width: 390px;
+ max-width: 100vw;
+ margin: 0;
+ list-style: none;
+ z-index: 2147483647;
+ outline: none;
+}
+
+.toast-root {
+ background-color: white;
+ border-radius: 6px;
+ box-shadow: hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
+ padding: 15px;
+ display: grid;
+ grid-template-areas: 'title action' 'description action';
+ grid-template-columns: auto max-content;
+ column-gap: 15px;
+ align-items: center;
+}
+.toast-root[data-state='open'] {
+ animation: slideIn 150ms cubic-bezier(0.16, 1, 0.3, 1);
+}
+.toast-root[data-state='closed'] {
+ animation: hide 100ms ease-in;
+}
+.toast-root[data-swipe='move'] {
+ transform: translateX(var(--radix-toast-swipe-move-x));
+}
+.toast-root[data-swipe='cancel'] {
+ transform: translateX(0);
+ transition: transform 200ms ease-out;
+}
+.toast-root[data-swipe='end'] {
+ animation: swipeOut 100ms ease-out;
+}
+
+@keyframes hide {
+ from {
+ opacity: 1;
+ }
+ to {
+ opacity: 0;
+ }
+}
+
+@keyframes slideIn {
+ from {
+ transform: translateX(calc(100% + var(--viewport-padding)));
+ }
+ to {
+ transform: translateX(0);
+ }
+}
+
+@keyframes swipeOut {
+ from {
+ transform: translateX(var(--radix-toast-swipe-end-x));
+ }
+ to {
+ transform: translateX(calc(100% + var(--viewport-padding)));
+ }
+}
+
+.toast-title {
+ grid-area: title;
+ margin-bottom: 5px;
+ font-weight: 500;
+ color: var(--slate-12);
+ font-size: 15px;
+}
+
+.toast-description {
+ grid-area: description;
+ margin: 0;
+ color: var(--slate-11);
+ font-size: 13px;
+ line-height: 1.3;
+}
+
+.toast-action {
+ grid-area: action;
+}
\ No newline at end of file
diff --git a/src/assets/scss/theme.scss b/src/assets/scss/theme.scss
index 2711edb5..3d70e778 100644
--- a/src/assets/scss/theme.scss
+++ b/src/assets/scss/theme.scss
@@ -9,6 +9,8 @@
@use 'card';
@use 'map';
+@use 'radix/toast';
+
:root {
--white: #fff;
--black: #111;
diff --git a/src/components/maps/MapOverlay.astro b/src/components/maps/MapOverlay.astro
index 7012d646..ff0fd53d 100644
--- a/src/components/maps/MapOverlay.astro
+++ b/src/components/maps/MapOverlay.astro
@@ -7,6 +7,7 @@ import type { MapOverlayProps } from "@/types/Map";
import SearchMarkers from "./overlay/SearchMarkers.vue";
import LangSwitcher from "./overlay/LangSwitcher.vue";
import MapOverlayBreadcrumbs from "./MapOverlayBreadcrumbs.astro";
+import ToastService from "./overlay/ToastService.vue";
interface Props extends MapOverlayProps {}
@@ -50,6 +51,8 @@ const currentUrl = Astro.url
}
+
+