-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- StatusIcon. Partially implements #9796.
- Loading branch information
Showing
7 changed files
with
50 additions
and
65 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,34 +1,28 @@ | ||
import "./StatusIcon.css" | ||
|
||
import { Avatar, Tooltip } from "@mui/material" | ||
import { instanceOf, oneOfType, string } from "prop-types" | ||
import { Icon } from "semantic-ui-react" | ||
|
||
import { STATUS_SHORT_NAME, statusPropType } from "../metric/status" | ||
import { Popup } from "../semantic_ui_react_wrappers" | ||
import { STATUS_COLORS_MUI, STATUS_ICONS, STATUS_SHORT_NAME, statusPropType } from "../metric/status" | ||
import { TimeAgoWithDate } from "../widgets/TimeAgoWithDate" | ||
|
||
export function StatusIcon({ status, status_start, size }) { | ||
export function StatusIcon({ status, statusStart, size }) { | ||
status = status || "unknown" | ||
const icon_name = { | ||
target_met: "check", | ||
near_target_met: "warning", | ||
debt_target_met: "money", | ||
target_not_met: "bolt", | ||
informative: "info", | ||
unknown: "question", | ||
}[status] | ||
const sizes = { small: 20, undefined: 32 } | ||
const statusName = STATUS_SHORT_NAME[status] | ||
const icon = <Icon aria-label={statusName} className={status} inverted circular name={icon_name} size={size} /> | ||
return status_start ? ( | ||
<Popup trigger={icon} flowing hoverable> | ||
<TimeAgoWithDate date={status_start}>{`${statusName} since`}</TimeAgoWithDate> | ||
</Popup> | ||
) : ( | ||
icon | ||
// Use Avatar to create a round inverted icon: | ||
const iconStyle = { width: sizes[size], height: sizes[size], bgcolor: STATUS_COLORS_MUI[status] } | ||
const icon = ( | ||
<Avatar aria-label={statusName} sx={iconStyle}> | ||
{STATUS_ICONS[status]} | ||
</Avatar> | ||
) | ||
if (statusStart) { | ||
const tooltipTitle = <TimeAgoWithDate date={statusStart}>{`${statusName} since`}</TimeAgoWithDate> | ||
return <Tooltip title={tooltipTitle}>{icon}</Tooltip> | ||
} | ||
return icon | ||
} | ||
StatusIcon.propTypes = { | ||
status: statusPropType, | ||
status_start: oneOfType([string, instanceOf(Date)]), | ||
statusStart: oneOfType([string, instanceOf(Date)]), | ||
size: string, | ||
} |
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