Skeleton: Register component modals for driver-/team-/race- and substitution-card
This commit is contained in:
@ -12,6 +12,10 @@
|
|||||||
Input,
|
Input,
|
||||||
PasswordIcon,
|
PasswordIcon,
|
||||||
LoadingIndicator,
|
LoadingIndicator,
|
||||||
|
DriverCard,
|
||||||
|
TeamCard,
|
||||||
|
RaceCard,
|
||||||
|
SubstitutionCard,
|
||||||
} from "$lib/components";
|
} from "$lib/components";
|
||||||
import { get_avatar_preview_event_handler } from "$lib/image";
|
import { get_avatar_preview_event_handler } from "$lib/image";
|
||||||
|
|
||||||
@ -21,17 +25,33 @@
|
|||||||
initializeStores,
|
initializeStores,
|
||||||
Drawer,
|
Drawer,
|
||||||
getDrawerStore,
|
getDrawerStore,
|
||||||
|
Modal,
|
||||||
|
getModalStore,
|
||||||
type DrawerSettings,
|
type DrawerSettings,
|
||||||
Avatar,
|
Avatar,
|
||||||
FileDropzone,
|
FileDropzone,
|
||||||
type DrawerStore,
|
type DrawerStore,
|
||||||
|
type ModalStore,
|
||||||
|
type ModalComponent,
|
||||||
} from "@skeletonlabs/skeleton";
|
} from "@skeletonlabs/skeleton";
|
||||||
import { computePosition, autoUpdate, offset, shift, flip, arrow } from "@floating-ui/dom";
|
import { computePosition, autoUpdate, offset, shift, flip, arrow } from "@floating-ui/dom";
|
||||||
|
|
||||||
let { data, children }: { data: LayoutData; children: Snippet } = $props();
|
let { data, children }: { data: LayoutData; children: Snippet } = $props();
|
||||||
|
|
||||||
// Drawer config
|
// Init skeleton stores for drawer + modal
|
||||||
initializeStores();
|
initializeStores();
|
||||||
|
|
||||||
|
// Modal config
|
||||||
|
const modalStore: ModalStore = getModalStore();
|
||||||
|
const modalRegistry: Record<string, ModalComponent> = {
|
||||||
|
// Card data (e.g. team, driver etc.) is passed using $modalStore[0].meta
|
||||||
|
teamCard: { ref: TeamCard },
|
||||||
|
driverCard: { ref: DriverCard },
|
||||||
|
raceCard: { ref: RaceCard },
|
||||||
|
substitutionCard: { ref: SubstitutionCard },
|
||||||
|
};
|
||||||
|
|
||||||
|
// Drawer config
|
||||||
const drawerStore: DrawerStore = getDrawerStore();
|
const drawerStore: DrawerStore = getDrawerStore();
|
||||||
let drawerOpen: boolean = false;
|
let drawerOpen: boolean = false;
|
||||||
let drawerId: string = "";
|
let drawerId: string = "";
|
||||||
@ -99,21 +119,12 @@
|
|||||||
|
|
||||||
// Popups config
|
// Popups config
|
||||||
storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
|
storePopup.set({ computePosition, autoUpdate, offset, shift, flip, arrow });
|
||||||
|
|
||||||
// Example: https://www.skeleton.dev/utilities/popups
|
|
||||||
// const data_popup_settings: PopupSettings = {
|
|
||||||
// event: "click",
|
|
||||||
// target: "data_popup",
|
|
||||||
// placement: "bottom",
|
|
||||||
// middleware: {
|
|
||||||
// offset: { mainAxis: 22, crossAxis: 0 },
|
|
||||||
// // shift: { mainAxis: true, crossAxis: false },
|
|
||||||
// },
|
|
||||||
// };
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<LoadingIndicator />
|
<LoadingIndicator />
|
||||||
|
|
||||||
|
<Modal components={modalRegistry} regionBackdrop="!overflow-y-scroll" />
|
||||||
|
|
||||||
<Drawer zIndex="z-30">
|
<Drawer zIndex="z-30">
|
||||||
<!-- Use p-3 because the drawer has a 5px overlap with the navbar -->
|
<!-- Use p-3 because the drawer has a 5px overlap with the navbar -->
|
||||||
{#if $drawerStore.id === "menu_drawer"}
|
{#if $drawerStore.id === "menu_drawer"}
|
||||||
|
|||||||
Reference in New Issue
Block a user