From 31015460b4d7aca3beda89a6e3d17cd2798b14e3 Mon Sep 17 00:00:00 2001 From: Tibor Postek Date: Mon, 24 Feb 2020 13:05:46 +0100 Subject: [PATCH] #92 remove grid breakpoint of preview component, move breakpoints to css --- js/components/nglView/nglView.js | 21 ++++++++++- js/components/preview/Preview.js | 63 ++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 18 deletions(-) diff --git a/js/components/nglView/nglView.js b/js/components/nglView/nglView.js index 4eec5cf7d..b3129f76c 100644 --- a/js/components/nglView/nglView.js +++ b/js/components/nglView/nglView.js @@ -12,11 +12,28 @@ import { NglContext } from './nglProvider'; import { handleNglViewPick } from './redux/dispatchActions'; import { throttle } from 'lodash'; import { BACKGROUND_COLOR, NGL_PARAMS } from './constants'; +import { makeStyles, useTheme } from '@material-ui/core'; +import { VIEWS } from '../../constants/constants'; + +const useStyles = makeStyles(theme => ({ + paper: { + backgroundColor: theme.palette.background.paper, + borderRadius: theme.spacing(1) / 2, + boxShadow: [ + '0px 2px 1px -1px rgba(0,0,0,0.2)', + '0px 1px 1px 0px rgba(0,0,0,0.14)', + '0px 1px 3px 0px rgba(0,0,0,0.12)' + ], + marginBottom: theme.spacing(1) + } +})); const NglView = memo(({ div_id, height, setOrientation, removeAllNglComponents, handleNglViewPick }) => { // connect to NGL Stage object const { registerNglView, unregisterNglView, getNglView } = useContext(NglContext); const [stage, setStage] = useState(); + const classes = useStyles(); + const theme = useTheme(); const handleOrientationChanged = useCallback( throttle(() => { @@ -104,9 +121,9 @@ const NglView = memo(({ div_id, height, setOrientation, removeAllNglComponents, return (
); diff --git a/js/components/preview/Preview.js b/js/components/preview/Preview.js index 34231e78b..c933b682e 100644 --- a/js/components/preview/Preview.js +++ b/js/components/preview/Preview.js @@ -2,7 +2,7 @@ * Created by abradley on 14/04/2018. */ -import React, { Fragment, memo, useEffect, useRef, useState } from 'react'; +import React, { memo, useEffect, useRef, useState } from 'react'; import { Grid, makeStyles, useTheme } from '@material-ui/core'; import NGLView from '../nglView/nglView'; import MoleculeList from './molecule/moleculeList'; @@ -20,6 +20,8 @@ import { useDispatch } from 'react-redux'; import { removeAllNglComponents } from '../../reducers/ngl/actions'; //import HotspotList from '../hotspot/hotspotList'; +const hitNavigatorWidth = 504; + const useStyles = makeStyles(theme => ({ root: { minHeight: 'inherit' @@ -28,18 +30,30 @@ const useStyles = makeStyles(theme => ({ width: 'inherit' }, nglViewWidth: { - width: 'inherit' + padding: 0, + width: 'inherit' //`calc(inherit - ${theme.spacing(1)}px` }, hitColumn: { - [theme.breakpoints.between('lg', 'xl')]: { - maxWidth: 504, - marginRight: theme.spacing(1) / 4 + minWidth: hitNavigatorWidth, + [theme.breakpoints.up('md')]: { + width: hitNavigatorWidth + }, + [theme.breakpoints.only('sm')]: { + width: '100%' + } + }, + nglColumn: { + [theme.breakpoints.up('lg')]: { + width: `calc(100vw - ${2 * hitNavigatorWidth}px - ${theme.spacing(2)}px)` + }, + [theme.breakpoints.only('md')]: { + width: `calc(100vw - ${hitNavigatorWidth}px - ${theme.spacing(4)}px)` } }, summaryColumn: { - [theme.breakpoints.between('lg', 'xl')]: { - maxWidth: 504, - minWidth: 400 + minWidth: hitNavigatorWidth, + [theme.breakpoints.up('lg')]: { + width: hitNavigatorWidth } } })); @@ -47,6 +61,7 @@ const useStyles = makeStyles(theme => ({ const Preview = memo(({ isStateLoaded, headerHeight }) => { const classes = useStyles(); const theme = useTheme(); + const nglViewerControlsRef = useRef(null); const dispatch = useDispatch(); @@ -73,9 +88,15 @@ const Preview = memo(({ isStateLoaded, headerHeight }) => { }, [dispatch]); return ( - + <> - + {/* Hit cluster selector */} @@ -89,12 +110,16 @@ const Preview = memo(({ isStateLoaded, headerHeight }) => { /> - - - + + + - + { - + @@ -118,7 +149,7 @@ const Preview = memo(({ isStateLoaded, headerHeight }) => { */} - + ); });