Grafana/ui: Fix margin in RadioButtonGroup option when only icon is present (#68899)

This commit is contained in:
Andrej Ocenas 2023-06-09 10:54:06 +02:00 committed by GitHub
parent 5d11def033
commit 417f6ceeb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,6 +75,7 @@ export function RadioButtonGroup<T>({
{options.map((opt, i) => {
const isItemDisabled = disabledOptions && opt.value && disabledOptions.includes(opt.value);
const icon = opt.icon ? toIconName(opt.icon) : undefined;
const hasNonIconPart = Boolean(opt.imgUrl || opt.label || opt.component);
return (
<RadioButton
@ -91,7 +92,7 @@ export function RadioButtonGroup<T>({
fullWidth={fullWidth}
ref={value === opt.value ? activeButtonRef : undefined}
>
{icon && <Icon name={icon} className={styles.icon} />}
{icon && <Icon name={icon} className={cx(hasNonIconPart && styles.icon)} />}
{opt.imgUrl && <img src={opt.imgUrl} alt={opt.label} className={styles.img} />}
{opt.label} {opt.component ? <opt.component /> : null}
</RadioButton>