Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 87e95b6

Browse files
committed
Adding support for overriding styles.
1 parent 3a45ea3 commit 87e95b6

15 files changed

+577
-512
lines changed

client/components/BaseApp.jsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Viewer from "./Viewer.jsx";
2525
import CustomToolTip from "./CustomToolTip.jsx";
2626
import DataPanelContainer from "./DataPanelContainer.jsx";
2727
import HyperionToolContainer from "./HyperionToolContainer.jsx";
28-
import { SpriteSize, SensorStyleDefinitions, PropIdGradientMap } from "../config/SensorStyles.js";
28+
import { SpriteSize, SensorStyleDefinitions, PropIdGradientMap, PropertyIconMap } from "../config/SensorStyles.js";
2929
import adskLogoSvg from "../../assets/images/autodesk-logo.svg";
3030
import ChronosTimeSlider from "./ChronosTimeSlider.jsx";
3131
import BasicDatePicker from "./BasicDatePicker.jsx";
@@ -815,9 +815,9 @@ export default function BaseApp(props) {
815815
}
816816

817817
/**
818-
* Uses the application based on user changes to the {@link SurfaceShader} component.
818+
* Uses the application based on user changes to the {@link HeatmapOptions} component.
819819
*
820-
* @param {Object} options Settings defined in the {@link SurfaceShader}.
820+
* @param {Object} options Settings defined in the {@link HeatmapOptions}.
821821
* @private
822822
*/
823823
function onHeatmapOptionChange(options) {
@@ -1129,7 +1129,7 @@ export default function BaseApp(props) {
11291129

11301130
return (
11311131
<React.Fragment>
1132-
<div id="main_header" style={{ display: "flex", backgroundColor: "#474747" }}>
1132+
<div id="main_header">
11331133
<ChronosTimeSlider
11341134
rangeStart={startRange.toISOString()}
11351135
rangeEnd={endRange.toISOString()}
@@ -1157,7 +1157,7 @@ export default function BaseApp(props) {
11571157
onViewerInitialized={onViewerInitialized}
11581158
onModelLoaded={onModelLoaded}
11591159
getToken={getToken}
1160-
extensions={{ "Autodesk.Viewing.ZoomWindow": {}, "Autodesk.DataVisualization": { useInternal: true } }}
1160+
extensions={{ "Autodesk.Viewing.ZoomWindow": {}, "Autodesk.DataVisualization": {} }}
11611161
geomIndex={props.geomIndex}
11621162
/>
11631163
</div>
@@ -1189,18 +1189,14 @@ export default function BaseApp(props) {
11891189
devices={props.data.devicePanelData}
11901190
onNodeSelected={onNodeSelected}
11911191
onNavigateBack={navigateBackToDevices}
1192-
propertyIconMap={props.propertyIconMap}
1192+
propertyIconMap={props.propertyIconMap ? props.propertyIconMap : PropertyIconMap}
11931193
selectedGroupNode={selectedGroupNode}
11941194
currentDeviceData={currentDeviceDataRef.current}
11951195
chartData={chartDataRef.current}
11961196
eventBus={props.eventBus}
11971197
/>
11981198
)}
1199-
<img
1200-
className="logo"
1201-
src={adskLogoSvg}
1202-
style={{ width: "9%", bottom: "22px", position: "absolute", zIndex: 2, left: "15px", opacity: 0.85 }}
1203-
></img>
1199+
<img className="logo" src={adskLogoSvg} alt="Autodesk Logo" />
12041200
</React.Fragment>
12051201
);
12061202
}

client/components/BasicTree.jsx

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import TreeView from "@material-ui/lab/TreeView";
1818
import ArrowRightIcon from "@material-ui/icons/ArrowRight";
1919
import ArrowDropDownIcon from "@material-ui/icons/ArrowDropDown";
2020
import TreeItem from "@material-ui/lab/TreeItem";
21+
import { withStyles } from "@material-ui/core/styles";
2122

2223
/**
2324
* A basic tree structure component.
@@ -32,23 +33,20 @@ import TreeItem from "@material-ui/lab/TreeItem";
3233
* @param {OnMouseEvent} props.onLabelClick Function to be invoked when a label is clicked
3334
* @param {OnMouseEvent} props.onMouseOver Function to be invoked on the mouseover of a {@link TreeNode}
3435
* @param {OnMouseEvent} props.onMouseOut Function to be invoked when the mouse hovers off a {@link TreeNode}.
35-
* @param {Object} props.classes Material UI Styles object applied to a {@link TreeNode}. See {@link https://material-ui.com/api/tree-item/#css} for structure.
36-
* @param {Object} [props.classes.root]
37-
* @param {Object} [props.classes.selected]
38-
* @param {Object} [props.classes.group]
39-
* @param {Object} [props.classes.categoryContent] Content styles applied applied to a {@link TreeNode} with children.
40-
* @param {Object} [props.classes.itemContent] Content styles applied to a {@link TreeNode} without children.
41-
* @param {Object} [props.classes.categoryLabel] Label styles applied to a {@link TreeNode} with children.
42-
* @param {Object} [props.classes.itemLabel] Label styles applied to a {@link TreeNode} without children.
43-
* @param {Object} [props.classes.iconContainer]
36+
* @param {Object} [props.styles]
37+
* @param {Object} [props.styles.treeNode] Material UI styles to apply to {@link TreeNode} with children. See https://material-ui.com/api/tree-item/#css
38+
* @param {Object} [props.styles.leafNode] Material UI styles to apply to {@link TreeNode} without children. See https://material-ui.com/api/tree-item/#css
4439
*
4540
* @memberof Autodesk.DataVisualization.UI
4641
* @alias Autodesk.DataVisualization.UI.BasicTree
4742
*/
4843
export default function BasicTree(props) {
44+
const TreeNodeItem = withStyles(() => (props.styles ? props.styles.treeNode : {}))(TreeItem);
45+
const LeafNodeItem = withStyles(() => (props.styles ? props.styles.leafNode : {}))(TreeItem);
46+
4947
/**
5048
* Calls the corresponding handler with data if found.
51-
*
49+
*
5250
* @param {string} handlerName Name of event handler.
5351
* @param {TreeNode} data Node that triggered event.
5452
* @private
@@ -61,8 +59,6 @@ export default function BasicTree(props) {
6159
};
6260
}
6361

64-
const classes = props.classes;
65-
6662
/**
6763
*
6864
* @param {Object} node Represents a node in props.data
@@ -79,10 +75,10 @@ export default function BasicTree(props) {
7975

8076
/**
8177
* Finds a path from the root of the tree to the target {@link TreeNode}.
82-
*
78+
*
8379
* @param {TreeNode[]} tree Tree of device {@link TreeNode} in the scene.
8480
* @param {string} goal Id of {@link TreeNode}
85-
* @returns {string[]} An array of node identifiers representing the path from root to goal. Returns [] if a path to the
81+
* @returns {string[]} An array of node identifiers representing the path from root to goal. Returns [] if a path to the
8682
* &nbsp;{@link TreeNode} cannot be found.
8783
* @private
8884
*/
@@ -112,30 +108,35 @@ export default function BasicTree(props) {
112108
* @param {TreeNode} node Represents a node in props.data
113109
* @private
114110
*/
115-
const renderTree = (node) => (
116-
<TreeItem
117-
classes={{
118-
root: classes.root,
119-
selected: classes.selected,
120-
group: classes.group,
121-
content: node.children.length > 0 ? classes.categoryContent : classes.itemContent,
122-
label: node.children.length > 0 ? classes.categoryLabel : classes.itemLabel,
123-
iconContainer: classes.iconContainer,
124-
}}
125-
key={node.id}
126-
nodeId={node.id.toString()}
127-
onMouseOver={onEvent("onMouseOver", node)}
128-
onMouseOut={onEvent("onMouseOut", node)}
129-
onLabelClick={onEvent("onLabelClick", node)}
130-
onIconClick={onEvent("onIconClick", node)}
131-
label={props.onLabelRequest(node)}
132-
>
133-
{
134-
// Render only child nodes of the expanded node.
135-
getChildNodes(node).map((child) => renderTree(child))
136-
}
137-
</TreeItem>
138-
);
111+
const renderTree = (node) => {
112+
if (node.children.length > 0) {
113+
return (
114+
<TreeNodeItem
115+
key={node.id}
116+
nodeId={node.id.toString()}
117+
onMouseOver={onEvent("onMouseOver", node)}
118+
onMouseOut={onEvent("onMouseOut", node)}
119+
onLabelClick={onEvent("onLabelClick", node)}
120+
onIconClick={onEvent("onIconClick", node)}
121+
label={props.onLabelRequest(node)}
122+
>
123+
{getChildNodes(node).map((child) => renderTree(child))}
124+
</TreeNodeItem>
125+
);
126+
} else {
127+
return (
128+
<LeafNodeItem
129+
key={node.id}
130+
nodeId={node.id.toString()}
131+
onMouseOver={onEvent("onMouseOver", node)}
132+
onMouseOut={onEvent("onMouseOut", node)}
133+
onLabelClick={onEvent("onLabelClick", node)}
134+
onIconClick={onEvent("onIconClick", node)}
135+
label={props.onLabelRequest(node)}
136+
/>
137+
);
138+
}
139+
};
139140

140141
return (
141142
<TreeView
@@ -148,4 +149,3 @@ export default function BasicTree(props) {
148149
</TreeView>
149150
);
150151
}
151-

client/components/ChronosTimeSlider.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { TimeSlider } from "chronos-etu";
3131
* @param {HandleCurrTimeUpdated} props.onCurrTimeUpdated A callback
3232
* &nbsp;handler invoked when the current time marker is updated without
3333
* &nbsp;changing the time selection.
34+
* @param {Object} [props.styles] Styles to apply to TimeSlider container.
3435
*
3536
* @memberof Autodesk.DataVisualization.UI
3637
* @alias Autodesk.DataVisualization.UI.ChronosTimeSlider
@@ -42,11 +43,10 @@ function ChronosTimeSlider(props) {
4243
const [timeSelectionId, setTimeselectionId] = useState(null);
4344
const containerRef = useRef();
4445

45-
const cntrStyle = {
46+
const cntrStyle = Object.assign({}, {
4647
height: "120px",
47-
backgroundColor: "gray",
4848
width: "75%",
49-
};
49+
}, props.styles);
5050

5151
/**
5252
* Creates a timeline selection for the provided Date range.

client/components/CustomToolTip.jsx

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,12 @@
1515
//
1616
import React from "react";
1717
import Tooltip from "@material-ui/core/Tooltip";
18-
import CircularProgress from '@material-ui/core/CircularProgress';
18+
import CircularProgress from "@material-ui/core/CircularProgress";
1919
import DataChart from "../components/DataChart.jsx";
20-
import { withStyles, makeStyles } from "@material-ui/core/styles";
20+
import { makeStyles } from "@material-ui/core/styles";
21+
import * as _ from "lodash";
2122
// eslint-disable-next-line no-unused-vars
2223

23-
const HtmlTooltip = withStyles(() => ({
24-
tooltip: {
25-
backgroundColor: "#373737",
26-
fontSize: "12px",
27-
padding: "0px",
28-
paddingTop: "2px",
29-
paddingBottom: "3px",
30-
margin: "0px",
31-
},
32-
arrow: {
33-
color: "#373737",
34-
marginBottom: "0px",
35-
fontSize: "20px",
36-
},
37-
}))(Tooltip);
38-
39-
const loadingIconStyles = makeStyles({
40-
loadingIcon: {
41-
display: "block",
42-
margin: "auto",
43-
padding: "5px"
44-
}
45-
});
46-
4724
/**
4825
* A custom tool-tip that is displayed over Forge Viewer canvas when a user hovers over a device. Contains a {@link DataChart} for each property along with the estimated current property value.
4926
* @component
@@ -54,46 +31,50 @@ const loadingIconStyles = makeStyles({
5431
* @param {ChartData} props.chartData Data used to generate charts for each property associated with props.hoveredDeviceInfo
5532
* @param {CurrentDeviceData} props.currentDeviceData Data containing the estimated propertyValue for each property
5633
* &nbsp;associated with props.hoveredDeviceInfo
34+
* @param {Object} props.styles Material UI styles to apply to the Tooltip component. See https://material-ui.com/api/tooltip/#css
5735
*
5836
* @memberof Autodesk.DataVisualization.UI
5937
* @alias Autodesk.DataVisualization.UI.CustomToolTip
6038
*/
6139
function CustomToolTip(props) {
62-
const classes = loadingIconStyles();
63-
6440
if (props.hoveredDeviceInfo.id) {
6541
const chartData = props.chartData[props.hoveredDeviceInfo.id];
66-
const deviceName = chartData ? chartData.name : <CircularProgress color="secondary" size={30} classes={{ root: classes.loadingIcon }} />;
42+
const deviceName = chartData ? chartData.name : <CircularProgress className="tooltip-loading-icon" color="secondary" size={30} />;
6743
const properties = chartData ? Object.keys(chartData["properties"]) : [];
6844

6945
const currentDeviceData = props.currentDeviceData[props.hoveredDeviceInfo.id];
7046

47+
const useStyles = makeStyles(
48+
_.merge(
49+
{
50+
tooltip: {
51+
backgroundColor: "#373737",
52+
fontSize: "12px",
53+
padding: "0px",
54+
paddingTop: "2px",
55+
paddingBottom: "3px",
56+
margin: "0px",
57+
},
58+
arrow: {
59+
color: "#373737",
60+
marginBottom: "0px",
61+
fontSize: "20px",
62+
},
63+
},
64+
props.styles
65+
)
66+
);
67+
68+
const classes = useStyles();
69+
7170
return (
72-
<HtmlTooltip
71+
<Tooltip
7372
title={
7473
<React.Fragment>
75-
<span
76-
style={{
77-
display: "flex",
78-
justifyContent: "center",
79-
fontWeight: "bold",
80-
fontSize: "12px",
81-
paddingTop: "1px",
82-
paddingBottom: "3px",
83-
}}
84-
>
85-
{deviceName}
86-
</span>
87-
74+
<span className="tooltip-device-name">{deviceName}</span>
8875
{properties.map((property) => (
8976
<React.Fragment key={`${props.hoveredDeviceInfo.id}-${property}`}>
90-
<span
91-
style={{
92-
fontSize: "13px",
93-
display: "flex",
94-
justifyContent: "center",
95-
}}
96-
>
77+
<span className="tooltip-property-val">
9778
{currentDeviceData ? currentDeviceData[property] : ""}
9879
</span>
9980
<DataChart
@@ -110,17 +91,16 @@ function CustomToolTip(props) {
11091
arrow={true}
11192
placement="top"
11293
open={Boolean(props.hoveredDeviceInfo.id)}
94+
classes={classes}
11395
>
11496
<span
115-
id="tooltip"
97+
className="tooltip"
11698
style={{
117-
position: "absolute",
11899
left: `${props.hoveredDeviceInfo.xcoord}px`,
119100
top: `${props.hoveredDeviceInfo.ycoord - 2}px`,
120-
zIndex: 2,
121101
}}
122102
></span>
123-
</HtmlTooltip>
103+
</Tooltip>
124104
);
125105
}
126106

0 commit comments

Comments
 (0)