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:
authored and GitHub committed 2024-07-19 05:30:50 +00:00
1 parent 0d1dd036eb
commit 7ee3f9409c
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";
+2
View File
@@ -193,6 +193,8 @@ export {
} from "./components/command";
export { Popover, PopoverContent, PopoverTrigger } from "./components/popover";
export { OrgBanner } from "./components/organization-banner";
export type { OrgBannerProps } from "./components/organization-banner";
export { StorybookTrpcProvider } from "./components/mocks/trpc";
export { default as Icon } from "./components/icon/Icon";