@@ -10,9 +10,8 @@ import { RiImage2Line, RiFileCodeLine, RiFileCopy2Line } from "react-icons/ri";
10
10
import { BsToggles } from "react-icons/bs" ;
11
11
import { FaEdit , FaRegEdit } from "react-icons/fa" ;
12
12
13
- const miniatureProps = { position : TOOL_NONE }
14
- const toolbarProps = { position : POSITION_LEFT , SVGAlignY : ALIGN_CENTER , SVGAlignX : ALIGN_CENTER }
15
-
13
+ const miniatureProps = { position : TOOL_NONE } ;
14
+ const toolbarProps = { position : POSITION_LEFT , SVGAlignY : ALIGN_CENTER , SVGAlignX : ALIGN_CENTER } ;
16
15
17
16
class Results extends React . Component {
18
17
constructor ( props ) {
@@ -27,8 +26,8 @@ class Results extends React.Component {
27
26
window . addEventListener ( "resize" , ( ) => this . handleResize ( ) ) ;
28
27
}
29
28
30
- componentWillUnMount ( ) {
31
- window . addEventListener ( "resize" , ( ) => this . handleResize ( ) ) ;
29
+ componentWillUnmount ( ) {
30
+ window . removeEventListener ( "resize" , ( ) => this . handleResize ( ) ) ;
32
31
}
33
32
34
33
componentDidUpdate ( ) {
@@ -91,9 +90,41 @@ class Results extends React.Component {
91
90
} ;
92
91
const fixCss = this . props . customStyle && this . props . customStyle . fixCss && this . props . customStyle . fixCss === "true" ? "1.5rem" : "" ;
93
92
const linkColor = this . props . customStyle && this . props . customStyle . linkColor ? this . props . customStyle . linkColor : "#337ab7" ;
93
+ const legendLocation = this . props . customStyle && this . props . customStyle . legendLocation && this . props . customStyle . legendLocation === "right" ? "right" : "" ;
94
94
const width = document . getElementsByTagName ( 'r2dt-web' ) [ 0 ] && document . getElementsByTagName ( 'r2dt-web' ) [ 0 ] . offsetWidth ? document . getElementsByTagName ( 'r2dt-web' ) [ 0 ] . offsetWidth - 40 : 1100 ; // using - 40 to display the right side border
95
95
const height = parseFloat ( this . props . height ) > 600 ? parseFloat ( this . props . height ) : 600 ;
96
96
97
+ const renderLegend = ( ) => (
98
+ < div className = "mt-3" style = { { fontSize : fixCss } } >
99
+ < strong > Colour legend</ strong >
100
+ < ul className = "list-unstyled" >
101
+ < li className = "mt-1" > < span className = "traveler-black traveler-key" > </ span > Same as the template</ li >
102
+ < li className = "mt-1" > < span className = "traveler-green traveler-key" > </ span > Modified compared to the template</ li >
103
+ < li className = "mt-1" > < span className = "traveler-magenta traveler-key" > </ span > Inserted nucleotides</ li >
104
+ < li className = "mt-1" > < span className = "traveler-blue traveler-key" > </ span > Repositioned compared to the template</ li >
105
+ < li className = "mt-2" > < strong > Tip:</ strong > Hover over nucleotides for more details</ li >
106
+ </ ul >
107
+ </ div >
108
+ ) ;
109
+
110
+ const renderSVGComponent = ( ) => (
111
+ < UncontrolledReactSVGPanZoom
112
+ width = { legendLocation === "right" ? width * 0.7 : width } // 70% of the total width if legend is on the right
113
+ height = { height }
114
+ ref = { this . viewerRef }
115
+ toolbarProps = { toolbarProps }
116
+ miniatureProps = { miniatureProps }
117
+ detectAutoPan = { false }
118
+ background = { "#fff" }
119
+ scaleFactorMin = { 0.5 }
120
+ scaleFactorMax = { 5 }
121
+ >
122
+ < svg width = { parseFloat ( this . props . width ) } height = { parseFloat ( this . props . height ) } >
123
+ < SvgLoader svgXML = { this . props . svg } />
124
+ </ svg >
125
+ </ UncontrolledReactSVGPanZoom >
126
+ ) ;
127
+
97
128
return (
98
129
< div className = "rna" ref = { this . divRef } >
99
130
{
@@ -145,49 +176,36 @@ class Results extends React.Component {
145
176
</ >
146
177
}
147
178
</ div >
148
- < div className = "border border-secondary" >
149
- < UncontrolledReactSVGPanZoom
150
- width = { width }
151
- height = { height }
152
- ref = { this . viewerRef }
153
- toolbarProps = { toolbarProps }
154
- miniatureProps = { miniatureProps }
155
- detectAutoPan = { false }
156
- background = { "#fff" }
157
- scaleFactorMin = { 0.5 }
158
- scaleFactorMax = { 5 }
159
- >
160
- < svg width = { parseFloat ( this . props . width ) } height = { parseFloat ( this . props . height ) } >
161
- < SvgLoader svgXML = { this . props . svg } />
162
- </ svg >
163
- </ UncontrolledReactSVGPanZoom >
164
- </ div >
165
- < div className = "mt-3" style = { { fontSize : fixCss } } >
166
- < strong > Colour legend</ strong >
167
- < ul className = "list-unstyled" >
168
- < li className = "mt-1" > < span className = "traveler-black traveler-key" > </ span > Same as the template</ li >
169
- < li className = "mt-1" >
170
- < span className = "traveler-green traveler-key" > </ span > Modified compared to the template.
171
- < strong > Tip:</ strong > Hover over green nucleotides for more details
172
- </ li >
173
- < li className = "mt-1" > < span className = "traveler-magenta traveler-key" > </ span > Inserted nucleotides</ li >
174
- < li className = "mt-1" > < span className = "traveler-blue traveler-key" > </ span > Repositioned compared to the template</ li >
175
- < li className = "mt-1" > < strong > Tip:</ strong > Hover over the nucleotides to see nucleotide numbers</ li >
176
- </ ul >
177
- </ div >
179
+ {
180
+ legendLocation === "right" ? (
181
+ < div style = { { display : 'flex' , justifyContent : 'space-between' } } >
182
+ < div style = { { flex : '1 1 70%' } } className = "border border-secondary" >
183
+ { renderSVGComponent ( ) }
184
+ </ div >
185
+ < div style = { { flex : '1 1 30%' , marginLeft : '1rem' } } >
186
+ { renderLegend ( ) }
187
+ </ div >
188
+ </ div >
189
+ ) : (
190
+ < div className = "border border-secondary" >
191
+ { renderSVGComponent ( ) }
192
+ </ div >
193
+ )
194
+ }
195
+ { legendLocation !== "right" && renderLegend ( ) }
178
196
</ div >
179
197
</ div >
180
198
]
181
199
}
182
200
{
183
201
this . props . jobId && this . props . svg !== "SVG not available" && this . props . status === "FINISHED" && this . props . notation && [
184
202
< div className = "row" key = { `notation-div` } >
185
- < div className = " col-12" >
186
- < p className = "notation-title" > Dot-bracket notation</ p >
203
+ < div className = { ` col-12 ${ legendLocation === "right" ? 'mt-3' : '' } ` } >
204
+ < span > < strong > Dot-bracket notation</ strong > </ span >
187
205
{
188
206
this . props . notation === "error" ? < div className = "alert alert-danger" >
189
207
There was an error loading the dot-bracket notation. Let us know if the problem persists by raising an issue on < a href = "https://github.com/RNAcentral/r2dt-web/issues" target = "_blank" > GitHub</ a > .
190
- </ div > : < pre className = "notation" >
208
+ </ div > : < pre className = "mt-1 notation" >
191
209
< span className = "notation-font" > { this . props . notation } </ span >
192
210
</ pre >
193
211
}
0 commit comments