-
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.
Merge pull request #262 from RobokopU24/feature/node-information
Feature/node information
- Loading branch information
Showing
4 changed files
with
259 additions
and
48 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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react'; | ||
import { Paper, styled, Popover as MuiPopover } from '@material-ui/core'; | ||
|
||
const PopoverPaper = styled(Paper)(({ theme }) => ({ | ||
filter: 'drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.3))', | ||
|
||
position: 'relative', | ||
'&::before': { | ||
content: '""', | ||
display: 'block', | ||
position: 'absolute', | ||
bottom: '-15px', | ||
left: '0', | ||
right: '0', | ||
margin: '0 auto', | ||
clipPath: "path('M 0 0 L 20 0 L 10 15 Z')", | ||
width: '20px', | ||
height: '15px', | ||
backgroundColor: theme.palette.background.paper, | ||
}, | ||
})); | ||
|
||
const PopoverPaperBelow = styled(PopoverPaper)(() => ({ | ||
'&::before': { | ||
top: '-15px', | ||
bottom: 'unset', | ||
clipPath: "path('M 0 15 L 20 15 L 10 0 Z')", | ||
}, | ||
})); | ||
|
||
const Popover = ({ | ||
children, open, onClose, anchorPosition, above, | ||
}) => { | ||
let PositionedPaper = PopoverPaperBelow; | ||
if (above) PositionedPaper = PopoverPaper; | ||
|
||
let anchorOriginVertical = 'bottom'; | ||
if (above) anchorOriginVertical = 'top'; | ||
|
||
let transformOriginVertical = 'top'; | ||
if (above) transformOriginVertical = 'bottom'; | ||
|
||
let marginBlockStart = '28px'; | ||
if (above) marginBlockStart = '-28px'; | ||
|
||
return ( | ||
<MuiPopover | ||
anchorReference="anchorPosition" | ||
anchorPosition={anchorPosition} | ||
open={open} | ||
onClose={onClose} | ||
anchorOrigin={{ | ||
vertical: anchorOriginVertical, | ||
horizontal: 'center', | ||
}} | ||
transformOrigin={{ | ||
vertical: transformOriginVertical, | ||
horizontal: 'center', | ||
}} | ||
PaperProps={{ | ||
style: { | ||
boxShadow: 'none', | ||
overflow: 'visible', | ||
marginBlockStart, | ||
}, | ||
}} | ||
> | ||
<PositionedPaper>{children}</PositionedPaper> | ||
</MuiPopover> | ||
); | ||
}; | ||
|
||
export default Popover; |
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,81 @@ | ||
import React from 'react'; | ||
import { | ||
Box, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableRow, | ||
styled, | ||
} from '@material-ui/core'; | ||
|
||
const StyledTableBody = styled(TableBody)(() => ({ | ||
'& .MuiTableRow-root:last-of-type .MuiTableCell-root': { | ||
borderBottom: 'none', | ||
}, | ||
})); | ||
|
||
const ValueCell = ({ value }) => ( | ||
<TableCell> | ||
<ul style={{ padding: 0, margin: 0, listStyleType: 'none' }}> | ||
{Array.isArray(value) ? ( | ||
value.map((valueItem, valueItemIndex) => ( | ||
<li key={valueItemIndex}>{valueItem}</li> | ||
)) | ||
) : ( | ||
<li>{value}</li> | ||
)} | ||
</ul> | ||
</TableCell> | ||
); | ||
|
||
const NodeAttributesTable = ({ nodeData }) => { | ||
const { | ||
name, id, categories, count, | ||
} = nodeData; | ||
|
||
return ( | ||
<Box style={{ maxHeight: 500, overflow: 'auto' }}> | ||
<Table size="small" aria-label="node attributes table"> | ||
<StyledTableBody> | ||
{Boolean(name) && ( | ||
<TableRow style={{ verticalAlign: 'top' }}> | ||
<TableCell> | ||
Name | ||
</TableCell> | ||
<ValueCell value={name} /> | ||
</TableRow> | ||
)} | ||
|
||
{Boolean(id) && ( | ||
<TableRow style={{ verticalAlign: 'top' }}> | ||
<TableCell> | ||
ID | ||
</TableCell> | ||
<ValueCell value={id} /> | ||
</TableRow> | ||
)} | ||
|
||
{Boolean(categories) && ( | ||
<TableRow style={{ verticalAlign: 'top' }}> | ||
<TableCell> | ||
Categories | ||
</TableCell> | ||
<ValueCell value={categories} /> | ||
</TableRow> | ||
)} | ||
|
||
{Boolean(count) && ( | ||
<TableRow style={{ verticalAlign: 'top' }}> | ||
<TableCell> | ||
Count | ||
</TableCell> | ||
<ValueCell value={count} /> | ||
</TableRow> | ||
)} | ||
</StyledTableBody> | ||
</Table> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default NodeAttributesTable; |
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