Skip to content

Commit

Permalink
feat(Modal): Added status variant styling to title (#10592)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlabaj authored Jun 13, 2024
1 parent a0c6355 commit c07a319
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@
"packages/**"
]
},
"dependencies": {}
"dependencies": {},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
7 changes: 6 additions & 1 deletion packages/react-core/src/components/Modal/ModalBoxTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export const ModalBoxTitle: React.FunctionComponent<ModalBoxTitleProps> = ({
<h1
id={id}
ref={h1}
className={css(modalStyles.modalBoxTitle, titleIconVariant && modalStyles.modifiers.icon, className)}
className={css(
modalStyles.modalBoxTitle,
titleIconVariant && modalStyles.modifiers.icon,
isVariantIcon(titleIconVariant) && modalStyles.modifiers[titleIconVariant],
className
)}
{...props}
>
{titleIconVariant && (
Expand Down
2 changes: 0 additions & 2 deletions packages/react-core/src/components/Modal/ModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export const ModalHeader: React.FunctionComponent<ModalHeaderProps> = ({
</>
);

// TODO: apply variant modifier for icon styling. Core fix needed first. similar to this:
// className={css(className, isVariantIcon(titleIconVariant) && modalStyles.modifiers[titleIconVariant])}
return (
<header className={css(styles.modalBoxHeader, help && styles.modifiers.help, className)} {...props}>
{help && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
import * as React from 'react';
import { render } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';

import { ModalBoxTitle } from '../ModalBoxTitle';
import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon';
import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box';

test('ModalBoxTitle alert variant', () => {
const { asFragment } = render(<ModalBoxTitle title="Test Modal Box warning" id="boxId" titleIconVariant="warning" />);
expect(asFragment()).toMatchSnapshot();
expect(screen.getByRole('heading')).toHaveClass(styles.modifiers.warning);
});

test('ModalBoxTitle info variant', () => {
const { asFragment } = render(<ModalBoxTitle title="Test Modal Box info" id="boxId" titleIconVariant="info" />);
expect(screen.getByRole('heading')).toHaveClass(styles.modifiers.info);
expect(asFragment()).toMatchSnapshot();
});

test('ModalBoxTitle danger variant', () => {
const { asFragment } = render(<ModalBoxTitle title="Test Modal Box danger" id="boxId" titleIconVariant="danger" />);
expect(screen.getByRole('heading')).toHaveClass(styles.modifiers.danger);
expect(asFragment()).toMatchSnapshot();
});

test('ModalBoxTitle custom variant', () => {
const { asFragment } = render(<ModalBoxTitle title="Test Modal Box warning" id="boxId" titleIconVariant="custom" />);
const { asFragment } = render(<ModalBoxTitle title="Test Modal Box custom" id="boxId" titleIconVariant="custom" />);
expect(screen.getByRole('heading')).toHaveClass(styles.modifiers.custom);
expect(asFragment()).toMatchSnapshot();
});

test('ModalBoxTitle success variant', () => {
const { asFragment } = render(<ModalBoxTitle title="Test Modal Box success" id="boxId" titleIconVariant="success" />);
expect(screen.getByRole('heading')).toHaveClass(styles.modifiers.success);
expect(asFragment()).toMatchSnapshot();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`ModalBoxTitle alert variant 1`] = `
<DocumentFragment>
<h1
class="pf-v6-c-modal-box__title pf-m-icon"
class="pf-v6-c-modal-box__title pf-m-icon pf-m-warning"
id="boxId"
>
<span
Expand Down Expand Up @@ -72,7 +72,7 @@ exports[`ModalBoxTitle custom icon variant 1`] = `
exports[`ModalBoxTitle custom variant 1`] = `
<DocumentFragment>
<h1
class="pf-v6-c-modal-box__title pf-m-icon"
class="pf-v6-c-modal-box__title pf-m-icon pf-m-custom"
id="boxId"
>
<span
Expand Down Expand Up @@ -100,7 +100,7 @@ exports[`ModalBoxTitle custom variant 1`] = `
<span
class="pf-v6-c-modal-box__title-text"
>
Test Modal Box warning
Test Modal Box custom
</span>
</h1>
</DocumentFragment>
Expand All @@ -109,7 +109,7 @@ exports[`ModalBoxTitle custom variant 1`] = `
exports[`ModalBoxTitle danger variant 1`] = `
<DocumentFragment>
<h1
class="pf-v6-c-modal-box__title pf-m-icon"
class="pf-v6-c-modal-box__title pf-m-icon pf-m-danger"
id="boxId"
>
<span
Expand Down Expand Up @@ -146,7 +146,7 @@ exports[`ModalBoxTitle danger variant 1`] = `
exports[`ModalBoxTitle info variant 1`] = `
<DocumentFragment>
<h1
class="pf-v6-c-modal-box__title pf-m-icon"
class="pf-v6-c-modal-box__title pf-m-icon pf-m-info"
id="boxId"
>
<span
Expand Down Expand Up @@ -183,7 +183,7 @@ exports[`ModalBoxTitle info variant 1`] = `
exports[`ModalBoxTitle success variant 1`] = `
<DocumentFragment>
<h1
class="pf-v6-c-modal-box__title pf-m-icon"
class="pf-v6-c-modal-box__title pf-m-icon pf-m-success"
id="boxId"
>
<span
Expand Down

0 comments on commit c07a319

Please sign in to comment.