File tree 7 files changed +108
-14
lines changed
7 files changed +108
-14
lines changed Original file line number Diff line number Diff line change 28
28
"build" : " npm run build:babel && cp ./package.json ./dist/package.json" ,
29
29
"build:babel" : " NODE_ENV=production babel ./src --out-dir=./dist" ,
30
30
"build-storybook" : " build-storybook" ,
31
- "deploy-storybook" : " storybook-to-ghpages"
31
+ "build:gh-pages" : " react-scripts build" ,
32
+ "deploy:gh-pages" : " gh-pages -d build"
32
33
},
33
34
"eslintConfig" : {
34
35
"extends" : " react-app"
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1, shrink-to-fit=no ">
6
+ < meta name ="theme-color " content ="#000000 ">
7
+ <!--
8
+ manifest.json provides metadata used when your web app is added to the
9
+ homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
10
+ -->
11
+ <!--
12
+ Notice the use of %PUBLIC_URL% in the tags above.
13
+ It will be replaced with the URL of the `public` folder during the build.
14
+ Only files inside the `public` folder can be referenced from the HTML.
15
+
16
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
17
+ work correctly both with client-side routing and a non-root public URL.
18
+ Learn how to configure a non-root public URL by running `npm run build`.
19
+ -->
20
+ < title > React Image Annotation</ title >
21
+ </ head >
22
+ < body >
23
+ < noscript >
24
+ You need to enable JavaScript to run this app.
25
+ </ noscript >
26
+ < div id ="root "> </ div >
27
+ <!--
28
+ This HTML file is a template.
29
+ If you open it directly in the browser, you will see an empty page.
30
+
31
+ You can add webfonts, meta tags, or analytics to this file.
32
+ The build step will place the bundled scripts into the <body> tag.
33
+
34
+ To begin the development, run `npm start` or `yarn start`.
35
+ To create a production bundle, use `npm run build` or `yarn build`.
36
+ -->
37
+ </ body >
38
+ </ html >
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ const useStyles = makeStyles({
29
29
}
30
30
} )
31
31
32
- const examples = {
32
+ export const examples = {
33
33
"Simple Bounding Box" : {
34
34
taskDescription :
35
35
"Annotate each image according to this _markdown_ specification." ,
@@ -52,9 +52,7 @@ const examples = {
52
52
53
53
const Editor = ( { onOpenAnnotator, lastOutput } : any ) => {
54
54
const c = useStyles ( )
55
- const [ selectedExample , changeSelectedExample ] = useState (
56
- "Simple Bounding Box"
57
- )
55
+ const [ selectedExample , changeSelectedExample ] = useState ( "Custom" )
58
56
const [ outputDialogOpen , changeOutputOpen ] = useState ( false )
59
57
return (
60
58
< div >
@@ -87,7 +85,9 @@ const Editor = ({ onOpenAnnotator, lastOutput }: any) => {
87
85
variant = "outlined"
88
86
onClick = { ( ) =>
89
87
onOpenAnnotator (
90
- JSON . parse ( window . localStorage . getItem ( "customInput" ) )
88
+ selectedExample === "Custom"
89
+ ? JSON . parse ( window . localStorage . getItem ( "customInput" ) )
90
+ : examples [ selectedExample ]
91
91
)
92
92
}
93
93
>
Original file line number Diff line number Diff line change
1
+ // @flow
2
+
3
+ import React , { Component } from "react"
4
+ import Dialog from "@material-ui/core/Dialog"
5
+ import Button from "@material-ui/core/Button"
6
+ import DialogTitle from "@material-ui/core/DialogTitle"
7
+ import DialogContent from "@material-ui/core/DialogContent"
8
+ import DialogActions from "@material-ui/core/DialogActions"
9
+
10
+ export default class ErrorBoundaryDialog extends Component {
11
+ state = { hasError : false , err : "" }
12
+ componentDidCatch ( err , info ) {
13
+ this . setState ( {
14
+ hasError : true ,
15
+ err : err . toString ( ) + "\n\n" + info . componentStack
16
+ } )
17
+ }
18
+ render ( ) {
19
+ if ( this . state . hasError ) {
20
+ return (
21
+ < Dialog open = { this . state . hasError } onClose = { this . props . onClose } >
22
+ < DialogTitle > Error Loading Annotator</ DialogTitle >
23
+ < DialogContent >
24
+ < pre > { this . state . err } </ pre >
25
+ </ DialogContent >
26
+ < DialogActions >
27
+ < Button onClick = { this . props . onClose } > Close</ Button >
28
+ </ DialogActions >
29
+ </ Dialog >
30
+ )
31
+ }
32
+ return this . props . children
33
+ }
34
+ }
Original file line number Diff line number Diff line change 1
1
// @flow
2
2
import React , { useState } from "react"
3
- import Editor from "./Editor"
3
+ import ReactDOM from "react-dom"
4
+ import Editor , { examples } from "./Editor"
4
5
import Annotator from "../Annotator"
6
+ import ErrorBoundaryDialog from "./ErrorBoundaryDialog.js"
5
7
6
8
export default ( ) => {
7
9
const [ annotatorOpen , changeAnnotatorOpen ] = useState ( false )
8
- const [ annotatorProps , changeAnnotatorProps ] = useState ( { } )
10
+ const [ annotatorProps , changeAnnotatorProps ] = useState ( examples [ "Custom" ] ( ) )
9
11
const [ lastOutput , changeLastOutput ] = useState ( )
10
12
11
13
return (
12
14
< div >
13
15
{ annotatorOpen ? (
14
- < Annotator
15
- { ...( annotatorProps : any ) }
16
- onExit = { output => {
17
- delete ( output : any ) [ "lastAction" ]
18
- changeLastOutput ( output )
16
+ < ErrorBoundaryDialog
17
+ onClose = { ( ) => {
19
18
changeAnnotatorOpen ( false )
20
19
} }
21
- />
20
+ >
21
+ < Annotator
22
+ { ...( annotatorProps : any ) }
23
+ onExit = { output => {
24
+ delete ( output : any ) [ "lastAction" ]
25
+ changeLastOutput ( output )
26
+ changeAnnotatorOpen ( false )
27
+ } }
28
+ />
29
+ </ ErrorBoundaryDialog >
22
30
) : (
23
31
< Editor
24
32
lastOutput = { lastOutput }
Original file line number Diff line number Diff line change
1
+ // @flow
2
+
3
+ import React from "react"
4
+ import ReactDOM from "react-dom"
5
+ import Theme from "./Theme"
6
+ import DemoSite from "./DemoSite"
7
+
8
+ ReactDOM . render (
9
+ < Theme >
10
+ < DemoSite />
11
+ </ Theme > ,
12
+ document . getElementById ( "root" )
13
+ )
You can’t perform that action at this time.
0 commit comments