@@ -14,6 +14,8 @@ import {
14
14
} from "semantic-ui-react" ;
15
15
import seqparse from "seqparse" ;
16
16
17
+ import Circular from "../../src/Circular/Circular" ;
18
+ import Linear from "../../src/Linear/Linear" ;
17
19
import SeqViz from "../../src/SeqViz" ;
18
20
import { AnnotationProp } from "../../src/elements" ;
19
21
import Header from "./Header" ;
@@ -29,6 +31,7 @@ const viewerTypeOptions = [
29
31
30
32
interface AppState {
31
33
annotations : AnnotationProp [ ] ;
34
+ customChildren : boolean ;
32
35
enzymes : any [ ] ;
33
36
name : string ;
34
37
primers : boolean ;
@@ -48,6 +51,7 @@ interface AppState {
48
51
export default class App extends React . Component < any , AppState > {
49
52
state : AppState = {
50
53
annotations : [ ] ,
54
+ customChildren : true ,
51
55
enzymes : [ "PstI" , "EcoRI" , "XbaI" , "SpeI" ] ,
52
56
name : "" ,
53
57
primers : true ,
@@ -67,6 +71,8 @@ export default class App extends React.Component<any, AppState> {
67
71
viewer : "" ,
68
72
zoom : 50 ,
69
73
} ;
74
+ linearRef : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
75
+ circularRef : React . RefObject < HTMLDivElement > = React . createRef ( ) ;
70
76
71
77
componentDidMount = async ( ) => {
72
78
const seq = await seqparse ( file ) ;
@@ -98,6 +104,59 @@ export default class App extends React.Component<any, AppState> {
98
104
} ;
99
105
100
106
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
+
101
160
return (
102
161
< div style = { { height : "100vh" } } >
103
162
< Sidebar . Pushable className = "sidebar-container" >
@@ -134,6 +193,13 @@ export default class App extends React.Component<any, AppState> {
134
193
< Menu . Item as = "a" className = "options-checkbox" >
135
194
< CheckboxInput label = "Show index" name = "index" set = { showIndex => this . setState ( { showIndex } ) } />
136
195
</ 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 >
137
203
< Menu . Item as = "a" >
138
204
< EnzymeInput enzymes = { this . state . enzymes } toggleEnzyme = { this . toggleEnzyme } />
139
205
</ Menu . Item >
@@ -151,9 +217,11 @@ export default class App extends React.Component<any, AppState> {
151
217
{ this . state . seq && (
152
218
< SeqViz
153
219
// accession="MN623123"
220
+ key = { `${ this . state . viewer } ${ this . state . customChildren } ` }
154
221
annotations = { this . state . annotations }
155
222
enzymes = { this . state . enzymes }
156
223
name = { this . state . name }
224
+ refs = { { circular : this . circularRef , linear : this . linearRef } }
157
225
search = { this . state . search }
158
226
selection = { this . state . selection }
159
227
seq = { this . state . seq }
@@ -163,7 +231,9 @@ export default class App extends React.Component<any, AppState> {
163
231
viewer = { this . state . viewer as "linear" | "circular" }
164
232
zoom = { { linear : this . state . zoom } }
165
233
onSelection = { selection => this . setState ( { selection } ) }
166
- />
234
+ >
235
+ { customChildren }
236
+ </ SeqViz >
167
237
) }
168
238
</ div >
169
239
</ div >
0 commit comments