diff --git a/workspaces/homepage/.changeset/brave-rocks-wave.md b/workspaces/homepage/.changeset/brave-rocks-wave.md new file mode 100644 index 0000000000..990412c2eb --- /dev/null +++ b/workspaces/homepage/.changeset/brave-rocks-wave.md @@ -0,0 +1,5 @@ +--- +'@red-hat-developer-hub/backstage-plugin-dynamic-home-page': patch +--- + +Fixed Homepage Layout when quickstart is visible diff --git a/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntityCard.tsx b/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntityCard.tsx index 4c5d045b1e..249da2e081 100644 --- a/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntityCard.tsx +++ b/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntityCard.tsx @@ -48,7 +48,8 @@ const EntityCard: FC = ({ sx={{ border: theme => `1px solid ${theme.palette.grey[400]}`, overflow: 'auto', - maxHeight: '100%', + height: '100%', + width: '100%', }} > = ({ pb: 2, }, backgroundColor: 'transparent', + display: 'flex', + flexDirection: 'column', + justifyContent: 'space-between', }} > diff --git a/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.test.tsx b/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.test.tsx index 73094f2996..ae8783544e 100644 --- a/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.test.tsx +++ b/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.test.tsx @@ -72,6 +72,14 @@ jest.mock('../../utils/utils', () => ({ jest.mock('../../images/homepage-entities-1.svg', () => 'mock-image.svg'); +// ResizeObserver is not available in JSDOM +class ResizeObserverMock { + observe = jest.fn(); + unobserve = jest.fn(); + disconnect = jest.fn(); +} +window.ResizeObserver = ResizeObserverMock as unknown as typeof ResizeObserver; + const theme = createTheme(); const renderComponent = () => diff --git a/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.tsx b/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.tsx index c425b3ab50..ad13bb392f 100644 --- a/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.tsx +++ b/workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.tsx @@ -15,7 +15,7 @@ */ import type { ReactNode } from 'react'; -import { useState, useEffect, Fragment } from 'react'; +import { useState, useEffect, Fragment, useRef } from 'react'; import { CodeSnippet, @@ -67,6 +67,22 @@ export const EntitySection = () => { const isMd = useMediaQuery(theme.breakpoints.only('md')); + const [contentWidth, setContentWidth] = useState(0); + const resizeObserverRef = useRef(null); + + const setContentNode = (node: HTMLDivElement | null) => { + if (!node) return; + + resizeObserverRef.current?.disconnect(); + + resizeObserverRef.current = new ResizeObserver(entries => { + const width = entries[0].contentRect.width; + setContentWidth(width); + }); + + resizeObserverRef.current.observe(node); + }; + useEffect(() => { if (isMd) { setIsMediumBreakpoint(true); @@ -126,17 +142,24 @@ export const EntitySection = () => { content = ( - + {!isRemoveFirstCard && !profileLoading && ( - + { : 'translateX(-50px)', }} > - {!imgLoaded && ( - 350 ? 'row' : 'column', + width: '100%', + maxWidth: '550px', + minHeight: '100%', + }} + > + {!imgLoaded && ( + + )} + setImgLoaded(true)} + alt="" height={300} sx={{ - borderRadius: 3, width: 'clamp(140px, 14vw, 266px)', }} /> - )} - setImgLoaded(true)} - alt="" - height={300} - sx={{ - width: 'clamp(140px, 14vw, 266px)', - }} - /> - - - - {t('entities.description')} - + + + + {t('entities.description')} + + + {entities?.length > 0 && ( + + + + )} - {entities?.length > 0 && ( - - - - )} @@ -195,8 +231,9 @@ export const EntitySection = () => { item xs={12} md={6} - lg={isRemoveFirstCard ? 3 : 3.5} + lg={isRemoveFirstCard ? 3 : 4} key={item.metadata.name} + display="flex" > { ))} {entities?.length === 0 && ( - + `1px solid ${muiTheme.palette.grey[400]}`, borderRadius: 3, overflow: 'hidden', }} > - + {t('entities.empty')} @@ -236,9 +286,11 @@ export const EntitySection = () => { > {t('entities.emptyDescription')} - - {t('entities.register')} - + + + {t('entities.register')} + + @@ -256,6 +308,10 @@ export const EntitySection = () => { padding: '24px', border: muitheme => `1px solid ${muitheme.palette.grey[300]}`, overflow: 'auto', + flex: 1, + minHeight: 0, + display: 'flex', + flexDirection: 'column', }} > { alignItems: 'center', fontWeight: '500', fontSize: '1.5rem', + flexShrink: 0, }} > {t('entities.title')} - {content} - {entities?.length > 0 && ( - - - - - - )} + + {content} + {entities?.length > 0 && ( + + + + + + )} + ); }; diff --git a/workspaces/homepage/plugins/dynamic-home-page/src/components/OnboardingSection/OnboardingCard.tsx b/workspaces/homepage/plugins/dynamic-home-page/src/components/OnboardingSection/OnboardingCard.tsx index 57c3b7a4d4..0c065c9730 100644 --- a/workspaces/homepage/plugins/dynamic-home-page/src/components/OnboardingSection/OnboardingCard.tsx +++ b/workspaces/homepage/plugins/dynamic-home-page/src/components/OnboardingSection/OnboardingCard.tsx @@ -44,8 +44,8 @@ const OnboardingCard: FC = ({ { const content = ( - + )} + sx={{ + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + }} > { {getLearningItems(t).map((item: LearningSectionItem) => ( )} + sx={{ + display: 'flex', + justifyContent: 'left', + alignItems: 'center', + }} key={item.title} - display="flex" - justifyContent="left" - alignItems="center" > { padding: '24px', border: muiTheme => `1px solid ${muiTheme.palette.grey[300]}`, overflow: 'auto', + flex: 1, + minHeight: 0, }} > {!profileLoading && ( @@ -145,12 +159,13 @@ export const OnboardingSection = () => { alignItems: 'center', fontWeight: '500', fontSize: '1.5rem', + flexShrink: 0, }} > {`${greeting}, ${profileDisplayName() || t('onboarding.guest')}!`} )} - {content} + {content} ); }; diff --git a/workspaces/homepage/plugins/dynamic-home-page/src/components/ReadOnlyGrid.tsx b/workspaces/homepage/plugins/dynamic-home-page/src/components/ReadOnlyGrid.tsx index af30714e9c..ca4793ce76 100644 --- a/workspaces/homepage/plugins/dynamic-home-page/src/components/ReadOnlyGrid.tsx +++ b/workspaces/homepage/plugins/dynamic-home-page/src/components/ReadOnlyGrid.tsx @@ -84,9 +84,18 @@ const defaultProps: ResponsiveProps = { const useStyles = makeStyles()({ // Make card content scrollable (so that cards don't overlap) cardWrapper: { + height: '100%', + minHeight: 0, + overflow: 'hidden', + display: 'flex', + flexDirection: 'column', '& > div[class*="MuiCard-root"]': { width: '100%', height: '100%', + minHeight: 0, + display: 'flex', + flexDirection: 'column', + overflow: 'hidden', }, '& div[class*="MuiCardContent-root"]': { overflow: 'auto', diff --git a/workspaces/homepage/plugins/dynamic-home-page/src/components/TemplateSection/TemplateSection.tsx b/workspaces/homepage/plugins/dynamic-home-page/src/components/TemplateSection/TemplateSection.tsx index aae0b7cfc8..6e0176e938 100644 --- a/workspaces/homepage/plugins/dynamic-home-page/src/components/TemplateSection/TemplateSection.tsx +++ b/workspaces/homepage/plugins/dynamic-home-page/src/components/TemplateSection/TemplateSection.tsx @@ -107,6 +107,7 @@ export const TemplateSection = () => { display: 'flex', alignItems: 'center', justifyContent: 'center', + maxWidth: 550, border: muiTheme => `1px solid ${muiTheme.palette.grey[400]}`, borderRadius: 3,