move preset saving to separate component

This commit is contained in:
Norman Köhring 2023-03-18 20:52:32 +01:00
parent 94f34e56d1
commit 09d7741d07
3 changed files with 29 additions and 15 deletions

View file

@ -22,20 +22,7 @@
<PresetLoader />
</template>
<template #save>
<p>
<label>
Save current system as:
<input placeholder="fancy star system" v-model="currentName" />
</label>
</p>
<p>
<b>Local Storage </b>
<button @click="savePreset(star, objects)">save as "{{ currentName }}"</button>
</p>
<p>
<b>File System </b>
<a :href="fileBlob" :download="`${currentName}.json`">download as {{ currentName }}.json</a>
</p>
<PresetSaver />
</template>
<template #x></template>
</AppMenu>
@ -56,6 +43,7 @@ import SystemSettings from './components/SystemSettings.vue'
import ObjectList from './components/ObjectList.vue'
import ObjectSettings from './components/ObjectSettings.vue'
import PresetLoader from './components/PresetLoader.vue'
import PresetSaver from './components/PresetSaver.vue'
import useObjects from './useObjects'
import useStorage from './useStorage'

View file

@ -0,0 +1,27 @@
<template>
<p>
<label>
Save current system as:
<input placeholder="fancy star system" v-model="currentName" />
</label>
</p>
<p>
<b>Local Storage </b>
<button @click="savePreset(star, objects)">save as "{{ currentName }}"</button>
</p>
<p>
<b>File System </b>
<a :href="fileBlob" :download="`${currentName}.json`">download as {{ currentName }}.json</a>
</p>
</template>
<script setup>
import useObjects from '../useObjects'
import useStorage from '../useStorage'
const { star, objects } = useObjects()
const {
savePreset,
currentName,
} = useStorage(star, objects)
</script>

View file

@ -12,4 +12,3 @@ export const MAX_AMOUNT_RINGS = 15
export const MIN_DISTANCE_PLANET = 32
export const MAX_DISTANCE_PLANET = 999