-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* deps: add codemirror dependencies * add user theme data endpoint * Add code mirror editor for theme json data * Moved json editor stuff to a modal class and started a resolvers file for API handling * add theme name to editor modal title * refactor fetchThemeJson * reword from editor to inspector * reword * Update src/plugin-sidebar.js Co-authored-by: Sarah Norris <1645628+mikachan@users.noreply.github.com> * Update src/editor-sidebar/json-editor-modal.js Co-authored-by: Sarah Norris <1645628+mikachan@users.noreply.github.com> --------- Co-authored-by: Jason Crist <jcrist@pbking.com> Co-authored-by: Sarah Norris <1645628+mikachan@users.noreply.github.com>
- Loading branch information
1 parent
7036404
commit 0f961ef
Showing
7 changed files
with
333 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { useState, useEffect } from '@wordpress/element'; | ||
import { Modal } from '@wordpress/components'; | ||
import { useSelect } from '@wordpress/data'; | ||
import CodeMirror from '@uiw/react-codemirror'; | ||
import { json } from '@codemirror/lang-json'; | ||
import { fetchThemeJson } from '../resolvers'; | ||
|
||
const ThemeJsonEditorModal = ( { onRequestClose } ) => { | ||
const [ themeData, setThemeData ] = useState( '' ); | ||
const themeName = useSelect( ( select ) => | ||
select( 'core' ).getCurrentTheme() | ||
)?.name?.raw; | ||
const fetchThemeData = async () => { | ||
setThemeData( await fetchThemeJson() ); | ||
}; | ||
const handleSave = () => {}; | ||
|
||
useEffect( () => { | ||
fetchThemeData(); | ||
} ); | ||
|
||
return ( | ||
<Modal | ||
isFullScreen | ||
title={ `theme.json for ${ themeName }` } | ||
onRequestClose={ onRequestClose } | ||
> | ||
<CodeMirror | ||
extensions={ [ json() ] } | ||
value={ themeData } | ||
onChange={ handleSave } | ||
readOnly={ true } | ||
/> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ThemeJsonEditorModal; |
Oops, something went wrong.