edit panes: remove footer buttons, export save() for header

parent components now call save() from sidebar header action
instead of embedded cancel/save buttons
This commit is contained in:
Justin Edmund 2025-12-13 14:34:30 -08:00
parent 4418157ca0
commit 7558aef509
3 changed files with 9 additions and 148 deletions

View file

@ -10,7 +10,6 @@
*/ */
import type { Summon } from '$lib/types/api/entities' import type { Summon } from '$lib/types/api/entities'
import DetailsSection from '$lib/components/sidebar/details/DetailsSection.svelte' import DetailsSection from '$lib/components/sidebar/details/DetailsSection.svelte'
import Button from '$lib/components/ui/Button.svelte'
import UncapIndicator from '$lib/components/uncap/UncapIndicator.svelte' import UncapIndicator from '$lib/components/uncap/UncapIndicator.svelte'
export interface SummonEditValues { export interface SummonEditValues {
@ -30,13 +29,9 @@
currentValues: SummonEditValues currentValues: SummonEditValues
/** Callback when save is clicked */ /** Callback when save is clicked */
onSave?: (updates: SummonEditUpdates) => void onSave?: (updates: SummonEditUpdates) => void
/** Callback when cancel is clicked */
onCancel?: () => void
/** Whether save is in progress */
saving?: boolean
} }
let { summonData, currentValues, onSave, onCancel, saving = false }: Props = $props() let { summonData, currentValues, onSave }: Props = $props()
// Internal state // Internal state
let uncapLevel = $state(currentValues.uncapLevel) let uncapLevel = $state(currentValues.uncapLevel)
@ -67,20 +62,14 @@
transcendenceStep = newStage transcendenceStep = newStage
} }
function handleSave() { // Export save function so parent can call it from header button
export function save() {
const updates: SummonEditUpdates = { const updates: SummonEditUpdates = {
uncapLevel, uncapLevel,
transcendenceStep transcendenceStep
} }
onSave?.(updates) onSave?.(updates)
} }
function handleCancel() {
// Reset to original values
uncapLevel = currentValues.uncapLevel
transcendenceStep = currentValues.transcendenceStep
onCancel?.()
}
</script> </script>
<div class="summon-edit-pane"> <div class="summon-edit-pane">
@ -101,19 +90,6 @@
</div> </div>
</DetailsSection> </DetailsSection>
</div> </div>
<div class="edit-footer">
<Button variant="secondary" onclick={handleCancel} disabled={saving}>Cancel</Button>
<Button
variant="primary"
element={elementName}
elementStyle={!!elementName}
onclick={handleSave}
disabled={saving}
>
{saving ? 'Saving...' : 'Save'}
</Button>
</div>
</div> </div>
<style lang="scss"> <style lang="scss">
@ -123,7 +99,6 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
gap: spacing.$unit-2x;
} }
.edit-sections { .edit-sections {
@ -137,16 +112,4 @@
.section-content { .section-content {
padding: spacing.$unit; padding: spacing.$unit;
} }
.edit-footer {
display: flex;
gap: spacing.$unit-2x;
padding: spacing.$unit-2x;
border-top: 1px solid var(--border-secondary);
flex-shrink: 0;
:global(button) {
flex: 1;
}
}
</style> </style>

View file

@ -16,7 +16,6 @@
import WeaponKeySelect from '$lib/components/sidebar/edit/WeaponKeySelect.svelte' import WeaponKeySelect from '$lib/components/sidebar/edit/WeaponKeySelect.svelte'
import AwakeningSelect from '$lib/components/sidebar/edit/AwakeningSelect.svelte' import AwakeningSelect from '$lib/components/sidebar/edit/AwakeningSelect.svelte'
import AxSkillSelect from '$lib/components/sidebar/edit/AxSkillSelect.svelte' import AxSkillSelect from '$lib/components/sidebar/edit/AxSkillSelect.svelte'
import Button from '$lib/components/ui/Button.svelte'
import UncapIndicator from '$lib/components/uncap/UncapIndicator.svelte' import UncapIndicator from '$lib/components/uncap/UncapIndicator.svelte'
import { getElementIcon } from '$lib/utils/images' import { getElementIcon } from '$lib/utils/images'
import { seriesHasWeaponKeys, getSeriesSlug } from '$lib/utils/weaponSeries' import { seriesHasWeaponKeys, getSeriesSlug } from '$lib/utils/weaponSeries'
@ -60,13 +59,9 @@
currentValues: WeaponEditValues currentValues: WeaponEditValues
/** Callback when save is clicked */ /** Callback when save is clicked */
onSave?: (updates: WeaponEditUpdates) => void onSave?: (updates: WeaponEditUpdates) => void
/** Callback when cancel is clicked */
onCancel?: () => void
/** Whether save is in progress */
saving?: boolean
} }
let { weaponData, currentValues, onSave, onCancel, saving = false }: Props = $props() let { weaponData, currentValues, onSave }: Props = $props()
// Internal state // Internal state
let uncapLevel = $state(currentValues.uncapLevel) let uncapLevel = $state(currentValues.uncapLevel)
@ -166,7 +161,8 @@
transcendenceStep = newStage transcendenceStep = newStage
} }
function handleSave() { // Export save function so parent can call it from header button
export function save() {
const updates: WeaponEditUpdates = { const updates: WeaponEditUpdates = {
uncapLevel, uncapLevel,
transcendenceStep transcendenceStep
@ -213,26 +209,6 @@
onSave?.(updates) onSave?.(updates)
} }
function handleCancel() {
// Reset to original values
uncapLevel = currentValues.uncapLevel
transcendenceStep = currentValues.transcendenceStep
element = currentValues.element ?? weaponData?.element ?? 0
weaponKey1 = currentValues.weaponKey1Id
weaponKey2 = currentValues.weaponKey2Id
weaponKey3 = currentValues.weaponKey3Id
selectedAwakening = currentValues.awakening?.type
awakeningLevel = currentValues.awakening?.level ?? 1
axSkills =
currentValues.axSkills.length > 0
? currentValues.axSkills
: [
{ modifier: -1, strength: 0 },
{ modifier: -1, strength: 0 }
]
onCancel?.()
}
</script> </script>
<div class="weapon-edit-pane"> <div class="weapon-edit-pane">
@ -332,19 +308,6 @@
</DetailsSection> </DetailsSection>
{/if} {/if}
</div> </div>
<div class="edit-footer">
<Button variant="secondary" onclick={handleCancel} disabled={saving}>Cancel</Button>
<Button
variant="primary"
element={elementName}
elementStyle={!!elementName}
onclick={handleSave}
disabled={saving}
>
{saving ? 'Saving...' : 'Save'}
</Button>
</div>
</div> </div>
<style lang="scss"> <style lang="scss">
@ -354,7 +317,6 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
gap: spacing.$unit-2x;
} }
.edit-sections { .edit-sections {
@ -374,16 +336,4 @@
flex-direction: column; flex-direction: column;
gap: spacing.$unit-2x; gap: spacing.$unit-2x;
} }
.edit-footer {
display: flex;
gap: spacing.$unit-2x;
padding: spacing.$unit-2x;
border-top: 1px solid var(--border-secondary);
flex-shrink: 0;
:global(button) {
flex: 1;
}
}
</style> </style>

