-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Checkin and merge to master Signed-off-by: Jason Porter <[email protected]> * fixed one more Signed-off-by: Jason Porter <[email protected]>
- Loading branch information
1 parent
950e080
commit f09f6af
Showing
14 changed files
with
344 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,4 +211,4 @@ | |
"resolutions": { | ||
"micromatch": "^4.0.0" | ||
} | ||
} | ||
} |
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
106 changes: 106 additions & 0 deletions
106
src/components/flytegraph/ReactFlow/NodeStatusLegend.tsx
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,106 @@ | ||
import * as React from 'react'; | ||
import { useState, CSSProperties } from 'react'; | ||
import { Button } from '@material-ui/core'; | ||
import { nodePhaseColorMapping } from './utils'; | ||
|
||
export const LegendItem = ({ color, text }) => { | ||
/** | ||
* @TODO temporary check for nested graph until | ||
* nested functionality is deployed | ||
*/ | ||
const isNested = text == 'Nested'; | ||
|
||
const containerStyle: CSSProperties = { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
width: '100%', | ||
padding: '.5rem 0' | ||
}; | ||
const colorStyle: CSSProperties = { | ||
width: '28px', | ||
height: '22px', | ||
background: isNested ? color : 'none', | ||
border: `3px solid ${color}`, | ||
borderRadius: '4px', | ||
paddingRight: '10px', | ||
marginRight: '1rem' | ||
}; | ||
return ( | ||
<div style={containerStyle}> | ||
<div style={colorStyle}></div> | ||
<div>{text}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export const Legend = () => { | ||
const [isVisible, setIsVisible] = useState(true); | ||
|
||
const positionStyle: CSSProperties = { | ||
bottom: '1rem', | ||
right: '1rem', | ||
zIndex: 10000, | ||
position: 'absolute', | ||
width: '150px' | ||
}; | ||
|
||
const buttonContainer: CSSProperties = { | ||
width: '100%', | ||
display: 'flex', | ||
justifyContent: 'center' | ||
}; | ||
|
||
const buttonStyle: CSSProperties = { | ||
color: '#555', | ||
width: '100%' | ||
}; | ||
|
||
const toggleVisibility = () => { | ||
setIsVisible(!isVisible); | ||
}; | ||
|
||
const renderLegend = () => { | ||
const legendContainerStyle: CSSProperties = { | ||
width: '100%', | ||
padding: '1rem', | ||
background: 'rgba(255,255,255,1)', | ||
border: `1px solid #ddd`, | ||
borderRadius: '4px', | ||
boxShadow: '2px 4px 10px rgba(50,50,50,.2)', | ||
marginBottom: '1rem' | ||
}; | ||
|
||
return ( | ||
<div style={legendContainerStyle}> | ||
{Object.keys(nodePhaseColorMapping).map(phase => { | ||
return ( | ||
<LegendItem | ||
{...nodePhaseColorMapping[phase]} | ||
key={`gl-${nodePhaseColorMapping[phase].text}`} | ||
/> | ||
); | ||
})} | ||
<LegendItem color={'#aaa'} text={'Nested'} /> | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<div style={positionStyle}> | ||
<div> | ||
{isVisible ? renderLegend() : null} | ||
<div style={buttonContainer}> | ||
<Button | ||
style={buttonStyle} | ||
color="default" | ||
id="graph-show-legend" | ||
onClick={toggleVisibility} | ||
variant="contained" | ||
> | ||
{isVisible ? 'Hide' : 'Show'} Legend | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.