Skip to content

Commit

Permalink
feat(onboarding): improve onboarding template component
Browse files Browse the repository at this point in the history
Use React.ComponentProps to improve flexibility of image rules

Signed-off-by: Thibault Barske <[email protected]>
  • Loading branch information
tibs245 committed Sep 19, 2024
1 parent aa132e2 commit 38c94e2
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ export type OnboardingLayoutProps = OnboardingLayoutButtonProps &
hideHeadingSection?: boolean;
title: string;
description?: React.ReactNode;
img?: {
src: string;
width?: number;
height?: number;
};
img?: React.ComponentProps<'img'>;
}>;

const OnboardingLayoutButton: React.FC<OnboardingLayoutButtonProps> = ({
Expand Down Expand Up @@ -103,21 +99,16 @@ export const OnboardingLayout: React.FC<OnboardingLayoutProps> = ({
img,
isActionDisabled,
}) => {
const { className: brandImageClassName, ...brandImageProps } = img;

Check failure on line 102 in packages/manager-react-components/src/components/templates/onboarding/onboarding.component.tsx

View workflow job for this annotation

GitHub Actions / test

src/pages/onboarding/OnBoarding.page.spec.tsx > OnBoardingPage > should render children when volumes are empty

TypeError: Cannot destructure property 'className' of 'img' as it is undefined. ❯ OnboardingLayout ../../../manager-react-components/src/components/templates/onboarding/onboarding.component.tsx:102:22 ❯ renderWithHooks ../../../../node_modules/react-dom/cjs/react-dom.development.js:16305:18 ❯ mountIndeterminateComponent ../../../../node_modules/react-dom/cjs/react-dom.development.js:20074:13 ❯ beginWork ../../../../node_modules/react-dom/cjs/react-dom.development.js:21587:16 ❯ beginWork$1 ../../../../node_modules/react-dom/cjs/react-dom.development.js:27426:14 ❯ performUnitOfWork ../../../../node_modules/react-dom/cjs/react-dom.development.js:26560:12 ❯ workLoopSync ../../../../node_modules/react-dom/cjs/react-dom.development.js:26466:5 ❯ renderRootSync ../../../../node_modules/react-dom/cjs/react-dom.development.js:26434:7 ❯ recoverFromConcurrentError ../../../../node_modules/react-dom/cjs/react-dom.development.js:25850:20 ❯ performConcurrentWorkOnRoot ../../../../node_modules/react-dom/cjs/react-dom.development.js:25750:22
return (
<div className="flex flex-col mx-auto sm:px-10">
{!hideHeadingSection && (
<section className="flex flex-col items-center">
{(img?.src || placeholderSrc) && (
<div className="flex justify-center pt-8 max-h-28">
<img
className="max-h-[150px]"
src={img?.src ?? placeholderSrc}
alt=""
width={img?.width}
height={img?.height}
/>
</div>
)}
<section className="flex flex-col items-center mt-8">
<img
className={`max-h-28 ${brandImageClassName}`}
src={placeholderSrc}
{...brandImageProps}
/>
<OsdsText
color={ODS_THEME_COLOR_INTENT.primary}
level={ODS_TEXT_LEVEL.heading}
Expand Down

0 comments on commit 38c94e2

Please sign in to comment.