Skip to content

Commit

Permalink
🦄 refactor(ui|modals): move the dialog modals types
Browse files Browse the repository at this point in the history
  • Loading branch information
Soushi888 committed Sep 17, 2024
1 parent 8b050dd commit 94d8988
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
13 changes: 13 additions & 0 deletions ui/src/lib/dialogs/AlertModal.svelte
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
<script lang="ts">
import type { AlertModalMeta } from '@lib/types';
import { getModalStore } from '@skeletonlabs/skeleton';
const modalStore = getModalStore();
const { message } = $modalStore[0].meta as AlertModalMeta;
</script>

<article
class="bg-surface-800 z-20 flex max-h-[90vh] w-11/12 flex-col items-center gap-4 overflow-auto p-10 text-white shadow-xl md:w-4/5 lg:w-3/5"
>
<div class="static space-y-10">
<h2 class="h3 text-center">{message}</h2>
</div>
</article>
1 change: 1 addition & 0 deletions ui/src/lib/dialogs/ConfirmModal.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import type { ConfirmModalMeta } from '@lib/types';
import { getModalStore } from '@skeletonlabs/skeleton';
const modalStore = getModalStore();
Expand Down
1 change: 1 addition & 0 deletions ui/src/lib/dialogs/PromptModal.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import type { PromptModalMeta } from '@lib/types';
import { getModalStore } from '@skeletonlabs/skeleton';
const modalStore = getModalStore();
Expand Down
1 change: 1 addition & 0 deletions ui/src/lib/modals/AddAdministratorModal.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import ConfirmModal from '@lib/dialogs/ConfirmModal.svelte';
import type { ConfirmModalMeta } from '@lib/types';
import {
Avatar,
ConicGradient,
Expand Down
1 change: 1 addition & 0 deletions ui/src/lib/modals/UserDetailsModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import PromptModal from '../dialogs/PromptModal.svelte';
import ConfirmModal from '@lib/dialogs/ConfirmModal.svelte';
import { queueAndReverseModal } from '@utils';
import type { ConfirmModalMeta, PromptModalMeta } from '@lib/types';
const { administrators } = $derived(administratorsStore);
const modalStore = getModalStore();
Expand Down
21 changes: 13 additions & 8 deletions ui/src/types.d.ts → ui/src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
type PromptModalMeta = {
export type AlertModalMeta = {
id: string;
message: string;
};

export type ConfirmModalMeta = {
id: string;
message: string;
confirmLabel?: string;
cancelLabel?: string;
};

export type PromptModalMeta = {
id: string;
message: string;
inputs: {
Expand All @@ -13,10 +25,3 @@ type PromptModalMeta = {
}[];
confirmText?: string;
};

type ConfirmModalMeta = {
id: string;
message: string;
confirmLabel?: string;
cancelLabel?: string;
};
1 change: 1 addition & 0 deletions ui/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const config = {
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter(),
alias: {
'@': './src',
'@static': './static',
'@lib': './src/lib',
'@services': './src/services',
Expand Down

0 comments on commit 94d8988

Please sign in to comment.