Skip to content

Commit

Permalink
feat(FileSelector): add an increment counter for new files (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Megrax authored May 25, 2022
1 parent 81aba6a commit 63b8f22
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/editor/FileSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ import { computed, inject, ref, VNode, Ref } from 'vue'
const store = inject('store') as Store
const pending = ref(false)
const pendingFilename = ref('Comp.vue')
const newFileCount = ref(0)
const customizedFilename = ref('')
const pendingFilename = computed({
get(): string {
if (customizedFilename.value) {
return customizedFilename.value
}
return newFileCount.value > 0 ? `Comp${newFileCount.value}.vue` : 'Comp.vue'
},
set(name: string) {
customizedFilename.value = name
}
})
const importMapFile = 'import-map.json'
const showImportMap = inject('import-map') as Ref<boolean>
const files = computed(() =>
Expand Down Expand Up @@ -45,7 +57,10 @@ function doneAddFile() {
store.state.errors = []
cancelAddFile()
store.addFile(filename)
pendingFilename.value = 'Comp.vue'
customizedFilename.value = ''
if (filename === pendingFilename.value) {
newFileCount.value++
}
}
const fileSel = ref(null)
Expand Down

0 comments on commit 63b8f22

Please sign in to comment.