Skip to content

Commit d80288b

Browse files
authored
fix: used passed className for page-notice (#243)
1 parent 66463ee commit d80288b

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

.changeset/sad-hands-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ebay/ui-core-react": patch
3+
---
4+
5+
fix(EbayPageNotice): fixed className passing to page-notice component

packages/ebayui-core-react/src/ebay-page-notice/__tests__/index.spec.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,16 @@ describe("<EbayPageNotice>", () => {
9191
expect(dismissMock).toHaveBeenCalled();
9292
});
9393
});
94+
95+
it("should support passing custom classes", () => {
96+
const { container } = render(
97+
<EbayPageNotice status="confirmation" className="custom-class">
98+
<EbayNoticeContent>
99+
<EbayPageNoticeTitle>Here is the title</EbayPageNoticeTitle>
100+
<p id="details">Here is some details</p>
101+
</EbayNoticeContent>
102+
</EbayPageNotice>,
103+
);
104+
expect(container.querySelector(".page-notice")).toHaveClass("custom-class");
105+
});
94106
});

packages/ebayui-core-react/src/ebay-page-notice/page-notice.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { ComponentProps, FC, KeyboardEventHandler, MouseEventHandler, useState } from "react";
2+
import classNames from "classnames";
23
import NoticeContent from "../common/notice-utils/notice-content";
34
import { EbayNoticeContent } from "../ebay-notice-base/components/ebay-notice-content";
45
import { EbayIcon, Icon } from "../ebay-icon";
@@ -20,6 +21,7 @@ const EbayPageNotice: FC<Props> = ({
2021
a11yDismissText,
2122
"aria-label": ariaLabel,
2223
onDismiss = () => {},
24+
className,
2325
...rest
2426
}) => {
2527
const [dismissed, setDismissed] = useState(false);
@@ -38,7 +40,9 @@ const EbayPageNotice: FC<Props> = ({
3840
<section
3941
{...rest}
4042
aria-labelledby={id || `${status}-status`}
41-
className={`page-notice ${status !== `general` ? `page-notice--${status}` : ``}`}
43+
className={classNames("page-notice", className, {
44+
[`page-notice--${status}`]: status !== "general",
45+
})}
4246
>
4347
{status !== `general` ? (
4448
<div className="page-notice__header" id={id || `${status}-status`}>

0 commit comments

Comments
 (0)