View file

@ -21,7 +21,6 @@
import RingsSelect from './edit/RingsSelect.svelte' import RingsSelect from './edit/RingsSelect.svelte'
import EarringSelect from './edit/EarringSelect.svelte' import EarringSelect from './edit/EarringSelect.svelte'
import PerpetuityToggle from './edit/PerpetuityToggle.svelte' import PerpetuityToggle from './edit/PerpetuityToggle.svelte'
import Button from '$lib/components/ui/Button.svelte'
import UncapIndicator from '$lib/components/uncap/UncapIndicator.svelte' import UncapIndicator from '$lib/components/uncap/UncapIndicator.svelte'
export interface CharacterEditValues { export interface CharacterEditValues {
@ -57,19 +56,13 @@
showPerpetuity?: boolean showPerpetuity?: boolean
/** Callback when save is clicked, receives API-formatted updates */ /** Callback when save is clicked, receives API-formatted updates */
onSave?: (updates: CharacterEditUpdates) => void onSave?: (updates: CharacterEditUpdates) => void
/** Callback when cancel is clicked */
onCancel?: () => void
/** Whether save is in progress (disables buttons) */
saving?: boolean
} }
let { let {
characterData, characterData,
currentValues, currentValues,
showPerpetuity = true, showPerpetuity = true,
onSave, onSave
onCancel,
saving = false
}: Props = $props() }: Props = $props()
// Internal state - initialized from currentValues // Internal state - initialized from currentValues
@ -143,7 +136,8 @@
transcendenceStep = newStage transcendenceStep = newStage
} }
function handleSave() { // Export save function so parent can call it from header button
export function save() {
const updates: CharacterEditUpdates = { const updates: CharacterEditUpdates = {
uncapLevel, uncapLevel,
transcendenceStep, transcendenceStep,
@ -173,26 +167,6 @@
onSave?.(updates) onSave?.(updates)
} }
function handleCancel() {
// Reset to original values
uncapLevel = currentValues.uncapLevel
transcendenceStep = currentValues.transcendenceStep
selectedAwakening = currentValues.awakening?.type
awakeningLevel = currentValues.awakening?.level ?? 1
rings =
currentValues.rings.length > 0
? currentValues.rings
: [
{ modifier: 1, strength: 0 },
{ modifier: 2, strength: 0 },
{ modifier: 0, strength: 0 },
{ modifier: 0, strength: 0 }
]
earring = currentValues.earring ?? undefined
perpetuity = currentValues.perpetuity
onCancel?.()
}
</script> </script>
<div class="character-edit-pane"> <div class="character-edit-pane">
@ -270,19 +244,6 @@
</DetailsSection> </DetailsSection>
{/if} {/if}
</div> </div>
<div class="edit-footer">
<Button variant="secondary" onclick={handleCancel} disabled={saving}>Cancel</Button>
<Button
variant="primary"
element={elementName}
elementStyle={!!elementName}
onclick={handleSave}
disabled={saving}
>
{saving ? 'Saving...' : 'Save'}
</Button>
</div>
</div> </div>
<style lang="scss"> <style lang="scss">
@ -292,7 +253,6 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
gap: spacing.$unit-2x;
} }
.edit-sections { .edit-sections {
@ -306,16 +266,4 @@
.section-content { .section-content {
padding: spacing.$unit; padding: spacing.$unit;
} }
.edit-footer {
display: flex;
gap: spacing.$unit-2x;
padding: spacing.$unit-2x;
border-top: 1px solid var(--border-secondary);
flex-shrink: 0;
:global(button) {
flex: 1;
}
}
</style> </style>