Skip to content

Commit

Permalink
Merge pull request #2154 from xmicha82/rm-unknown-icon
Browse files Browse the repository at this point in the history
fix(Shield): remove Unknown question mark icon
  • Loading branch information
johnsonm325 authored Feb 7, 2025
2 parents 7bdbc55 + 2095f46 commit e72ba9e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 2 additions & 3 deletions packages/components/doc/shield.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ Import Shield from this package.
import React from 'react';
import { Shield } from '@redhat-cloud-services/frontend-components';

class YourCmp extends React.Component {
render() {
const YourCmp = () => {
return (
<Shield impact={'Critical'} hasTooltip={true} size={'md'} />
)
}
}
```

Expand All @@ -32,6 +30,7 @@ You can also use all the props from Patternfly Tooltip component - [Documentatio
propTypes.number
]),
hasTooltip: propTypes.bool,
disableQuestionIcon: propTypes.bool
tooltipPosition: propTypes.string, // top, (right), bottom, left
tooltipPrefix: propTypes.string,
title: propTypes.string,
Expand Down
15 changes: 13 additions & 2 deletions packages/components/src/Shield/Shield.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,29 @@ export interface ShieldProps {
impact: keyof typeof impactList | 'N/A';
hasLabel?: boolean;
hasTooltip?: boolean;
disableQuestionIcon?: boolean;
size?: IconComponentProps['size'];
}

const Shield: React.FunctionComponent<ShieldProps> = ({ impact = 'N/A', hasLabel = false, size = 'md', hasTooltip = true }) => {
const Shield: React.FunctionComponent<ShieldProps> = ({
impact = 'N/A',
hasLabel = false,
size = 'md',
hasTooltip = true,
disableQuestionIcon = false,
}) => {
const attributes = impactList?.[impact as keyof typeof impactList] ?? impactList.Unknown;
const badgeProps: SVGIconProps = {
'aria-hidden': 'false',
'aria-label': attributes.title,
color: attributes.color,
};

const badge = <Icon size={size}>{attributes.title === 'Unknown' ? <QuestionIcon {...badgeProps} /> : <SecurityIcon {...badgeProps} />}</Icon>;
const badge = (
<Icon size={size}>
{attributes.title === 'Unknown' ? disableQuestionIcon ? null : <QuestionIcon {...badgeProps} /> : <SecurityIcon {...badgeProps} />}
</Icon>
);

const body = (
<span>
Expand Down

0 comments on commit e72ba9e

Please sign in to comment.