-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/build-arm-image
- Loading branch information
Showing
19 changed files
with
319 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { RichTypography } from "@commons-ui/legacy"; | ||
import { Box } from "@mui/material"; | ||
import PropTypes from "prop-types"; | ||
import React, { useState, forwardRef } from "react"; | ||
|
||
const Legend = forwardRef(function Legend({ data, title }, ref) { | ||
const [hoveredValue, setHoveredValue] = useState(null); | ||
|
||
const handleMouseEnter = (value) => { | ||
setHoveredValue(value); | ||
}; | ||
|
||
const handleMouseLeave = () => { | ||
setHoveredValue(null); | ||
}; | ||
|
||
return ( | ||
<Box> | ||
<RichTypography variant="caption" sx={{ fontWeight: "bold", mb: 1 }}> | ||
{title} | ||
</RichTypography> | ||
<Box ref={ref} display="flex" alignItems="center"> | ||
{data.map((item) => ( | ||
<Box | ||
key={`${item.min} - ${item.max}`} | ||
onMouseEnter={() => handleMouseEnter(`${item.min} - ${item.max}`)} | ||
onMouseLeave={handleMouseLeave} | ||
sx={{ | ||
backgroundColor: item.color, | ||
height: 24, | ||
minWidth: 24, | ||
cursor: "pointer", | ||
}} | ||
/> | ||
))} | ||
{hoveredValue && ( | ||
<RichTypography | ||
variant="caption" | ||
sx={{ marginLeft: 2, whiteSpace: "nowrap" }} | ||
> | ||
{hoveredValue} | ||
</RichTypography> | ||
)} | ||
</Box> | ||
</Box> | ||
); | ||
}); | ||
|
||
Legend.propTypes = { | ||
data: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
min: PropTypes.number.isRequired, | ||
max: PropTypes.number.isRequired, | ||
color: PropTypes.string.isRequired, | ||
}), | ||
).isRequired, | ||
}; | ||
|
||
export default Legend; |
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.