Skip to content

Commit 5bcecab

Browse files
committed
Make Badge priority class always present like in all other components
This change affects output HTML and may break downstream snapshot tests.
1 parent 9664227 commit 5bcecab

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

src/components/Badge/Badge.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { withGlobalProps } from '../../provider';
44
import { classNames } from '../../utils/classNames';
55
import { transferProps } from '../../utils/transferProps';
66
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
7+
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';
78
import styles from './Badge.module.scss';
89

910
export const Badge = ({
@@ -16,7 +17,7 @@ export const Badge = ({
1617
{...transferProps(restProps)}
1718
className={classNames(
1819
styles.root,
19-
priority === 'outline' && styles.isRootPriorityOutline,
20+
getRootPriorityClassName(priority, styles),
2021
getRootColorClassName(color, styles),
2122
)}
2223
>

src/components/Badge/Badge.module.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ $_badge-size: 1.25rem;
2020
vertical-align: baseline;
2121
color: var(--rui-local-color);
2222
border-radius: math.div($_badge-size, 2);
23+
}
24+
25+
.isRootPriorityFilled {
2326
background-color: var(--rui-local-background-color);
2427
box-shadow: var(--rui-local-box-shadow, #{0 0 0 2px rgb(255 255 255 / 80%)});
2528
}
@@ -67,9 +70,6 @@ $_badge-size: 1.25rem;
6770
}
6871

6972
.isRootPriorityOutline {
70-
--rui-local-background-color: transparent;
71-
--rui-local-box-shadow: none;
72-
7373
padding-top: 0.1875rem;
7474
padding-bottom: 0.1875rem;
7575
border: borders.$width solid currentcolor;

src/components/Badge/__tests__/Badge.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('rendering', () => {
1919
],
2020
[
2121
{ priority: 'filled' },
22-
(rootElement) => expect(rootElement).not.toHaveClass('isRootPriorityOutline'),
22+
(rootElement) => expect(rootElement).toHaveClass('isRootPriorityFilled'),
2323
],
2424
[
2525
{ priority: 'outline' },

src/components/Button/Button.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { withGlobalProps } from '../../provider';
44
import { classNames } from '../../utils/classNames';
55
import { transferProps } from '../../utils/transferProps';
66
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
7+
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';
78
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
89
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
910
import { ButtonGroupContext } from '../ButtonGroup';
1011
import { InputGroupContext } from '../InputGroup/InputGroupContext';
11-
import getRootPriorityClassName from '../_helpers/getRootPriorityClassName';
1212
import getRootLabelVisibilityClassName from './helpers/getRootLabelVisibilityClassName';
1313
import styles from './Button.module.scss';
1414

src/components/ButtonGroup/ButtonGroup.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React, {
55
import { withGlobalProps } from '../../provider';
66
import { classNames } from '../../utils/classNames';
77
import { transferProps } from '../../utils/transferProps';
8-
import getRootPriorityClassName from '../_helpers/getRootPriorityClassName';
8+
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';
99
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
1010
import styles from './ButtonGroup.module.scss';
1111
import { ButtonGroupContext } from './ButtonGroupContext';

src/components/_helpers/getRootPriorityClassName.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default (priority, styles) => {
1+
export const getRootPriorityClassName = (priority, styles) => {
22
if (priority === 'filled') {
33
return styles.isRootPriorityFilled;
44
}

0 commit comments

Comments
 (0)