Skip to content

Commit

Permalink
fix: use simple IconComponent type
Browse files Browse the repository at this point in the history
  • Loading branch information
dweber019 committed Oct 24, 2024
1 parent aa4048f commit eda3051
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-dots-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dweber019/backstage-plugin-simple-icons': patch
---

Use simple IconComponent type without the AppIcons type.
10 changes: 7 additions & 3 deletions plugins/simple-icons/src/simpleIcons.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SvgIcon, SvgIconProps } from '@material-ui/core';
import type { SimpleIcon } from 'simple-icons';
import { OptionalAppOptions } from '@backstage/app-defaults';
import * as icons from 'simple-icons';
import React from 'react';
import { IconComponent } from '@backstage/core-plugin-api';

export const createIcon = (icon: SimpleIcon, color = true, props?: SvgIconProps) => {
const SimpleIcon: React.FC<SvgIconProps> = (iconProps) => {
Expand All @@ -19,13 +19,17 @@ export const createIcon = (icon: SimpleIcon, color = true, props?: SvgIconProps)
return () => {return <SimpleIcon {...defaultProps} />};
};

export const simpleIcons: OptionalAppOptions['icons'] =
export const simpleIcons: {
[key in string]: IconComponent;
} =
Object.keys(icons).map(key => {
const icon = (icons as any)[key] as SimpleIcon;
return { [icon.slug]: createIcon(icon, false), }
}).reduce((previous, current) => ({ ...previous, ...current }));

export const simpleIconsColor: OptionalAppOptions['icons'] =
export const simpleIconsColor: {
[key in string]: IconComponent;
} =
Object.keys(icons).map(key => {
const icon = (icons as any)[key] as SimpleIcon;
return { [icon.slug]: createIcon(icon), }
Expand Down

0 comments on commit eda3051

Please sign in to comment.