mirror of https://github.com/sgoudham/carbon.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
666 B
JavaScript
26 lines
666 B
JavaScript
6 years ago
|
// 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
|