Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions packages/module/src/Battery/Battery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createUseStyles } from 'react-jss'

const batteryDefault = {
'& svg': {
'& path': { fill: 'var(--pf-v5-global--disabled-color--200)' }
'& path': { fill: 'var(--pf-v5-global--icon--Color--light)' }
}
};

Expand Down Expand Up @@ -32,6 +32,12 @@ const batteryCritical = {
}
};

const batteryLineColor = {
'& svg': {
'& path': { stroke: 'var(--pf-v5-global--BorderColor--100)' }
}
};

const useStyles = createUseStyles({
battery: {
display: 'inline-block',
Expand All @@ -48,6 +54,7 @@ const useStyles = createUseStyles({
batteryMedium,
batteryHigh,
batteryCritical,
batteryLineColor
});

const batteryLevels = (severity: BatterySeverity, classMode?: boolean) => {
Expand Down Expand Up @@ -91,17 +98,15 @@ const Battery: React.FunctionComponent<BatteryProps> = ({ severity, label, label
const classes = useStyles();
const batteryClasses = clsx(classes.battery, classes[String(batteryLevels(severity, true))], className);

let ariaLabels = {};
if (labelHidden) {
ariaLabels = { ['aria-label']: `${severity} ${label}` };
}
const title = { ['title']: `${severity} ${label}` };


const batteryVariant = useMemo(() => batteryLevels(severity) , [ severity ])

return (
<React.Fragment>
{/* eslint-disable-next-line react/no-unknown-property */}
<i className={batteryClasses} {...ariaLabels} {...props} widget-type="InsightsBattery" widget-id={label}>
<i className={batteryClasses} {...title} {...props} widget-type="Battery" widget-id={label}>
<svg
version="1.1"
x="0px"
Expand All @@ -114,7 +119,7 @@ const Battery: React.FunctionComponent<BatteryProps> = ({ severity, label, label
style={{
fill: 'none',
fillOpacity: 1,
stroke: '#969696',
stroke: batteryLineColor['& svg']['& path'].stroke,
strokeWidth: 41.96378708,
strokeLinejoin: 'round',
strokeMiterlimit: 4,
Expand Down
Loading