Skip to content

Commit eaa5337

Browse files
committed
fix double border issue with the widgets
1 parent 52f5f6d commit eaa5337

20 files changed

Lines changed: 322 additions & 183 deletions

workspaces/homepage/.changeset/mui-v5-homepage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
---
44

55
Replace Material UI v4 with MUI v5 and scope JSS class names to prevent style collisions.
6+
Fix double border issue in the widgets

workspaces/homepage/plugins/dynamic-home-page/report-alpha.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ export const homepageTranslationRef: TranslationRef<
4848
readonly 'onboarding.learn.ariaLabel': string;
4949
readonly 'entities.title': string;
5050
readonly 'entities.error': string;
51-
readonly 'entities.description': string;
5251
readonly 'entities.close': string;
5352
readonly 'entities.empty': string;
5453
readonly 'entities.fetchError': string;
5554
readonly 'entities.emptyDescription': string;
5655
readonly 'entities.register': string;
56+
readonly 'entities.description': string;
5757
readonly 'entities.browseTheCatalog': string;
5858
}
5959
>;

workspaces/homepage/plugins/dynamic-home-page/report.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,6 @@ export interface WorldClockProps {
260260
// (undocumented)
261261
worldClocks: ClockConfig[];
262262
}
263+
264+
// (No @packageDocumentation comment for this package)
263265
```

workspaces/homepage/plugins/dynamic-home-page/src/alpha/components/CustomizableGridLayout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import {
2828
} from '@backstage/plugin-home';
2929
import { useTheme } from '@mui/material/styles';
3030
import GlobalStyles from '@mui/material/GlobalStyles';
31+
32+
import { cardWrapperSx } from '../../styles/cardWrapperSx';
3133
import { HomePageCardConfig } from '../../types';
3234
import { useContainerQuery } from '../../hooks/useContainerQuery';
3335

@@ -91,6 +93,7 @@ export const CustomizableGridLayout = ({
9193
? 'rgba(20, 20, 20, 0.95) !important'
9294
: 'rgba(40, 40, 40, 0.93) !important',
9395
},
96+
'[class*="widgetWrapper"]': cardWrapperSx,
9497
}}
9598
/>
9699
<div

workspaces/homepage/plugins/dynamic-home-page/src/alpha/components/ReadOnlyGirdLayout.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,7 @@ const defaultProps: ResponsiveProps = {
7979
compactType: null,
8080
};
8181

82-
const cardWrapperSx = {
83-
'& > div[class*="MuiCard-root"]': {
84-
width: '100%',
85-
height: '100%',
86-
},
87-
'& div[class*="MuiCardContent-root"]': {
88-
overflow: 'auto',
89-
},
90-
};
91-
82+
import { cardWrapperSx } from '../../styles/cardWrapperSx';
9283
/**
9384
* Props for the read-only grid layout.
9485
* @alpha

workspaces/homepage/plugins/dynamic-home-page/src/alpha/extensions/homePageCards.tsx

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { HomePageWidgetBlueprint } from '@backstage/plugin-home-react/alpha';
1818
import homePlugin from '@backstage/plugin-home/alpha';
1919
import { compatWrapper } from '@backstage/core-compat-api';
20+
import { homepageMessages } from '../../translations/ref';
2021

2122
const defaultCardLayout = {
2223
width: {
@@ -41,9 +42,11 @@ export const onboardingSectionWidget = HomePageWidgetBlueprint.make({
4142
name: 'Red Hat Developer Hub - Onboarding',
4243
layout: defaultCardLayout,
4344
components: () =>
44-
import('../../components/OnboardingSection').then(m => ({
45-
Content: m.OnboardingSection,
46-
})),
45+
import('../../components/OnboardingSection/OnboardingSection').then(
46+
m => ({
47+
Content: m.OnboardingSectionContent,
48+
}),
49+
),
4750
},
4851
});
4952

@@ -55,10 +58,11 @@ export const entitySectionWidget = HomePageWidgetBlueprint.make({
5558
name: 'rhdh-entity-section',
5659
params: {
5760
name: 'Red Hat Developer Hub - Software Catalog',
61+
title: homepageMessages.entities.title,
5862
layout: defaultCardLayout,
5963
components: () =>
60-
import('../../components/EntitySection').then(m => ({
61-
Content: () => compatWrapper(<m.EntitySection />),
64+
import('../../components/EntitySection/EntitySection').then(m => ({
65+
Content: m.EntitySectionContent,
6266
})),
6367
},
6468
});
@@ -71,10 +75,11 @@ export const templateSectionWidget = HomePageWidgetBlueprint.make({
7175
name: 'rhdh-template-section',
7276
params: {
7377
name: 'Red Hat Developer Hub - Explore templates',
78+
title: homepageMessages.templates.title,
7479
layout: defaultCardLayout,
7580
components: () =>
76-
import('../../components/TemplateSection').then(m => ({
77-
Content: m.TemplateSection,
81+
import('../../components/TemplateSection/TemplateSection').then(m => ({
82+
Content: m.TemplateSectionContent,
7883
})),
7984
},
8085
});
@@ -87,10 +92,11 @@ export const quickAccessCardWidget = HomePageWidgetBlueprint.make({
8792
name: 'quick-access-card',
8893
params: {
8994
name: 'Quick Access Card',
95+
title: homepageMessages.quickAccess.title,
9096
layout: defaultCardLayout,
9197
components: () =>
9298
import('../../components/QuickAccessCard').then(m => ({
93-
Content: () => compatWrapper(<m.QuickAccessCard />),
99+
Content: m.QuickAccessCardContent,
94100
})),
95101
},
96102
});
@@ -121,6 +127,17 @@ export const searchBarWidget = HomePageWidgetBlueprint.make({
121127
},
122128
});
123129

130+
/**
131+
* Renders a legacy plugin-home CardExtension directly, skipping the NFS
132+
* CardExtension InfoCard shell. Used when upstream only exports full cards
133+
* (not Content) from the public API.
134+
*/
135+
const legacyHomeCardRenderer = ({
136+
Content,
137+
}: {
138+
Content: React.ComponentType;
139+
}) => compatWrapper(<Content />);
140+
124141
/**
125142
* NFS widget: FeaturedDocsCard (migrated from mountPoint home.page/cards).
126143
* @alpha
@@ -133,6 +150,7 @@ export const featuredDocsCardWidget = HomePageWidgetBlueprint.make({
133150
components: () =>
134151
import('../../components/FeaturedDocsCard').then(m => ({
135152
Content: m.FeaturedDocsCard,
153+
Renderer: legacyHomeCardRenderer,
136154
})),
137155
},
138156
});
@@ -172,6 +190,7 @@ export const RecentlyVisitedWidget = HomePageWidgetBlueprint.make({
172190
components: () =>
173191
import('@backstage/plugin-home').then(m => ({
174192
Content: m.HomePageRecentlyVisited,
193+
Renderer: legacyHomeCardRenderer,
175194
})),
176195
},
177196
});
@@ -187,7 +206,8 @@ export const TopVisitedWidget = HomePageWidgetBlueprint.make({
187206
name: 'Top visited',
188207
components: () =>
189208
import('@backstage/plugin-home').then(m => ({
190-
Content: () => <m.HomePageTopVisited />,
209+
Content: m.HomePageTopVisited,
210+
Renderer: legacyHomeCardRenderer,
191211
})),
192212
},
193213
});

workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { render, screen } from '@testing-library/react';
1919
import { MemoryRouter } from 'react-router-dom';
2020
import { ThemeProvider, createTheme } from '@mui/material/styles';
2121

22-
import { EntitySection } from './EntitySection';
22+
import { EntitySection } from '../legacy/HomePageLegacyCards';
2323
import { useEntities } from '../../hooks/useEntities';
2424

2525
// jsdom does not provide ResizeObserver; required by useContainerQuery in EntitySection

workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/EntitySection.tsx

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import {
4949
useContainerQuery,
5050
type ContainerSize,
5151
} from '../../hooks/useContainerQuery';
52+
import { sectionContentContainerSx } from '../../styles/sectionCardSx';
5253

5354
const StyledLink = styled(BackstageLink)(({ theme }) => ({
5455
textDecoration: 'none',
@@ -59,7 +60,7 @@ const StyledLink = styled(BackstageLink)(({ theme }) => ({
5960
borderRadius: 4,
6061
}));
6162

62-
export const EntitySection = () => {
63+
export const EntitySectionContent = () => {
6364
const theme = useTheme();
6465
const { t } = useTranslation();
6566
const { displayName, loading: profileLoading } = useUserProfile();
@@ -285,46 +286,15 @@ export const EntitySection = () => {
285286
}
286287

287288
return (
288-
<Card
289-
elevation={0}
290-
sx={{
291-
padding: '24px',
292-
border: muitheme => `1px solid ${muitheme.palette.grey[300]}`,
293-
containerType: 'inline-size',
294-
display: 'flex',
295-
flexDirection: 'column',
296-
}}
297-
>
298-
<Typography
299-
variant="h3"
300-
sx={{
301-
display: 'flex',
302-
alignItems: 'center',
303-
fontWeight: '500',
304-
fontSize: '1.5rem',
305-
flexShrink: 0,
306-
}}
307-
>
308-
{t('entities.title')}
309-
</Typography>
310-
<Box
311-
ref={containerRef}
312-
sx={{
313-
flex: 1,
314-
minHeight: 0,
315-
overflowY: 'auto',
316-
mt: 1,
317-
}}
318-
>
319-
{content}
320-
{entities?.length > 0 && (
321-
<Box sx={{ pt: 2 }}>
322-
<ViewMoreLink to="/catalog">
323-
{t('entities.browseTheCatalog')}
324-
</ViewMoreLink>
325-
</Box>
326-
)}
327-
</Box>
328-
</Card>
289+
<Box ref={containerRef} sx={sectionContentContainerSx}>
290+
{content}
291+
{entities?.length > 0 && (
292+
<Box sx={{ pt: 2 }}>
293+
<ViewMoreLink to="/catalog">
294+
{t('entities.browseTheCatalog')}
295+
</ViewMoreLink>
296+
</Box>
297+
)}
298+
</Box>
329299
);
330300
};

workspaces/homepage/plugins/dynamic-home-page/src/components/EntitySection/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
export { EntitySection } from './EntitySection';
17-
export { EntitySection as default } from './EntitySection';
16+
export { EntitySectionContent } from './EntitySection';
17+
export { EntitySection } from '../legacy/HomePageLegacyCards';
18+
export { EntitySection as default } from '../legacy/HomePageLegacyCards';

workspaces/homepage/plugins/dynamic-home-page/src/components/FeaturedDocsCard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { useTranslation } from '../hooks/useTranslation';
2727
*
2828
* 1. To fix the all uppercase that is used in home plugin
2929
* 2. To add a small missing gap between the title and the button
30+
*
31+
* @public
3032
*/
3133
export const FeaturedDocsCard = (props: FeaturedDocsCardProps) => {
3234
const { t } = useTranslation();

0 commit comments

Comments
 (0)