mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 23:27:09 +00:00
Project tree view and creation (#203)
* Implement creating and importing new projects * Add downloading a zip of a project * Project validation (WIP) * Add project side panel, remove project pages * Project file saving * Add file tree actions to rename and delete * Fix file creation auto focus * Add button to save file from menu * Add project creation * Fix specificity on version switcher button * Update default version to 1.19 * List project files by type, remember project and delete project
This commit is contained in:
31
src/app/components/generator/FileCreation.tsx
Normal file
31
src/app/components/generator/FileCreation.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { DataModel } from '@mcschema/core'
|
||||
import { useState } from 'preact/hooks'
|
||||
import { Analytics } from '../../Analytics'
|
||||
import { useLocale, useProject } from '../../contexts'
|
||||
import { Btn } from '../Btn'
|
||||
import { TextInput } from '../forms'
|
||||
import { Modal } from '../Modal'
|
||||
|
||||
interface Props {
|
||||
model: DataModel,
|
||||
id: string,
|
||||
method: string,
|
||||
onClose: () => void,
|
||||
}
|
||||
export function FileCreation({ model, id, method, onClose }: Props) {
|
||||
const { locale } = useLocale()
|
||||
const { projects, project, updateFile } = useProject()
|
||||
const [fileId, setFileId] = useState('')
|
||||
|
||||
const doSave = () => {
|
||||
Analytics.saveProjectFile(id, projects.length, project.files.length, method as any)
|
||||
updateFile(id, undefined, { type: id, id: fileId, data: DataModel.unwrapLists(model.data) })
|
||||
onClose()
|
||||
}
|
||||
|
||||
return <Modal class="file-modal" onDismiss={onClose}>
|
||||
<p>{locale('project.save_current_file')}</p>
|
||||
<TextInput autofocus class="btn btn-input" value={fileId} onChange={setFileId} onEnter={doSave} onCancel={onClose} placeholder={locale('resource_location')} spellcheck={false} />
|
||||
<Btn icon="file" label={locale('project.save')} onClick={doSave} />
|
||||
</Modal>
|
||||
}
|
||||
Reference in New Issue
Block a user