Skip to content

Commit 78fd7e9

Browse files
committed
Updating props and rebuilding
1 parent 184610d commit 78fd7e9

File tree

11 files changed

+88
-54
lines changed

11 files changed

+88
-54
lines changed

R/dashbioNglMoleculeViewer.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# AUTO GENERATED FILE - DO NOT EDIT
22

3-
dashbioNglMoleculeViewer <- function(id=NULL, viewportStyle=NULL, stageParameters=NULL, imageParameters=NULL, downloadImage=NULL, pdbString=NULL, data=NULL, molStyles=NULL) {
3+
dashbioNglMoleculeViewer <- function(id=NULL, viewportWidth=NULL, viewportHeight=NULL, stageParameters=NULL, imageParameters=NULL, downloadImage=NULL, pdbString=NULL, data=NULL, molStyles=NULL) {
44

5-
props <- list(id=id, viewportStyle=viewportStyle, stageParameters=stageParameters, imageParameters=imageParameters, downloadImage=downloadImage, pdbString=pdbString, data=data, molStyles=molStyles)
5+
props <- list(id=id, viewportWidth=viewportWidth, viewportHeight=viewportHeight, stageParameters=stageParameters, imageParameters=imageParameters, downloadImage=downloadImage, pdbString=pdbString, data=data, molStyles=molStyles)
66
if (length(props) > 0) {
77
props <- props[!vapply(props, is.null, logical(1))]
88
}
99
component <- list(
1010
props = props,
1111
type = 'NglMoleculeViewer',
1212
namespace = 'dash_bio',
13-
propNames = c('id', 'viewportStyle', 'stageParameters', 'imageParameters', 'downloadImage', 'pdbString', 'data', 'molStyles'),
13+
propNames = c('id', 'viewportWidth', 'viewportHeight', 'stageParameters', 'imageParameters', 'downloadImage', 'pdbString', 'data', 'molStyles'),
1414
package = 'dashBio'
1515
)
1616

dash_bio/NglMoleculeViewer.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,10 @@ class NglMoleculeViewer(Component):
1515
Keyword arguments:
1616
- id (string; optional): The ID of this component, used to identify dash components in callbacks.
1717
The ID needs to be unique across all of the components in an app.
18-
- viewportStyle (dict; default {
19-
width: '500px',
20-
height: '500px',
21-
}): The height and the width (in px) of the container
18+
- viewportWidth (string | number; default '500px'): The width (in px or as a number) of the container
19+
in which the molecules will be displayed.
20+
- viewportHeight (string | number; default '500px'): The height (in px or as a number) of the container
2221
in which the molecules will be displayed.
23-
It should be in JSON format. viewportStyle has the following type: dict containing keys 'width', 'height'.
24-
Those keys have the following types:
25-
- width (string; optional)
26-
- height (string; optional)
2722
- stageParameters (dict; default {
2823
quality: 'medium',
2924
backgroundColor: 'white',
@@ -130,12 +125,12 @@ class NglMoleculeViewer(Component):
130125
- molSpacingXaxis (number; required)
131126
- sideByside (boolean; required)"""
132127
@_explicitize_args
133-
def __init__(self, id=Component.UNDEFINED, viewportStyle=Component.UNDEFINED, stageParameters=Component.UNDEFINED, imageParameters=Component.UNDEFINED, downloadImage=Component.UNDEFINED, pdbString=Component.UNDEFINED, data=Component.UNDEFINED, molStyles=Component.UNDEFINED, **kwargs):
134-
self._prop_names = ['id', 'viewportStyle', 'stageParameters', 'imageParameters', 'downloadImage', 'pdbString', 'data', 'molStyles']
128+
def __init__(self, id=Component.UNDEFINED, viewportWidth=Component.UNDEFINED, viewportHeight=Component.UNDEFINED, stageParameters=Component.UNDEFINED, imageParameters=Component.UNDEFINED, downloadImage=Component.UNDEFINED, pdbString=Component.UNDEFINED, data=Component.UNDEFINED, molStyles=Component.UNDEFINED, **kwargs):
129+
self._prop_names = ['id', 'viewportWidth', 'viewportHeight', 'stageParameters', 'imageParameters', 'downloadImage', 'pdbString', 'data', 'molStyles']
135130
self._type = 'NglMoleculeViewer'
136131
self._namespace = 'dash_bio'
137132
self._valid_wildcard_attributes = []
138-
self.available_properties = ['id', 'viewportStyle', 'stageParameters', 'imageParameters', 'downloadImage', 'pdbString', 'data', 'molStyles']
133+
self.available_properties = ['id', 'viewportWidth', 'viewportHeight', 'stageParameters', 'imageParameters', 'downloadImage', 'pdbString', 'data', 'molStyles']
139134
self.available_wildcard_properties = []
140135

141136
_explicit_args = kwargs.pop('_explicit_args')

dash_bio/async-nglmoleculeviewer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_bio/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_bio/metadata.json

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,24 +1841,48 @@
18411841
"required": false,
18421842
"description": "The ID of this component, used to identify dash components in callbacks.\nThe ID needs to be unique across all of the components in an app."
18431843
},
1844-
"viewportStyle": {
1844+
"setProps": {
18451845
"type": {
1846-
"name": "exact",
1847-
"value": {
1848-
"width": {
1849-
"name": "string",
1850-
"required": false
1846+
"name": "func"
1847+
},
1848+
"required": false,
1849+
"description": "Dash-assigned callback that should be called whenever properties change."
1850+
},
1851+
"viewportWidth": {
1852+
"type": {
1853+
"name": "union",
1854+
"value": [
1855+
{
1856+
"name": "string"
18511857
},
1852-
"height": {
1853-
"name": "string",
1854-
"required": false
1858+
{
1859+
"name": "number"
18551860
}
1856-
}
1861+
]
1862+
},
1863+
"required": false,
1864+
"description": "The width (in px or as a number) of the container\nin which the molecules will be displayed.",
1865+
"defaultValue": {
1866+
"value": "'500px'",
1867+
"computed": false
1868+
}
1869+
},
1870+
"viewportHeight": {
1871+
"type": {
1872+
"name": "union",
1873+
"value": [
1874+
{
1875+
"name": "string"
1876+
},
1877+
{
1878+
"name": "number"
1879+
}
1880+
]
18571881
},
18581882
"required": false,
1859-
"description": "The height and the width (in px) of the container\nin which the molecules will be displayed.\nIt should be in JSON format.",
1883+
"description": "The height (in px or as a number) of the container\nin which the molecules will be displayed.",
18601884
"defaultValue": {
1861-
"value": "{\n width: '500px',\n height: '500px',\n}",
1885+
"value": "'500px'",
18621886
"computed": false
18631887
}
18641888
},
@@ -2636,4 +2660,4 @@
26362660
}
26372661
}
26382662
}
2639-
}
2663+
}

inst/deps/async-nglmoleculeviewer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/deps/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dashbioNglMoleculeViewer.Rd

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ The NglMoleculeViewer is used to render schematic diagrams of biomolecules in ri
1010
}
1111

1212
\usage{
13-
dashbioNglMoleculeViewer(id=NULL, viewportStyle=NULL, stageParameters=NULL,
14-
imageParameters=NULL, downloadImage=NULL, pdbString=NULL,
15-
data=NULL, molStyles=NULL)
13+
dashbioNglMoleculeViewer(id=NULL, viewportWidth=NULL, viewportHeight=NULL,
14+
stageParameters=NULL, imageParameters=NULL,
15+
downloadImage=NULL, pdbString=NULL, data=NULL,
16+
molStyles=NULL)
1617
}
1718

1819
\arguments{
1920
\item{id}{Character. The ID of this component, used to identify dash components in callbacks.
2021
The ID needs to be unique across all of the components in an app.}
2122

22-
\item{viewportStyle}{Lists containing elements 'width', 'height'.
23-
those elements have the following types:
24-
- width (character; optional)
25-
- height (character; optional). The height and the width (in px) of the container
26-
in which the molecules will be displayed.
27-
It should be in JSON format.}
23+
\item{viewportWidth}{Character | numeric. The width (in px or as a number) of the container
24+
in which the molecules will be displayed.}
25+
26+
\item{viewportHeight}{Character | numeric. The height (in px or as a number) of the container
27+
in which the molecules will be displayed.}
2828

2929
\item{stageParameters}{Lists containing elements 'quality', 'backgroundcolor', 'cameratype'.
3030
those elements have the following types:

src/lib/components/NglMoleculeViewer.react.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ export default class NglMoleculeViewer extends Component {
2121
}
2222
}
2323

24-
const defaultViewportStyle = {
25-
width: '500px',
26-
height: '500px',
27-
};
24+
const defaultViewportHeight = '500px';
25+
26+
const defaultViewportWidth = '500px';
2827

2928
const defaultStageParameters = {
3029
quality: 'medium',
@@ -62,7 +61,8 @@ const defaultData = [
6261

6362
NglMoleculeViewer.defaultProps = {
6463
data: defaultData,
65-
viewportStyle: defaultViewportStyle,
64+
viewportWidth: defaultViewportWidth,
65+
viewportHeight: defaultViewportHeight,
6666
stageParameters: defaultStageParameters,
6767
imageParameters: defaultImageParameters,
6868
downloadImage: false,
@@ -83,14 +83,21 @@ NglMoleculeViewer.propTypes = {
8383
id: PropTypes.string,
8484

8585
/**
86-
* The height and the width (in px) of the container
86+
* Dash-assigned callback that should be called whenever properties change.
87+
*/
88+
setProps: PropTypes.func,
89+
90+
/**
91+
* The width (in px or as a number) of the container
8792
* in which the molecules will be displayed.
88-
* It should be in JSON format.
8993
*/
90-
viewportStyle: PropTypes.exact({
91-
width: PropTypes.string,
92-
height: PropTypes.string,
93-
}),
94+
viewportWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
95+
96+
/**
97+
* The height (in px or as a number) of the container
98+
* in which the molecules will be displayed.
99+
*/
100+
viewportHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
94101

95102
/**
96103
* Parameters (in JSON format) for the stage object of ngl.

src/lib/fragments/NglMoleculeViewer.react.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, {Component} from 'react';
22
import {propTypes, defaultProps} from '../components/NglMoleculeViewer.react';
33
import {Stage, Selection, download} from 'ngl';
44
import {equals} from 'ramda';
5+
// import {isNumeric} from 'fast-isnumeric';
56

67
/**
78
* The NglMoleculeViewer is used to render schematic diagrams
@@ -22,12 +23,19 @@ export default class NglMoleculeViewer extends Component {
2223
}
2324

2425
componentDidMount() {
25-
const {id, stageParameters, viewportStyle} = this.props;
26+
const {id, stageParameters, viewportWidth, viewportHeight} = this.props;
2627
const params = {...stageParameters};
2728
const stage = new Stage(id, params);
2829
const orientationMatrix = stage.viewerControls.getOrientation();
2930

30-
stage.setSize(viewportStyle.width, viewportStyle.height);
31+
const widthStr = isNaN(viewportWidth)
32+
? viewportWidth
33+
: viewportWidth + 'px';
34+
const heightStr = isNaN(viewportHeight)
35+
? viewportHeight
36+
: viewportHeight + 'px';
37+
38+
stage.setSize(widthStr, heightStr);
3139
this.setState({stage, orientationMatrix});
3240
}
3341

0 commit comments

Comments
 (0)