Skip to content

Commit

Permalink
Make Badge priority class always present like in all other components
Browse files Browse the repository at this point in the history
This change affects output HTML and may break downstream snapshot tests.
  • Loading branch information
adamkudrna committed Sep 11, 2024
1 parent 9664227 commit c3e3222
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/components/Badge/Badge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { withGlobalProps } from '../../provider';
import { classNames } from '../../utils/classNames';
import { transferProps } from '../../utils/transferProps';
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';
import styles from './Badge.module.scss';

export const Badge = ({
Expand All @@ -16,7 +17,7 @@ export const Badge = ({
{...transferProps(restProps)}
className={classNames(
styles.root,
priority === 'outline' && styles.isRootPriorityOutline,
getRootPriorityClassName(priority, styles),
getRootColorClassName(color, styles),
)}
>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Badge/Badge.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ $_badge-size: 1.25rem;
vertical-align: baseline;
color: var(--rui-local-color);
border-radius: math.div($_badge-size, 2);
}

.isRootPriorityFilled {
background-color: var(--rui-local-background-color);
box-shadow: var(--rui-local-box-shadow, #{0 0 0 2px rgb(255 255 255 / 80%)});
}
Expand Down Expand Up @@ -67,9 +70,6 @@ $_badge-size: 1.25rem;
}

.isRootPriorityOutline {
--rui-local-background-color: transparent;
--rui-local-box-shadow: none;

padding-top: 0.1875rem;
padding-bottom: 0.1875rem;
border: borders.$width solid currentcolor;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Badge/__tests__/Badge.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('rendering', () => {
],
[
{ priority: 'filled' },
(rootElement) => expect(rootElement).not.toHaveClass('isRootPriorityOutline'),
(rootElement) => expect(rootElement).toHaveClass('isRootPriorityFilled'),
],
[
{ priority: 'outline' },
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { withGlobalProps } from '../../provider';
import { classNames } from '../../utils/classNames';
import { transferProps } from '../../utils/transferProps';
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
import { ButtonGroupContext } from '../ButtonGroup';
import { InputGroupContext } from '../InputGroup/InputGroupContext';
import getRootPriorityClassName from '../_helpers/getRootPriorityClassName';
import getRootLabelVisibilityClassName from './helpers/getRootLabelVisibilityClassName';
import styles from './Button.module.scss';

Expand Down
2 changes: 1 addition & 1 deletion src/components/ButtonGroup/ButtonGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
import { withGlobalProps } from '../../provider';
import { classNames } from '../../utils/classNames';
import { transferProps } from '../../utils/transferProps';
import getRootPriorityClassName from '../_helpers/getRootPriorityClassName';
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
import styles from './ButtonGroup.module.scss';
import { ButtonGroupContext } from './ButtonGroupContext';
Expand Down
2 changes: 1 addition & 1 deletion src/components/_helpers/getRootPriorityClassName.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default (priority, styles) => {
export const getRootPriorityClassName = (priority, styles) => {
if (priority === 'filled') {
return styles.isRootPriorityFilled;
}
Expand Down

0 comments on commit c3e3222

Please sign in to comment.