diff --git a/src/lib/components/sidebar/AddArtifactSidebar.svelte b/src/lib/components/sidebar/AddArtifactSidebar.svelte new file mode 100644 index 00000000..f0095b62 --- /dev/null +++ b/src/lib/components/sidebar/AddArtifactSidebar.svelte @@ -0,0 +1,391 @@ + + + + +
+
+ + + (element = v)} + size="small" + contained + placeholder="Select element" + /> + + + + {#if proficiency !== undefined} + +
+ {#if artifactsQuery.isPending} +

Loading artifacts...

+ {:else if artifactsQuery.isError} +

Failed to load artifacts

+ {:else if artifactOptions.length === 0} +

No artifacts available for this proficiency

+ {:else} + v !== undefined && (level = v)} + size="small" + contained + /> + + + + + + + + {#if !isQuirk} + +
+ {#each [1, 2, 3, 4] as slot} + handleSelectModifier(slot)} + onUpdateSkill={(update) => handleUpdateSkill(slot, update)} + /> + {/each} +
+
+ {/if} + {/if} +
+ + +
+ + diff --git a/src/lib/features/collection/openAddArtifactSidebar.ts b/src/lib/features/collection/openAddArtifactSidebar.ts new file mode 100644 index 00000000..07f6da62 --- /dev/null +++ b/src/lib/features/collection/openAddArtifactSidebar.ts @@ -0,0 +1,23 @@ +import { sidebar } from '$lib/stores/sidebar.svelte' +import AddArtifactSidebar from '$lib/components/sidebar/AddArtifactSidebar.svelte' + +/** + * Opens the Add Artifact sidebar for adding a new artifact to the collection. + * + * Uses the pane stack pattern - the root pane allows artifact selection and + * configuration, with skill modifier selection pushing additional panes. + */ +export function openAddArtifactSidebar(options?: { onSuccess?: () => void }) { + const handleClose = () => { + sidebar.close() + } + + sidebar.openWithComponent('Add Artifact', AddArtifactSidebar, { + onSuccess: options?.onSuccess, + onClose: handleClose + }) +} + +export function closeAddArtifactSidebar() { + sidebar.close() +} diff --git a/src/routes/(app)/[username]/collection/+layout.svelte b/src/routes/(app)/[username]/collection/+layout.svelte index 916f4b31..270a65d6 100644 --- a/src/routes/(app)/[username]/collection/+layout.svelte +++ b/src/routes/(app)/[username]/collection/+layout.svelte @@ -8,6 +8,7 @@ import Button from '$lib/components/ui/Button.svelte' import Icon from '$lib/components/Icon.svelte' import AddToCollectionModal from '$lib/components/collection/AddToCollectionModal.svelte' + import { openAddArtifactSidebar } from '$lib/features/collection/openAddArtifactSidebar' let { data, children }: { data: LayoutData; children: any } = $props() @@ -26,13 +27,16 @@ const modalEntityType = $derived.by((): 'character' | 'weapon' | 'summon' | undefined => { if (activeEntityType === 'weapons') return 'weapon' if (activeEntityType === 'summons') return 'summon' - if (activeEntityType === 'artifacts') return undefined // Artifacts use different flow + if (activeEntityType === 'artifacts') return undefined // Artifacts use sidebar instead return 'character' }) - // Whether the current entity type supports the add modal + // Whether the current entity type supports the add modal (all except artifacts) const supportsAddModal = $derived(activeEntityType !== 'artifacts') + // Whether to show the add button for artifacts (uses sidebar instead of modal) + const isArtifacts = $derived(activeEntityType === 'artifacts') + // Dynamic button text const addButtonText = $derived(`Add ${activeEntityType}`) @@ -41,6 +45,10 @@ function handleTabChange(value: string) { goto(`/${username}/collection/${value}`) } + + function handleAddArtifact() { + openAddArtifactSidebar() + } @@ -80,6 +88,16 @@ > {addButtonText} + {:else if data.isOwner && isArtifacts} + {/if}