Skip to content

Commit

Permalink
ControlsLabel: style: use info icons for description (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenjaneczek authored Mar 21, 2024
1 parent ef8ef64 commit d16d129
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/scenes/src/utils/ControlsLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ export function ControlsLabel(props: ControlsLabelProps) {
);
}

let descriptionIndicator = null;
if (props.description) {
descriptionIndicator = (
<Tooltip content={props.description} placement={isVertical ? 'top' : 'bottom'}>
<Icon className={styles.normalIcon} name="info-circle" />
</Tooltip>
);
}

const testId =
typeof props.label === 'string' ? selectors.pages.Dashboard.SubMenu.submenuItemLabels(props.label) : '';
let labelElement: JSX.Element;
Expand All @@ -57,6 +66,7 @@ export function ControlsLabel(props: ControlsLabelProps) {
labelElement = (
<label className={styles.verticalLabel} data-testid={testId} htmlFor={props.htmlFor}>
{props.label}
{descriptionIndicator}
{errorIndicator}
{props.icon && <Icon name={props.icon} className={styles.normalIcon} />}
{loadingIndicator}
Expand All @@ -71,19 +81,12 @@ export function ControlsLabel(props: ControlsLabelProps) {
{errorIndicator}
{props.icon && <Icon name={props.icon} className={styles.normalIcon} />}
{props.label}
{descriptionIndicator}
{loadingIndicator}
</label>
);
}

if (props.description) {
return (
<Tooltip content={props.description} placement={isVertical ? 'top' : 'bottom'}>
{labelElement}
</Tooltip>
);
}

return labelElement;
}

Expand Down

0 comments on commit d16d129

Please sign in to comment.