feat: [CAL-3939] fix org banner (#15557)
* update documentation for proper hostile command * add OrgBanner component and replace it in ee organization profile settings * add width and height defaults, with option to override * updated sizing with image loaded * fix: add alt to OrgBanner in test * fix: failing OrgBanner test, added neg test --------- Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
6 files changed
+67
-7
No files matched your search
@@ -0,0 +1,20 @@
|
||||
/* eslint-disable playwright/missing-playwright-await */
|
||||
import { render } from "@testing-library/react";
|
||||
|
||||
import { OrgBanner } from "./OrgBanner";
|
||||
|
||||
describe("tests for OrgBanner component", () => {
|
||||
test("Should render the OrgBanner correctly when supplied imageSrc", () => {
|
||||
const { getByTestId } = render(
|
||||
<OrgBanner alt="Test Org Banner" data-testid="org-banner-test" imageSrc="/logo.svg" />
|
||||
);
|
||||
const orgBanner = getByTestId("org-banner-test");
|
||||
|
||||
expect(orgBanner).toBeInTheDocument();
|
||||
});
|
||||
test("Should not render the OrgBanner when no imageSrc is supplied", () => {
|
||||
const { getByTestId } = render(<OrgBanner alt="Test Org Banner" data-testid="org-banner-test" />);
|
||||
|
||||
expect(() => getByTestId("org-banner-test")).toThrow();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import Image from "next/image";
|
||||
|
||||
import classNames from "@calcom/lib/classNames";
|
||||
|
||||
type Maybe<T> = T | null | undefined;
|
||||
|
||||
export type OrgBannerProps = {
|
||||
alt: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
imageSrc?: Maybe<string>;
|
||||
fallback?: React.ReactNode;
|
||||
className?: string;
|
||||
"data-testid"?: string;
|
||||
};
|
||||
|
||||
export function OrgBanner(props: OrgBannerProps) {
|
||||
const { imageSrc, alt, width = 1500, height = 500 } = props;
|
||||
|
||||
if (!imageSrc) {
|
||||
return <div className={classNames("bg-muted", props.className)}>{props.fallback}</div>;
|
||||
}
|
||||
return (
|
||||
<Image
|
||||
data-testid={props?.["data-testid"]}
|
||||
src={imageSrc}
|
||||
alt={alt}
|
||||
className={props.className}
|
||||
width={width}
|
||||
height={height}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export { OrgBanner } from "./OrgBanner";
|
||||
export type { OrgBannerProps } from "./OrgBanner";
|
||||
Reference in new issue
Block a user