diff --git a/components/categorical-variable-options.tsx b/components/categorical-variable-options.tsx index 10df38ab..af894aa5 100644 --- a/components/categorical-variable-options.tsx +++ b/components/categorical-variable-options.tsx @@ -1,4 +1,5 @@ -import { Button, TextField } from '@material-ui/core'; +import { Button, Grid, IconButton, TextField } from '@material-ui/core'; +import AddIcon from "@material-ui/icons/Add"; import { ChangeEvent, useState } from 'react'; type CategoricalVariableOptionProps = { @@ -18,17 +19,22 @@ export default function CategoricalVariableOptions(props: CategoricalVariableOpt } return ( - <> - updateOption((e.target as HTMLInputElement).value)} - /> -
- -
- + + + updateOption((e.target as HTMLInputElement).value)} + /> + + + onOptionAdded()}> + + + + ) } diff --git a/components/categorical-variable.tsx b/components/categorical-variable.tsx index dcf0cb78..d438a54c 100644 --- a/components/categorical-variable.tsx +++ b/components/categorical-variable.tsx @@ -32,6 +32,7 @@ export default function CategoricalVariable(props: CategoricalVariableProps) { <>

(
- {option} + {option} deleteOption(index)} size="small" aria-label="delete" color="primary"> diff --git a/components/data-points.tsx b/components/data-points.tsx index 82fa89a3..1d6f2114 100644 --- a/components/data-points.tsx +++ b/components/data-points.tsx @@ -77,7 +77,7 @@ export default function DataPoints(props: DataPointProps) { {variableNames.map((name, index) => - onNewPointChange(name, index, (e.target as HTMLInputElement).value)} /> + onNewPointChange(name, index, (e.target as HTMLInputElement).value)} /> )} diff --git a/components/layout.tsx b/components/layout.tsx index b5df1dd1..e9a8e408 100644 --- a/components/layout.tsx +++ b/components/layout.tsx @@ -1,16 +1,33 @@ +import { AppBar, Button, Toolbar, Typography } from '@material-ui/core' import Link from 'next/link' +import useStyles from '../styles/layout.style' +import Image from 'next/image' + +export default function Layout ( {children} ) { + const classes = useStyles() -export default function Layout ( {children}) { return ( -
- - Home - - | - - Experiment - - {children} -
+ <> + + +
+ logo +
+ + BrownieBee + +
+ + + +
+
+
+
+ {children} +
+ ) } \ No newline at end of file diff --git a/components/model-editor.tsx b/components/model-editor.tsx index 17240edc..bfaac691 100644 --- a/components/model-editor.tsx +++ b/components/model-editor.tsx @@ -1,26 +1,22 @@ -import { Card, CardContent, Grid, Radio, TextField, Typography } from '@material-ui/core' -import { ChangeEvent, useState } from 'react'; -import { CategoricalVariableType, Info, ValueVariableType } from '../types/common'; -import CategoricalVariable from './categorical-variable'; -import ValueVariable from './value-variable'; +import { Card, CardContent, TextField } from '@material-ui/core' +import { ChangeEvent } from 'react'; +import { Info } from '../types/common'; type ModelEditorProps = { info: Info updateName: (name: string) => void updateDescription: (description: string) => void - addValueVariable: (valueVariable: ValueVariableType) => void - addCategoricalVariable: (categoricalVariable: CategoricalVariableType) => void } export default function ModelEditor(props: ModelEditorProps) { const { info } = props - const [radioIndex, setRadioIndex] = useState(0) return (

- - - - Add new variable - - - - {setRadioIndex(0)}} - /> - Value - - - {setRadioIndex(1)}} - /> - Categorical - - -
-
- {radioIndex === 0 && - props.addValueVariable(valueVariable)} /> - } - {radioIndex === 1 && - props.addCategoricalVariable(categoricalVariable)} /> - } -
-
-
-
) diff --git a/components/optimizer-model.tsx b/components/optimizer-model.tsx index ed6b2ea2..3925f58e 100644 --- a/components/optimizer-model.tsx +++ b/components/optimizer-model.tsx @@ -1,17 +1,20 @@ -import { Button, Card, CardContent, Table, TableBody, TableCell, TableHead, TableRow, Typography } from '@material-ui/core' +import { Button, Card, CardContent, IconButton, Table, TableBody, TableCell, TableHead, TableRow, Typography } from '@material-ui/core' import { CategoricalVariableType, ExperimentType, ValueVariableType } from '../types/common' import DeleteIcon from '@material-ui/icons/Delete' -import { ReactNode } from 'react' +import { ReactNode, useState } from 'react' +import VariableEditor from './variable-editor' type OptimizerModelProps = { experiment: ExperimentType onDeleteValueVariable: (valueVariable: ValueVariableType) => void onDeleteCategoricalVariable: (categoricalVariable: CategoricalVariableType) => void + addValueVariable: (valueVariable: ValueVariableType) => void + addCategoricalVariable: (categoricalVariable: CategoricalVariableType) => void } export default function OptimizerModel(props: OptimizerModelProps) { - const { experiment: { valueVariables, categoricalVariables} } = props + const [isAddOpen, setAddOpen] = useState(false) function renderCategoricalVariableOptions(options: string[]): ReactNode[] { return options.map((option, optionIndex) => { @@ -51,9 +54,9 @@ export default function OptimizerModel(props: OptimizerModelProps) { {valueVar.minVal} {valueVar.maxVal} - + {props.onDeleteValueVariable(valueVar)}}> + + ))} @@ -83,9 +86,9 @@ export default function OptimizerModel(props: OptimizerModelProps) { {renderCategoricalVariableOptions(catVar.options)} - + {props.onDeleteCategoricalVariable(catVar)}}> + + ))} @@ -93,6 +96,17 @@ export default function OptimizerModel(props: OptimizerModelProps) { } +
+
+ {!isAddOpen && + + } + {isAddOpen && + props.addCategoricalVariable(categoricalVariable)} + addValueVariable={(valueVariable: ValueVariableType) => props.addValueVariable(valueVariable)} + close={() => setAddOpen(false)} /> + } ) diff --git a/components/value-variable.tsx b/components/value-variable.tsx index dce979df..675aa16e 100644 --- a/components/value-variable.tsx +++ b/components/value-variable.tsx @@ -18,6 +18,7 @@ export default function ValueVariable(props: ValueVariableProps) { <>



void + addCategoricalVariable: (categoricalVariable: CategoricalVariableType) => void + close: () => void +} + +export default function VariableEditor(props: VariableEditorProps) { + const [radioIndex, setRadioIndex] = useState(0) + const classes = useStyles() + + return ( + + + + + + + + + Add variable + + + + + props.close()}> + + + + + + {setRadioIndex(0)}} + /> + Value + + + {setRadioIndex(1)}} + /> + Categorical + + +
+
+ {radioIndex === 0 && + props.addValueVariable(valueVariable)} /> + } + {radioIndex === 1 && + props.addCategoricalVariable(categoricalVariable)} /> + } +
+
+
+
+
+
+ ) +} \ No newline at end of file diff --git a/pages/experiment/[experimentid].tsx b/pages/experiment/[experimentid].tsx index 1c1d9a82..5cc6113b 100644 --- a/pages/experiment/[experimentid].tsx +++ b/pages/experiment/[experimentid].tsx @@ -117,7 +117,8 @@ export default function Experiment() { - + + {state.experiment.id} @@ -126,19 +127,41 @@ export default function Experiment() { {state.experiment.info.name} {isDirty && '(unsaved)'} + + + + + + updateName(name)} - updateDescription={(description: string) => updateDescription(description)} - addValueVariable={(valueVariable: ValueVariableType) => addValueVariable(valueVariable)} - addCategoricalVariable={(categoricalVariable: CategoricalVariableType) => addCategoricalVariable(categoricalVariable)}/> + updateDescription={(description: string) => updateDescription(description)} /> +
+ + + + Next experiment + + + {state.experiment.results.next && state.experiment.results.next.join(',')} + + + +
+ updateOptimizerConfiguration(config)}/>
- + + {deleteValueVariable(valueVariable)}} - onDeleteCategoricalVariable={(categoricalVariable: CategoricalVariableType) => {deleteCategoricalVariable(categoricalVariable)}}/> + onDeleteCategoricalVariable={(categoricalVariable: CategoricalVariableType) => {deleteCategoricalVariable(categoricalVariable)}} + addValueVariable={(valueVariable: ValueVariableType) => addValueVariable(valueVariable)} + addCategoricalVariable={(categoricalVariable: CategoricalVariableType) => addCategoricalVariable(categoricalVariable)}/>
}
- - updateOptimizerConfiguration(config)}/> -
- - - - Next experiment: {state.experiment.results.next && state.experiment.results.next.join(',')} - - - -
+

