mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-26 00:16:51 +00:00
Projects (#192)
* 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:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user