forked from PrincetonUniversity/PsyNeuLinkView
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#57 code re-factoring and cleaning; add a common modals layout to be …
…used across all application modals
- Loading branch information
Salam Dalloul
committed
Jun 9, 2023
1 parent
e5e8608
commit e408bdb
Showing
4 changed files
with
135 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,55 @@ | ||
import React from "react"; | ||
import {Box, Button, IconButton, Paper, Typography} from "@mui/material"; | ||
import { Button, Typography, Stack} from "@mui/material"; | ||
import {messageTypes} from "../../../messageTypes"; | ||
import vars from "../../assets/styles/variables"; | ||
import {CloseModalIcon} from "../views/visualiseView/icons/layoutIcons"; | ||
import {CustomSelect} from "./CustomSelect"; | ||
import {ModalsLayout} from "./ModalsLayout"; | ||
|
||
const { | ||
lightBlack, | ||
listItemActiveBg | ||
} = vars; | ||
|
||
export const CondaSelectionDialog = ({state, setState, getMenuItems}) => { | ||
|
||
return <Paper | ||
id='pnl-wall' | ||
open={true} | ||
sx={{ | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: 'calc(100VW)', | ||
maxWidth: 'calc(100VW)', | ||
height: 'calc(100Vh)', | ||
border: '0px transparent', | ||
background: 'rgba(0, 0, 0, 0.5)', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<Paper | ||
elevation={4} | ||
id='pnl-wall' | ||
open={true} | ||
hideBackdrop | ||
sx={{ | ||
position: 'fixed', | ||
background: "#fff", | ||
borderRadius: '0.75rem', | ||
zIndex: 1305, | ||
width: '640px', | ||
height: '640px', | ||
}} | ||
> | ||
<IconButton | ||
return ( | ||
<ModalsLayout hasClosingIcon={true}> | ||
<Stack spacing={4}> | ||
<Typography | ||
sx={{ | ||
padding: 0, | ||
margin: '1rem' | ||
fontSize: '2.5rem', | ||
fontWeight: 600, | ||
color: lightBlack, | ||
lineHeight: 1.2 | ||
}} | ||
> | ||
<CloseModalIcon /> | ||
</IconButton> | ||
<Box | ||
height={.895} | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'inherit', | ||
justifyContent: 'space-between', | ||
padding: '80px', | ||
paddingTop: '25px' | ||
}} | ||
> | ||
<Box> | ||
<Typography | ||
sx={{ | ||
fontSize: '2.5rem', | ||
fontWeight: 600, | ||
color: lightBlack, | ||
marginBottom: '1.714rem', | ||
lineHeight: 1.2 | ||
}} | ||
> | ||
{'Select conda environment:'} | ||
</Typography> | ||
<CustomSelect state={state} setState={(val) => setState(val)} getMenuItems={getMenuItems} /> | ||
</Box> | ||
{'Select conda environment:'} | ||
</Typography> | ||
<CustomSelect state={state} setState={(val) => setState(val)} getMenuItems={getMenuItems} /> | ||
</Stack> | ||
|
||
<Button | ||
size="small" | ||
variant="contained" | ||
sx={{ | ||
width: '100%', | ||
height: '2.5rem', | ||
boxShadow: 'none', | ||
backgroundColor: listItemActiveBg, | ||
border: '2px solid rgba(0, 0, 0, 0.1)' | ||
}} | ||
onClick={() => { | ||
window.api.send("toMain", { | ||
type: messageTypes.CONDA_ENV_SELECTED, | ||
payload: state.condaEnv | ||
}); | ||
setState({ | ||
openCondaDialog: false, | ||
dependenciesFound: true, | ||
spinnerEnabled: true, | ||
}); | ||
}} | ||
> | ||
Save conda environment | ||
</Button> | ||
</Box> | ||
</Paper> | ||
</Paper> | ||
<Button | ||
size="small" | ||
variant="contained" | ||
sx={{ | ||
width: '100%', | ||
height: '2.5rem', | ||
boxShadow: 'none', | ||
backgroundColor: listItemActiveBg, | ||
border: '2px solid rgba(0, 0, 0, 0.1)' | ||
}} | ||
onClick={() => { | ||
window.api.send("toMain", { | ||
type: messageTypes.CONDA_ENV_SELECTED, | ||
payload: state.condaEnv | ||
}); | ||
setState({ | ||
openCondaDialog: false, | ||
dependenciesFound: true, | ||
spinnerEnabled: true, | ||
}); | ||
}} | ||
> | ||
Save conda environment | ||
</Button> | ||
</ModalsLayout>) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from "react"; | ||
import {Box, IconButton, Paper} from "@mui/material"; | ||
import {CloseModalIcon} from "../views/visualiseView/icons/layoutIcons"; | ||
|
||
export const ModalsLayout = ({children, hasClosingIcon = false}) => { | ||
|
||
return <Paper | ||
id='pnl-wall' | ||
open={true} | ||
sx={{ | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
width: 'calc(100VW)', | ||
maxWidth: 'calc(100VW)', | ||
height: 'calc(100Vh)', | ||
border: '0px transparent', | ||
background: 'rgba(0, 0, 0, 0.5)', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<Paper | ||
elevation={4} | ||
id='pnl-wall' | ||
open={true} | ||
hideBackdrop | ||
sx={{ | ||
position: 'fixed', | ||
background: "#fff", | ||
borderRadius: '0.75rem', | ||
zIndex: 1305, | ||
width: '640px', | ||
height: '640px', | ||
top: 60, | ||
}} | ||
> | ||
{ | ||
hasClosingIcon && <IconButton | ||
sx={{ | ||
padding: 0, | ||
margin: '1rem', | ||
position: 'absolute', | ||
top: '0', | ||
}} | ||
> | ||
<CloseModalIcon /> | ||
</IconButton> | ||
} | ||
|
||
<Box | ||
height={1} | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'space-between', | ||
textAlign: 'left', | ||
padding: '80px', | ||
}} | ||
> | ||
{children} | ||
</Box> | ||
</Paper> | ||
</Paper> | ||
} |