Skip to content

Commit 648dd30

Browse files
add createGenerateClassName
1 parent 6c4d1fe commit 648dd30

7 files changed

Lines changed: 55 additions & 12 deletions

File tree

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

Lines changed: 0 additions & 5 deletions
This file was deleted.

workspaces/scorecard/plugins/scorecard/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"@backstage/theme": "^0.7.2",
6464
"@mui/icons-material": "5.18.0",
6565
"@mui/material": "5.18.0",
66+
"@mui/styles": "5.18.0",
6667
"@red-hat-developer-hub/backstage-plugin-scorecard-common": "workspace:^",
6768
"@tanstack/react-query": "^5.95.2",
6869
"date-fns": "^4.1.0",

workspaces/scorecard/plugins/scorecard/src/components/Scorecard/EntityScorecardContent.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ import Scorecard from './Scorecard';
2424
import { useScorecards } from '../../hooks/useScorecards';
2525
import { getStatusConfig, resolveMetricTranslation } from '../../utils';
2626
import PermissionRequiredState from '../Common/PermissionRequiredState';
27+
import { ScorecardStylesProvider } from '../ScorecardStylesProvider';
2728
import { useTranslation } from '../../hooks/useTranslation';
2829
import { CardLoading } from '../Common/CardLoading';
2930

30-
export const EntityScorecardContent = () => {
31+
const EntityScorecardContentInner = () => {
3132
const { data: scorecards, isLoading, error } = useScorecards();
3233
const { t } = useTranslation();
3334

@@ -102,3 +103,9 @@ export const EntityScorecardContent = () => {
102103
</Box>
103104
);
104105
};
106+
107+
export const EntityScorecardContent = () => (
108+
<ScorecardStylesProvider>
109+
<EntityScorecardContentInner />
110+
</ScorecardStylesProvider>
111+
);

workspaces/scorecard/plugins/scorecard/src/components/ScorecardHomepageSection/ScorecardHomepageCard.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { EmptyStatePanel } from './EmptyStatePanel';
2323
import { Metric } from '@red-hat-developer-hub/backstage-plugin-scorecard-common';
2424
import { useMetricDisplayLabels } from '../../hooks/useMetricDisplayLabels';
2525
import { CardLoading } from '../Common/CardLoading';
26+
import { ScorecardStylesProvider } from '../ScorecardStylesProvider';
2627

2728
/** Coerces unknown/missing values to a finite number for safe UI math (NaN → 0). */
2829
function toSafeFiniteNumber(value: unknown): number {
@@ -129,7 +130,9 @@ export const ScorecardHomepageCardWithProvider = (props: {
129130
showSubheader?: boolean;
130131
showInfo?: boolean;
131132
}) => (
132-
<ScorecardQueryProvider>
133-
<ScorecardHomepageCard {...props} />
134-
</ScorecardQueryProvider>
133+
<ScorecardStylesProvider>
134+
<ScorecardQueryProvider>
135+
<ScorecardHomepageCard {...props} />
136+
</ScorecardQueryProvider>
137+
</ScorecardStylesProvider>
135138
);

workspaces/scorecard/plugins/scorecard/src/components/ScorecardPage/ScorecardPage.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Divider from '@mui/material/Divider';
2525
import { ScorecardQueryProvider } from '../../api';
2626
import { ScorecardHomepageCard } from '../ScorecardHomepageSection/ScorecardHomepageCard';
2727
import NotFoundState from '../Common/NotFoundState';
28+
import { ScorecardStylesProvider } from '../ScorecardStylesProvider';
2829
import { useTranslation } from '../../hooks/useTranslation';
2930
import { resolveMetricTranslation } from '../../utils/translationUtils';
3031

@@ -125,7 +126,9 @@ export const ScorecardPage = () => {
125126
* when rendered outside a tree that already has a provider (e.g. on the homepage).
126127
*/
127128
export const ScorecardPageWithProvider = () => (
128-
<ScorecardQueryProvider>
129-
<ScorecardPage />
130-
</ScorecardQueryProvider>
129+
<ScorecardStylesProvider>
130+
<ScorecardQueryProvider>
131+
<ScorecardPage />
132+
</ScorecardQueryProvider>
133+
</ScorecardStylesProvider>
131134
);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import type { ReactNode } from 'react';
18+
19+
import { createGenerateClassName, StylesProvider } from '@mui/styles';
20+
21+
const generateClassName = createGenerateClassName({
22+
seed: 'scorecard',
23+
});
24+
25+
export const ScorecardStylesProvider = ({
26+
children,
27+
}: {
28+
readonly children: ReactNode;
29+
}) => (
30+
<StylesProvider generateClassName={generateClassName}>
31+
{children}
32+
</StylesProvider>
33+
);

workspaces/scorecard/yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12380,6 +12380,7 @@ __metadata:
1238012380
"@backstage/ui": "npm:^0.13.2"
1238112381
"@mui/icons-material": "npm:5.18.0"
1238212382
"@mui/material": "npm:5.18.0"
12383+
"@mui/styles": "npm:5.18.0"
1238312384
"@red-hat-developer-hub/backstage-plugin-scorecard-common": "workspace:^"
1238412385
"@red-hat-developer-hub/backstage-plugin-theme": "npm:^0.13.0"
1238512386
"@tanstack/react-query": "npm:^5.95.2"

0 commit comments

Comments
 (0)