-
- - - - - - - - +
- + Experiment saved diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 00000000..bc6b93b5 Binary files /dev/null and b/public/logo.png differ diff --git a/styles/experiment.style.tsx b/styles/experiment.style.tsx index 02e121a3..e3320c4b 100644 --- a/styles/experiment.style.tsx +++ b/styles/experiment.style.tsx @@ -11,6 +11,12 @@ export const useStyles = makeStyles(theme => ({ experimentContainerDirty: { border: '2px solid ' + theme.palette.warning.main, }, + actionContainer: { + textAlign: "right", + }, + runButton: { + marginLeft: theme.spacing(2), + }, saveButtonDirty: { animationName: '$saveButton', animationDuration: '3s', @@ -18,13 +24,13 @@ export const useStyles = makeStyles(theme => ({ }, '@keyframes saveButton': { '0%': { - backgroundColor: theme.palette.secondary.main, + backgroundColor: theme.palette.primary.main, }, '50%': { backgroundColor: theme.palette.warning.main, }, '100%': { - backgroundColor: theme.palette.secondary.main, + backgroundColor: theme.palette.primary.main, } } })); diff --git a/styles/layout.style.tsx b/styles/layout.style.tsx new file mode 100644 index 00000000..642c4188 --- /dev/null +++ b/styles/layout.style.tsx @@ -0,0 +1,18 @@ +import { makeStyles } from "@material-ui/core"; + +export const useStyles = makeStyles(theme => ({ + links: { + marginLeft: theme.spacing(5), + }, + link: { + color: "white", + }, + mainContent: { + marginTop: 56, + }, + logo: { + marginRight: theme.spacing(1), + } +})); + +export default useStyles \ No newline at end of file diff --git a/styles/variable-editor.style.tsx b/styles/variable-editor.style.tsx new file mode 100644 index 00000000..cb67fc4a --- /dev/null +++ b/styles/variable-editor.style.tsx @@ -0,0 +1,9 @@ +import { makeStyles } from "@material-ui/core"; + +export const useStyles = makeStyles(theme => ({ + main: { + background: theme.palette.grey[50], + } +})); + +export default useStyles \ No newline at end of file