Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions workspaces/global-header/.changeset/real-windows-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@red-hat-developer-hub/backstage-plugin-global-header': patch
---

Fixes the icon of global-header
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { CSSProperties } from 'react';
import type { CSSProperties, ComponentType } from 'react';
import { useApp } from '@backstage/core-plugin-api';
import type { SvgIconProps } from '@mui/material/SvgIcon';
import MuiIcon from '@mui/material/Icon';
import Box from '@mui/material/Box';
import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline';

/**
* @public
Expand All @@ -35,6 +37,14 @@ function toMaterialIconLigature(name: string): string {
return name.replace(/[A-Z]/g, m => `_${m.toLowerCase()}`);
}

/**
* Bundled MUI icon fallbacks for names used in default toolbar extensions.
* Avoids reliance on the Material Icons web font being loaded at runtime.
*/
const BUILTIN_ICONS: Record<string, ComponentType<SvgIconProps>> = {
addCircleOutline: AddCircleOutlineIcon,
};

/**
* @public
*/
Expand All @@ -57,6 +67,15 @@ export const HeaderIcon = ({
);
}

const BuiltinIcon = BUILTIN_ICONS[icon];
if (BuiltinIcon) {
return (
<Box sx={{ display: 'flex', alignItems: 'center', ...layout }}>
<BuiltinIcon fontSize={size} />
</Box>
);
}

if (icon.startsWith('<svg')) {
const svgDataUri = `data:image/svg+xml;base64,${btoa(icon)}`;
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const HeaderIconButton = ({
icon,
tooltip,
color = 'inherit',
size = 'small',
size = 'medium',
ariaLabel,
to,
}: HeaderIconButtonProps) => {
Expand Down
Loading