Skip to content

Commit

Permalink
React component style adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Stukova committed Jun 24, 2022
1 parent d376919 commit a6e137d
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 102 deletions.
66 changes: 60 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"papaparse": "^5.3.1",
"qrcode.react": "^1.0.1",
"qs": "^6.10.2",
"react-full-screen": "^1.1.1",
"react-resize-detector": "^7.1.2",
"use-debounce": "0.0.7"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/DimensionsApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';

import Dimensions from './pages/Dimensions';

const DimensionsApp = ({ parameters }) => (
<Dimensions queryString={parameters} />
const DimensionsApp = ({ parameters, fullscreenHandle }) => (
<Dimensions queryString={parameters} fullscreenHandle={fullscreenHandle} />
);

export default DimensionsApp;
4 changes: 2 additions & 2 deletions src/VOSviewerApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';

import VOSviewer from './pages/VOSviewer';

const VOSviewerApp = ({ parameters }) => (
<VOSviewer queryString={parameters} />
const VOSviewerApp = ({ parameters, fullscreenHandle }) => (
<VOSviewer queryString={parameters} fullscreenHandle={fullscreenHandle} />

);

Expand Down
4 changes: 2 additions & 2 deletions src/ZetaAlphaApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';

import ZetaAlpha from './pages/ZetaAlpha';

const ZetaAlphaApp = ({ parameters }) => (
<ZetaAlpha queryString={parameters} />
const ZetaAlphaApp = ({ parameters, fullscreenHandle }) => (
<ZetaAlpha queryString={parameters} fullscreenHandle={fullscreenHandle} />
);

export default ZetaAlphaApp;
8 changes: 7 additions & 1 deletion src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { observer } from 'mobx-react-lite';
import levenSort from 'leven-sort';
import _isUndefined from 'lodash/isUndefined';
import _isPlainObject from 'lodash/isPlainObject';
import { FullScreen, useFullScreenHandle } from "react-full-screen";

import { parameterKeys } from 'utils/variables';
import {
Expand All @@ -23,6 +24,7 @@ const VOSviewer = observer(({ parameters = {}, data }) => {
const queryStringStore = useContext(QueryStringStoreContext);
const webworkerStore = useContext(WebworkerStoreContext);
const [firstRender, setFirstRender] = useState(true);
const fullscreenHandle = useFullScreenHandle();

if (firstRender) {
setFirstRender(false);
Expand Down Expand Up @@ -200,7 +202,11 @@ const VOSviewer = observer(({ parameters = {}, data }) => {
}

return (
<App parameters={parameters} />
<div style={{ position: 'relative', width: '100%', height: '100%', overflow: 'hidden' }}>
<FullScreen handle={fullscreenHandle}>
<App parameters={parameters} fullscreenHandle={fullscreenHandle} />
</FullScreen>
</div>
);
});

Expand Down
6 changes: 5 additions & 1 deletion src/components/ui/ControlPanel/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ import { controlPanelWidth } from 'utils/variables';

export const open = css`
label: control-panel-open;
z-index: 0;
`;

export const closed = css`
label: control-panel-closed;
z-index: 0;
`;

export const controlPanel = css`
label: control-panel;
top: 0;
position: fixed;
position: absolute;
width: ${controlPanelWidth - 2}px;
height: 100%;
background-color: rgba(255, 255, 255, 0.95);
Expand Down
43 changes: 4 additions & 39 deletions src/components/ui/Fullscreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,20 @@ import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
import { ConfigStoreContext } from 'store/stores';
import * as s from './styles';

const Fullscreen = observer(() => {
const Fullscreen = observer(({ enter, exit, active }) => {
const configStore = useContext(ConfigStoreContext);

useEffect(() => {
document.addEventListener("fullscreenchange", () => {
configStore.setFullscreen(document.fullscreen);
}, false);

document.addEventListener("mozfullscreenchange", () => {
configStore.setFullscreen(document.fullscreen);
}, false);

document.addEventListener("webkitfullscreenchange", () => {
configStore.setFullscreen(document.fullscreen);
}, false);
}, []);

// https://gist.github.com/simonewebdesign/6183356

const changeFullscreen = () => {
if (configStore.fullscreen) {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
} else {
const el = document.body;
if (el.requestFullscreen) {
el.requestFullscreen();
} else if (el.msRequestFullscreen) {
el.msRequestFullscreen();
} else if (el.mozRequestFullScreen) {
el.mozRequestFullScreen();
} else if (el.webkitRequestFullscreen) {
el.webkitRequestFullscreen();
}
}
};
configStore.setFullscreen(active);
}, [active]);

return (
<>
{configStore.uiConfig.fullscreen_icon
&& (
<div
className={s.fullscreenButton}
onClick={changeFullscreen}
onClick={configStore.fullscreen ? exit : enter}
>
<Tooltip title={`${configStore.fullscreen ? 'Exit full screen' : 'Full screen'}`}>
<IconButton>
Expand Down
Loading

0 comments on commit a6e137d

Please sign in to comment.