mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-25 08:06:51 +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:
29
src/app/components/generator/FileRenaming.tsx
Normal file
29
src/app/components/generator/FileRenaming.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
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 {
|
||||
id: string,
|
||||
name: string,
|
||||
onClose: () => void,
|
||||
}
|
||||
export function FileRenaming({ id, name, onClose }: Props) {
|
||||
const { locale } = useLocale()
|
||||
const { projects, project, updateFile } = useProject()
|
||||
const [fileId, setFileId] = useState(name)
|
||||
|
||||
const doSave = () => {
|
||||
Analytics.renameProjectFile(id, projects.length, project.files.length, 'menu')
|
||||
updateFile(id, name, { type: id, id: fileId })
|
||||
onClose()
|
||||
}
|
||||
|
||||
return <Modal class="file-modal" onDismiss={onClose}>
|
||||
<p>{locale('project.rename_file')}</p>
|
||||
<TextInput autofocus class="btn btn-input" value={fileId} onChange={setFileId} onEnter={doSave} placeholder={locale('resource_location')} spellcheck={false} />
|
||||
<Btn icon="pencil" label={locale('project.rename')} onClick={doSave} />
|
||||
</Modal>
|
||||
}
|
||||
Reference in New Issue
Block a user