move preset saving to separate component
This commit is contained in:
parent
94f34e56d1
commit
09d7741d07
3 changed files with 29 additions and 15 deletions
16
src/App.vue
16
src/App.vue
|
@ -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'
|
||||
|
|
27
src/components/PresetSaver.vue
Normal file
27
src/components/PresetSaver.vue
Normal 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>
|
|
@ -12,4 +12,3 @@ export const MAX_AMOUNT_RINGS = 15
|
|||
|
||||
export const MIN_DISTANCE_PLANET = 32
|
||||
export const MAX_DISTANCE_PLANET = 999
|
||||
|
||||
|
|
Loading…
Reference in a new issue