22
33import React , { useState } from "react"
44import Button from "@mui/material/Button"
5- import { makeStyles } from '@mui/styles' ;
5+ import { makeStyles } from "@mui/styles"
6+ import { createTheme , ThemeProvider } from "@mui/material/styles"
67import Select from "react-select"
78import Code from "react-syntax-highlighter"
89import Dialog from "@mui/material/Dialog"
@@ -11,7 +12,8 @@ import DialogContent from "@mui/material/DialogContent"
1112import DialogActions from "@mui/material/DialogActions"
1213import MonacoEditor from "react-monaco-editor"
1314
14- const useStyles = makeStyles ( {
15+ const theme = createTheme ( ) ;
16+ const useStyles = makeStyles ( ( theme ) => ( {
1517 editBar : {
1618 padding : 10 ,
1719 borderBottom : "1px solid #ccc" ,
@@ -27,7 +29,7 @@ const useStyles = makeStyles({
2729 specificationArea : {
2830 padding : 10 ,
2931 } ,
30- } )
32+ } ) )
3133
3234const loadSavedInput = ( ) => {
3335 try {
@@ -90,89 +92,90 @@ const Editor = ({ onOpenAnnotator, lastOutput }: any) => {
9092 JSON . stringify ( examples [ selectedExample ] ( ) , null , " " )
9193 )
9294 return (
93- < div >
94- < div className = { c . editBar } >
95- < h3 > React Image Annotate</ h3 >
96- < div style = { { flexGrow : 1 } } />
97- < div >
98- < div style = { { display : "inline-flex" } } >
99- < Select
100- className = { c . select }
101- value = { { label : selectedExample , value : selectedExample } }
102- options = { Object . keys ( examples ) . map ( ( s ) => ( {
103- label : s ,
104- value : s ,
105- } ) ) }
106- onChange = { ( selectedOption ) => {
107- changeSelectedExample ( selectedOption . value )
95+ < ThemeProvider theme = { theme } >
96+ < div >
97+ < div className = { c . editBar } >
98+ < h3 > React Image Annotate</ h3 >
99+ < div style = { { flexGrow : 1 } } />
100+ < div >
101+ < div style = { { display : "inline-flex" } } >
102+ < Select
103+ className = { c . select }
104+ value = { { label : selectedExample , value : selectedExample } }
105+ options = { Object . keys ( examples ) . map ( ( s ) => ( {
106+ label : s ,
107+ value : s ,
108+ } ) ) }
109+ onChange = { ( selectedOption ) => {
110+ changeSelectedExample ( selectedOption . value )
108111
109- changeCurrentJSONValue (
110- JSON . stringify (
111- selectedOption . value === "Custom"
112- ? loadSavedInput ( )
113- : examples [ selectedOption . value ] ( ) ,
114- null ,
115- " "
112+ changeCurrentJSONValue (
113+ JSON . stringify (
114+ selectedOption . value === "Custom"
115+ ? loadSavedInput ( )
116+ : examples [ selectedOption . value ] ( ) ,
117+ null ,
118+ " "
119+ )
116120 )
121+ } }
122+ />
123+ </ div >
124+ < Button
125+ className = "button"
126+ disabled = { ! lastOutput }
127+ onClick = { ( ) => changeOutputOpen ( true ) }
128+ >
129+ View Output
130+ </ Button >
131+ < Button
132+ className = "button"
133+ variant = "outlined"
134+ disabled = { Boolean ( currentError ) }
135+ onClick = { ( ) => {
136+ onOpenAnnotator (
137+ selectedExample === "Custom"
138+ ? loadSavedInput ( )
139+ : examples [ selectedExample ]
117140 )
118141 } }
119- />
142+ >
143+ Open Annotator
144+ </ Button >
120145 </ div >
121- < Button
122- className = "button"
123- disabled = { ! lastOutput }
124- onClick = { ( ) => changeOutputOpen ( true ) }
125- >
126- View Output
127- </ Button >
128- < Button
129- className = "button"
130- variant = "outlined"
131- disabled = { Boolean ( currentError ) }
132- onClick = { ( ) => {
133- onOpenAnnotator (
134- selectedExample === "Custom"
135- ? loadSavedInput ( )
136- : examples [ selectedExample ]
137- )
138- } }
139- >
140- Open Annotator
141- </ Button >
142146 </ div >
143- </ div >
144- < div
145- className = { c . contentArea }
146- style = {
147- currentError
148- ? { border : "2px solid #f00 " }
149- : { border : "2px solid #fff" }
150- }
151- >
152- < div >
153- < MonacoEditor
154- value = { currentJSONValue }
155- language = "javascript"
156- onChange = { ( code ) => {
157- try {
158- window . localStorage . setItem (
159- "customInput" ,
160- JSON . stringify ( JSON . parse ( code ) )
161- )
162- changeCurrentError ( null )
163- } catch ( e ) {
164- changeCurrentError ( e . toString ( ) )
165- }
166- changeCurrentJSONValue ( code )
167- } }
168- width = "100% "
169- height = "550px"
170- / >
147+ < div
148+ className = { c . contentArea }
149+ style = {
150+ currentError
151+ ? { border : "2px solid #f00" }
152+ : { border : "2px solid #fff " }
153+ }
154+ >
155+ < div >
156+ < MonacoEditor
157+ value = { currentJSONValue }
158+ language = "javascript"
159+ onChange = { ( code ) => {
160+ try {
161+ window . localStorage . setItem (
162+ "customInput" ,
163+ JSON . stringify ( JSON . parse ( code ) )
164+ )
165+ changeCurrentError ( null )
166+ } catch ( e ) {
167+ changeCurrentError ( e . toString ( ) )
168+ }
169+ changeCurrentJSONValue ( code )
170+ } }
171+ width = "100%"
172+ height = "550px "
173+ />
174+ </ div >
171175 </ div >
172- </ div >
173- < div className = { c . specificationArea } >
174- < h2 > React Image Annotate Format</ h2 >
175- < Code language = "javascript" > { `
176+ < div className = { c . specificationArea } >
177+ < h2 > React Image Annotate Format</ h2 >
178+ < Code language = "javascript" > { `
176179{
177180 taskDescription?: string, // markdown
178181 regionTagList?: Array<string>,
@@ -212,22 +215,23 @@ const Editor = ({ onOpenAnnotator, lastOutput }: any) => {
212215 }>,
213216}
214217` } </ Code >
218+ </ div >
219+ < Dialog fullScreen open = { outputDialogOpen } >
220+ < DialogTitle > React Image Annotate Output</ DialogTitle >
221+ < DialogContent style = { { minWidth : 400 } } >
222+ < MonacoEditor
223+ value = { JSON . stringify ( lastOutput , null , " " ) }
224+ language = "javascript"
225+ width = "100%"
226+ height = "550px"
227+ />
228+ </ DialogContent >
229+ < DialogActions >
230+ < Button onClick = { ( ) => changeOutputOpen ( false ) } > Close</ Button >
231+ </ DialogActions >
232+ </ Dialog >
215233 </ div >
216- < Dialog fullScreen open = { outputDialogOpen } >
217- < DialogTitle > React Image Annotate Output</ DialogTitle >
218- < DialogContent style = { { minWidth : 400 } } >
219- < MonacoEditor
220- value = { JSON . stringify ( lastOutput , null , " " ) }
221- language = "javascript"
222- width = "100%"
223- height = "550px"
224- />
225- </ DialogContent >
226- < DialogActions >
227- < Button onClick = { ( ) => changeOutputOpen ( false ) } > Close</ Button >
228- </ DialogActions >
229- </ Dialog >
230- </ div >
234+ </ ThemeProvider >
231235 )
232236}
233237
0 commit comments