mirror of https://github.com/sgoudham/carbon.git
move editor container into its own component
parent
47c30c1b7f
commit
dff5013edd
@ -0,0 +1,25 @@
|
|||||||
|
// Theirs
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
import Editor from './Editor'
|
||||||
|
import { THEMES } from '../lib/constants'
|
||||||
|
import { getThemes, saveThemes } from '../lib/util'
|
||||||
|
|
||||||
|
function EditorContainer(props) {
|
||||||
|
const [themes, updateThemes] = React.useState(THEMES)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const storedThemes = getThemes(localStorage) || []
|
||||||
|
if (storedThemes) {
|
||||||
|
updateThemes(currentThemes => [...storedThemes, ...currentThemes])
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
saveThemes(localStorage, themes.filter(({ custom }) => custom))
|
||||||
|
}, [themes])
|
||||||
|
|
||||||
|
return <Editor {...props} themes={themes} updateThemes={updateThemes} />
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EditorContainer
|
Loading…
Reference in New Issue