* Add file save UI and drafts project

* Fix build

* Create SearchList component as abstraction

* Add project page and file tree view

* Create Locale context

* Create Theme context

* Create Version context

* Create Title context

* Create Project context

* Store current file in project context

* Fix issues when renaming file and implement deleting

* Style improvements

* Make all project strings translatable

* Fix z-index
This commit is contained in:
Misode
2022-01-18 01:02:19 +01:00
committed by GitHub
parent cd318dc795
commit c6c52ca41a
39 changed files with 958 additions and 373 deletions

View File

@@ -1,3 +1,5 @@
import type { Project } from './contexts'
import { DRAFT_PROJECT } from './contexts'
import type { VersionId } from './services'
import { VersionIds } from './services'
@@ -8,6 +10,7 @@ export namespace Store {
export const ID_INDENT = 'indentation'
export const ID_FORMAT = 'output_format'
export const ID_SOUNDS_VERSION = 'minecraft_sounds_version'
export const ID_PROJECTS = 'misode_projects'
export function getLanguage() {
return localStorage.getItem(ID_LANGUAGE) ?? 'en'
@@ -37,6 +40,14 @@ export namespace Store {
return localStorage.getItem(ID_SOUNDS_VERSION) ?? 'latest'
}
export function getProjects(): Project[] {
const projects = localStorage.getItem(ID_PROJECTS)
if (projects) {
return JSON.parse(projects) as Project[]
}
return [DRAFT_PROJECT]
}
export function setLanguage(language: string | undefined) {
if (language) localStorage.setItem(ID_LANGUAGE, language)
}
@@ -60,4 +71,8 @@ export namespace Store {
export function setSoundsVersion(version: string | undefined) {
if (version) localStorage.setItem(ID_SOUNDS_VERSION, version)
}
export function setProjects(projects: Project[] | undefined) {
if (projects) localStorage.setItem(ID_PROJECTS, JSON.stringify(projects))
}
}