Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Badge priority class always present like in all other components #561

Merged
merged 1 commit into from
Sep 11, 2024
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
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),
adamkudrna marked this conversation as resolved.
Show resolved Hide resolved
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