Skip to content

Commit 9f225a9

Browse files
committed
fix: updated the styles.
1 parent e355442 commit 9f225a9

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

packages/module/src/Severity/Severity.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@ const severityUndefined = {
4747
};
4848

4949
const useStyles = createUseStyles({
50-
battery: {
50+
severity: {
5151
display: 'inline-block',
5252
'line-height': 0,
5353
'& svg': {
5454
position: 'relative',
5555
top: 'var(--pf-t--global--spacer--sm)',
56-
height: '1.75rem'
57-
}
56+
height: 'calc(var(--pf-t--global--spacer--md) * 1.75)',
57+
},
58+
},
59+
severityLabel: {
60+
'margin-left': 'var(--pf-t--global--spacer--xs)'
5861
},
59-
6062
severityNone,
6163
severityMinor,
6264
severityModerate,
@@ -65,7 +67,7 @@ const useStyles = createUseStyles({
6567
severityUndefined
6668
});
6769

68-
const batteryLevels = (severity: SeverityType, classMode?: boolean) => {
70+
const severityLevels = (severity: SeverityType, classMode?: boolean) => {
6971
switch (severity) {
7072
case 'critical':
7173
return classMode ? 'severityCritical' : <SeverityCriticalIcon />;
@@ -94,9 +96,9 @@ export const SeverityType = {
9496
export type SeverityType = (typeof SeverityType)[keyof typeof SeverityType];
9597

9698
export interface SeverityProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
97-
/** Determines a variant of displayed battery */
99+
/** Determines a variant of displayed severity */
98100
severity: SeverityType;
99-
/** Label displayed next to the battery */
101+
/** Label displayed next to the severity */
100102
label: string;
101103
/** Option to hide the label */
102104
labelHidden?: boolean;
@@ -115,19 +117,19 @@ export const Severity: React.FunctionComponent<SeverityProps> = ({
115117
...props
116118
}: SeverityProps) => {
117119
const classes = useStyles();
118-
const batteryClasses = clsx(classes.battery, classes[String(batteryLevels(severity, true))], className);
120+
const severityClasses = clsx(classes.severity, classes[String(severityLevels(severity, true))], className);
119121

120122
const title = { title: `${severity} ${label}` };
121123

122-
const batteryVariant = useMemo(() => batteryLevels(severity), [ severity ]);
124+
const severityVariant = useMemo(() => severityLevels(severity), [ severity ]);
123125

124126
return (
125127
<React.Fragment>
126128
{/* eslint-disable-next-line react/no-unknown-property */}
127-
<i className={batteryClasses} {...title} {...props} widget-type="Severity" widget-id={label} data-ouia-component-id={ouiaId}>
128-
{batteryVariant}
129+
<i className={severityClasses} {...title} {...props} widget-type="Severity" widget-id={label} data-ouia-component-id={ouiaId}>
130+
{severityVariant}
129131
</i>
130-
{!labelHidden && <span> {label} </span>}
132+
{!labelHidden && <span className={clsx(classes.severityLabel)}> {label} </span>}
131133
</React.Fragment>
132134
);
133135
};

packages/module/src/Severity/__snapshots__/Severity.test.tsx.snap

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`Severity component API should hide label 1`] = `
44
<div>
55
<i
6-
class="battery-0-2-1 severityImportant-0-2-5"
6+
class="severity-0-2-1 severityImportant-0-2-6"
77
data-ouia-component-id="Severity-icon"
88
title="important important"
99
widget-id="important"
@@ -29,7 +29,7 @@ exports[`Severity component API should hide label 1`] = `
2929
exports[`Severity component should render correctly CriticalSeverity 1`] = `
3030
<div>
3131
<i
32-
class="battery-0-2-1 severityCritical-0-2-6"
32+
class="severity-0-2-1 severityCritical-0-2-7"
3333
data-ouia-component-id="Severity-icon"
3434
title="critical Critical"
3535
widget-id="Critical"
@@ -49,7 +49,9 @@ exports[`Severity component should render correctly CriticalSeverity 1`] = `
4949
/>
5050
</svg>
5151
</i>
52-
<span>
52+
<span
53+
class="severityLabel-0-2-2"
54+
>
5355
5456
Critical
5557
@@ -60,7 +62,7 @@ exports[`Severity component should render correctly CriticalSeverity 1`] = `
6062
exports[`Severity component should render correctly HighSeverity 1`] = `
6163
<div>
6264
<i
63-
class="battery-0-2-1 severityImportant-0-2-5"
65+
class="severity-0-2-1 severityImportant-0-2-6"
6466
data-ouia-component-id="Severity-icon"
6567
title="important Important"
6668
widget-id="Important"
@@ -80,7 +82,9 @@ exports[`Severity component should render correctly HighSeverity 1`] = `
8082
/>
8183
</svg>
8284
</i>
83-
<span>
85+
<span
86+
class="severityLabel-0-2-2"
87+
>
8488
8589
Important
8690
@@ -91,7 +95,7 @@ exports[`Severity component should render correctly HighSeverity 1`] = `
9195
exports[`Severity component should render correctly LowSeverity 1`] = `
9296
<div>
9397
<i
94-
class="battery-0-2-1 severityMinor-0-2-3"
98+
class="severity-0-2-1 severityMinor-0-2-4"
9599
data-ouia-component-id="Severity-icon"
96100
title="minor Minor"
97101
widget-id="Minor"
@@ -111,7 +115,9 @@ exports[`Severity component should render correctly LowSeverity 1`] = `
111115
/>
112116
</svg>
113117
</i>
114-
<span>
118+
<span
119+
class="severityLabel-0-2-2"
120+
>
115121
116122
Minor
117123
@@ -122,7 +128,7 @@ exports[`Severity component should render correctly LowSeverity 1`] = `
122128
exports[`Severity component should render correctly LowSeverity 2`] = `
123129
<div>
124130
<i
125-
class="battery-0-2-1 severityMinor-0-2-3"
131+
class="severity-0-2-1 severityMinor-0-2-4"
126132
data-ouia-component-id="Severity-icon"
127133
title="none None"
128134
widget-id="None"
@@ -142,7 +148,9 @@ exports[`Severity component should render correctly LowSeverity 2`] = `
142148
/>
143149
</svg>
144150
</i>
145-
<span>
151+
<span
152+
class="severityLabel-0-2-2"
153+
>
146154
147155
None
148156
@@ -153,7 +161,7 @@ exports[`Severity component should render correctly LowSeverity 2`] = `
153161
exports[`Severity component should render correctly MediumSeverity 1`] = `
154162
<div>
155163
<i
156-
class="battery-0-2-1 severityModerate-0-2-4"
164+
class="severity-0-2-1 severityModerate-0-2-5"
157165
data-ouia-component-id="Severity-icon"
158166
title="moderate Moderate"
159167
widget-id="Moderate"
@@ -173,7 +181,9 @@ exports[`Severity component should render correctly MediumSeverity 1`] = `
173181
/>
174182
</svg>
175183
</i>
176-
<span>
184+
<span
185+
class="severityLabel-0-2-2"
186+
>
177187
178188
Moderate
179189
@@ -184,7 +194,7 @@ exports[`Severity component should render correctly MediumSeverity 1`] = `
184194
exports[`Severity component should render correctly UndefinedSeverity, default 1`] = `
185195
<div>
186196
<i
187-
class="battery-0-2-1 severityNone-0-2-2"
197+
class="severity-0-2-1 severityNone-0-2-3"
188198
data-ouia-component-id="Severity-icon"
189199
title=" "
190200
widget-id=""
@@ -204,7 +214,9 @@ exports[`Severity component should render correctly UndefinedSeverity, default 1
204214
/>
205215
</svg>
206216
</i>
207-
<span>
217+
<span
218+
class="severityLabel-0-2-2"
219+
>
208220
209221
210222
</span>

0 commit comments

Comments
 (0)