Use page theme fontColor consistently in scaffolder headers and cards.

This fixes problems with themes with white header background, which
end up with white-on-white text for card heads and context menus.

Signed-off-by: Axel Hecht <axel@pike.org>
This commit is contained in:
Axel Hecht
2023-03-06 14:14:41 +01:00
parent 479c7025f5
commit 3c96e77b51
5 changed files with 39 additions and 18 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-scaffolder-react': minor
'@backstage/plugin-scaffolder': minor
---
Make scaffolder adhere to page themes by using page fontColor consistently. If your theme overwrites template list or card headers, review those stylings.
@@ -21,17 +21,22 @@ import { BackstageTheme } from '@backstage/theme';
import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
import { FavoriteEntity } from '@backstage/plugin-catalog-react';
const useStyles = makeStyles<BackstageTheme, { cardBackgroundImage: string }>(
() => ({
header: {
backgroundImage: ({ cardBackgroundImage }) => cardBackgroundImage,
},
subtitleWrapper: {
display: 'flex',
justifyContent: 'space-between',
},
}),
);
const useStyles = makeStyles<
BackstageTheme,
{
cardFontColor: string;
cardBackgroundImage: string;
}
>(() => ({
header: {
backgroundImage: ({ cardBackgroundImage }) => cardBackgroundImage,
color: ({ cardFontColor }) => cardFontColor,
},
subtitleWrapper: {
display: 'flex',
justifyContent: 'space-between',
},
}));
/**
* Props for the CardHeader component
@@ -54,6 +59,7 @@ export const CardHeader = (props: CardHeaderProps) => {
const themeForType = getPageTheme({ themeId: type });
const styles = useStyles({
cardFontColor: themeForType.fontColor,
cardBackgroundImage: themeForType.backgroundImage,
});
@@ -15,6 +15,7 @@
*/
import { useRouteRef } from '@backstage/core-plugin-api';
import { BackstageTheme } from '@backstage/theme';
import IconButton from '@material-ui/core/IconButton';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
@@ -34,9 +35,9 @@ import {
scaffolderListTaskRouteRef,
} from '../../routes';
const useStyles = makeStyles(theme => ({
const useStyles = makeStyles<BackstageTheme>(theme => ({
button: {
color: theme.palette.common.white,
color: theme.page.fontColor,
},
}));
@@ -64,12 +64,16 @@ import WarningIcon from '@material-ui/icons/Warning';
import React from 'react';
import { selectedTemplateRouteRef, viewTechDocRouteRef } from '../../routes';
const useStyles = makeStyles(theme => ({
const useStyles = makeStyles<
BackstageTheme,
{ fontColor: string; backgroundImage: string }
>(theme => ({
cardHeader: {
position: 'relative',
},
title: {
backgroundImage: ({ backgroundImage }: any) => backgroundImage,
backgroundImage: ({ backgroundImage }) => backgroundImage,
color: ({ fontColor }) => fontColor,
},
box: {
overflow: 'hidden',
@@ -186,7 +190,10 @@ export const TemplateCard = ({ template, deprecated }: TemplateCardProps) => {
? templateProps.type
: 'other';
const theme = backstageTheme.getPageTheme({ themeId });
const classes = useStyles({ backgroundImage: theme.backgroundImage });
const classes = useStyles({
fontColor: theme.fontColor,
backgroundImage: theme.backgroundImage,
});
const { name, namespace } = parseEntityRef(stringifyEntityRef(template));
const href = templateRoute({ templateName: name, namespace });
@@ -15,6 +15,7 @@
*/
import { useRouteRef } from '@backstage/core-plugin-api';
import { BackstageTheme } from '@backstage/theme';
import IconButton from '@material-ui/core/IconButton';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
@@ -34,9 +35,9 @@ import {
nextScaffolderListTaskRouteRef,
} from '../routes';
const useStyles = makeStyles(theme => ({
const useStyles = makeStyles((theme: BackstageTheme) => ({
button: {
color: theme.palette.common.white,
color: theme.page.fontColor,
},
}));