Skip to content

Commit

Permalink
Render icon as a svg instead of img tag to support dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
vikram-raj committed Jun 8, 2022
1 parent 8703892 commit 084aed5
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type AddAction = ExtensionDeclaration<
icon?: CodeRef<React.ReactNode>;
/** Optional access review to control visibility / enablement of the action. */
accessReview?: AccessReviewResourceAttributes[];
iconRenderAs?: 'svg' | 'img';
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
// temporary fix since --pf-global--FontSize--md is being computed to 14px instead of 16px
font-size: var(--pf-global--FontSize--md);
margin-right: var(--pf-global--spacer--sm);
svg {
fill: var(--pf-global--Color--100);
vertical-align: -0.125em;
}
}

&__title {
Expand Down
11 changes: 10 additions & 1 deletion frontend/packages/dev-console/src/components/add/AddCardItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@ type AddCardItemProps = {

const AddCardItem: React.FC<AddCardItemProps> = ({
action: {
properties: { id, label, icon, href, description },
properties: { id, label, icon, href, description, iconRenderAs },
},
namespace,
}) => {
const fireTelemetryEvent = useTelemetry();
const [showDetails] = useShowAddCardItemDetails();

const actionIcon = (): JSX.Element => {
if (typeof icon === 'string' && iconRenderAs === 'svg') {
return (
<span className="odc-add-card-item__icon" aria-hidden="true">
<svg viewBox="0 0 100 100" width="1.2em">
<use href={`${icon}#Layer_1`} />
</svg>
</span>
);
}
if (typeof icon === 'string') {
return <img className="odc-add-card-item__icon" src={icon} alt={label} aria-hidden="true" />;
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/packages/helm-plugin/console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@
"href": "/catalog/ns/:namespace?catalogType=HelmChart",
"label": "%helm-plugin~Helm Chart%",
"description": "%helm-plugin~Browse the catalog to discover and install Helm Charts%",
"icon": { "$codeRef": "helmUtils.helmCatalogIconSVG" }
"icon": { "$codeRef": "helmUtils.helmCatalogIconSVG" },
"iconRenderAs": "svg"
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions frontend/packages/knative-plugin/console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@
"label": "%knative-plugin~Broker%",
"description": "%knative-plugin~Create a Broker to define an event mesh for collecting a pool of events and route those events based on attributes, through triggers%",
"icon": { "$codeRef": "icons.channelIconSVG" },
"iconRenderAs": "svg",
"accessReview": [{ "group": "eventing.knative.dev", "resource": "brokers", "verb": "create" }]
}
},
Expand All @@ -481,6 +482,7 @@
"label": "%knative-plugin~Channel%",
"description": "%knative-plugin~Create a Knative Channel to create an event forwarding and persistence layer with in-memory and reliable implementations%",
"icon": { "$codeRef": "icons.channelIconSVG" },
"iconRenderAs": "svg",
"accessReview": [
{ "group": "eventing.knative.dev", "resource": "channels", "verb": "create" }
]
Expand Down
12 changes: 11 additions & 1 deletion frontend/packages/knative-plugin/src/imgs/channel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 23 additions & 1 deletion frontend/packages/pipelines-plugin/src/images/pipeline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions frontend/packages/rhoas-plugin/console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"label": "%rhoas-plugin~Managed Services%",
"description": "%rhoas-plugin~Discover managed services to simplify deployments and reduce operational overhead & complexities%",
"icon": { "$codeRef": "constants.cloudServicesIcon" },
"iconRenderAs": "svg",
"accessReview": [
{ "group": "apps.openshift.io", "resource": "deploymentconfigs", "verb": "create" },
{ "group": "route.openshift.io", "resource": "routes", "verb": "create" },
Expand Down
3 changes: 2 additions & 1 deletion frontend/public/imgs/logos/helm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 084aed5

Please sign in to comment.