@@ -14,6 +14,8 @@ import {
1414} from "semantic-ui-react" ;
1515import seqparse from "seqparse" ;
1616
17+ import Circular from "../../src/Circular/Circular" ;
18+ import Linear from "../../src/Linear/Linear" ;
1719import SeqViz from "../../src/SeqViz" ;
1820import { AnnotationProp } from "../../src/elements" ;
1921import Header from "./Header" ;
@@ -29,6 +31,7 @@ const viewerTypeOptions = [
2931
3032interface AppState {
3133 annotations : AnnotationProp [ ] ;
34+ customChildren : boolean ;
3235 enzymes : any [ ] ;
3336 name : string ;
3437 primers : boolean ;
@@ -48,6 +51,7 @@ interface AppState {
4851export default class App extends React . Component < any , AppState > {
4952 state : AppState = {
5053 annotations : [ ] ,
54+ customChildren : true ,
5155 enzymes : [ "PstI" , "EcoRI" , "XbaI" , "SpeI" ] ,
5256 name : "" ,
5357 primers : true ,
@@ -67,6 +71,8 @@ export default class App extends React.Component<any, AppState> {
6771 viewer : "" ,
6872 zoom : 50 ,
6973 } ;
74+ linearRef : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
75+ circularRef : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
7076
7177 componentDidMount = async ( ) => {
7278 const seq = await seqparse ( file ) ;
@@ -98,6 +104,59 @@ export default class App extends React.Component<any, AppState> {
98104 } ;
99105
100106 render ( ) {
107+
108+ let customChildren = null ;
109+ if ( this . state . customChildren ) {
110+ customChildren = ( { circularProps, linearProps, ...props } ) => {
111+ if ( this . state . viewer === "linear" ) {
112+ return (
113+ < div ref = { this . linearRef } style = { { height : "100%" , width : "100%" } } >
114+ < Linear { ...linearProps } { ...props } />
115+ </ div >
116+ ) ;
117+ } else if ( this . state . viewer === "circular" ) {
118+ return (
119+ < div ref = { this . circularRef } style = { { height : "100%" , width : "100%" } } >
120+ < Circular { ...circularProps } { ...props } />
121+ </ div >
122+ ) ;
123+ } else if ( this . state . viewer === "both" ) {
124+ return (
125+ < div style = { { display : "flex" , flexDirection : "row" , height : "100%" , width : "100%" } } >
126+ < div ref = { this . circularRef } style = { { height : "100%" , width : "70%" } } >
127+ < Circular { ...circularProps } { ...props } />
128+ </ div >
129+ < div ref = { this . linearRef } style = { { height : "100%" , width : "30%" } } >
130+ < Linear { ...linearProps } { ...props } />
131+ </ div >
132+ </ div >
133+ ) ;
134+ } else if ( this . state . viewer === "both_flip" ) {
135+ return (
136+ < div style = { { display : "flex" , flexDirection : "row" , height : "100%" , width : "100%" } } >
137+ < div ref = { this . linearRef } style = { { height : "100%" , width : "30%" } } >
138+ < Linear { ...linearProps } { ...props } />
139+ </ div >
140+ < div ref = { this . circularRef } style = { { height : "100%" , width : "70%" } } >
141+ < Circular { ...circularProps } { ...props } />
142+ </ div >
143+ </ div >
144+ ) ;
145+ } else {
146+ return (
147+ < div style = { { display : "flex" , flexDirection : "column" , width : "100%" } } >
148+ < div ref = { this . linearRef } style = { { height : "25%" , width : "100%" } } >
149+ < Linear { ...linearProps } { ...props } />
150+ </ div >
151+ < div ref = { this . circularRef } style = { { height : "75%" , width : "100%" } } >
152+ < Circular { ...circularProps } { ...props } />
153+ </ div >
154+ </ div >
155+ ) ;
156+ }
157+ }
158+ }
159+
101160 return (
102161 < div style = { { height : "100vh" } } >
103162 < Sidebar . Pushable className = "sidebar-container" >
@@ -134,6 +193,13 @@ export default class App extends React.Component<any, AppState> {
134193 < Menu . Item as = "a" className = "options-checkbox" >
135194 < CheckboxInput label = "Show index" name = "index" set = { showIndex => this . setState ( { showIndex } ) } />
136195 </ Menu . Item >
196+ < Menu . Item as = "a" className = "options-checkbox" >
197+ < CheckboxInput
198+ label = "Custom Children"
199+ name = "customChildren"
200+ set = { customChildren => this . setState ( { customChildren } ) }
201+ />
202+ </ Menu . Item >
137203 < Menu . Item as = "a" >
138204 < EnzymeInput enzymes = { this . state . enzymes } toggleEnzyme = { this . toggleEnzyme } />
139205 </ Menu . Item >
@@ -151,9 +217,11 @@ export default class App extends React.Component<any, AppState> {
151217 { this . state . seq && (
152218 < SeqViz
153219 // accession="MN623123"
220+ key = { `${ this . state . viewer } ${ this . state . customChildren } ` }
154221 annotations = { this . state . annotations }
155222 enzymes = { this . state . enzymes }
156223 name = { this . state . name }
224+ refs = { { circular : this . circularRef , linear : this . linearRef } }
157225 search = { this . state . search }
158226 selection = { this . state . selection }
159227 seq = { this . state . seq }
@@ -163,7 +231,9 @@ export default class App extends React.Component<any, AppState> {
163231 viewer = { this . state . viewer as "linear" | "circular" }
164232 zoom = { { linear : this . state . zoom } }
165233 onSelection = { selection => this . setState ( { selection } ) }
166- />
234+ >
235+ { customChildren }
236+ </ SeqViz >
167237 ) }
168238 </ div >
169239 </ div >
0 commit comments