mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
* 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
30 lines
1017 B
TypeScript
30 lines
1017 B
TypeScript
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>
|
|
}
|