Added a variant prop to the WelcomeTitle component

Signed-off-by: Andre Wanlin <awanlin@spotify.com>
This commit is contained in:
Andre Wanlin
2025-05-19 16:26:23 -05:00
parent 33eacde752
commit 2c1761fc41
3 changed files with 14 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-home': patch
---
Added a `variant` prop to the `WelcomeTitle` component making it work with the Customizable Home page feature. Adding it like this `<WelcomeTitle variant='h1' />` to the list of items under `CustomHomepageGrid` will allow it to render with a size that works well.
@@ -28,6 +28,7 @@ import { HomePageSearchBar } from '@backstage/plugin-search';
import Grid from '@material-ui/core/Grid';
import { tools, useLogoStyles } from './shared';
import { WelcomeTitle } from '@backstage/plugin-home';
const defaultConfig = [
{
@@ -81,6 +82,7 @@ export const CustomizableHomePage = () => {
</Grid>
<CustomHomepageGrid config={defaultConfig}>
<WelcomeTitle variant="h1" />
<HomePageSearchBar />
<HomePageRecentlyVisited />
<HomePageTopVisited />
@@ -23,13 +23,18 @@ import Typography from '@material-ui/core/Typography';
import { useEffect, useMemo } from 'react';
import useAsync from 'react-use/esm/useAsync';
import { getTimeBasedGreeting } from './timeUtil';
import { Variant } from '@material-ui/core/styles/createTypography';
/** @public */
export type WelcomeTitleLanguageProps = {
language?: string[];
variant?: Variant | 'inherit';
};
export const WelcomeTitle = ({ language }: WelcomeTitleLanguageProps) => {
export const WelcomeTitle = ({
language,
variant,
}: WelcomeTitleLanguageProps) => {
const identityApi = useApi(identityApiRef);
const alertApi = useApi(alertApiRef);
const greeting = useMemo(() => getTimeBasedGreeting(language), [language]);
@@ -49,7 +54,7 @@ export const WelcomeTitle = ({ language }: WelcomeTitleLanguageProps) => {
return (
<Tooltip title={greeting.language}>
<Typography component="span" variant="inherit">{`${greeting.greeting}${
<Typography component="span" variant={variant}>{`${greeting.greeting}${
profile?.displayName ? `, ${profile?.displayName}` : ''
}!`}</Typography>
</Tooltip>