-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added plant, cell, and tissue efps with routing
- Loading branch information
Showing
22 changed files
with
1,394 additions
and
472 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
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
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,50 @@ | ||
import { Box, Button, Grid, Tooltip } from '@mui/material' | ||
|
||
import { StateActions } from '.' | ||
|
||
interface ActionsPanelProps<T> { | ||
actions: StateActions<T> | ||
prevState: T | ||
setState: (newState: T) => void | ||
} | ||
|
||
export const ActionsPanel = <T,>({ | ||
actions, | ||
prevState, | ||
setState, | ||
}: ActionsPanelProps<T>) => { | ||
const actionButtons = Object.entries(actions) | ||
.filter(([_, action]) => action.rendered) | ||
.map(([key, action]) => { | ||
if (action.rendered) { | ||
return ( | ||
<Tooltip key={key} title={key}> | ||
<Button | ||
startIcon={action.icon} | ||
onClick={() => setState(action.mutation(prevState))} | ||
></Button> | ||
</Tooltip> | ||
) | ||
} | ||
return null // Should never get here but need this to make TS compiler happy | ||
}) | ||
|
||
const rows = [] | ||
for (let i = 0; i < actionButtons.length; i += 5) { | ||
rows.push(actionButtons.slice(i, i + 5)) | ||
} | ||
|
||
return ( | ||
<Box> | ||
{rows.map((row, index) => ( | ||
<Grid container spacing={2} key={index}> | ||
{row.map((button) => ( | ||
<Grid item key={button?.key}> | ||
{button} | ||
</Grid> | ||
))} | ||
</Grid> | ||
))} | ||
</Box> | ||
) | ||
} |
Oops, something went wrong.