Skip to content

Commit 652ea5b

Browse files
committed
fix(ui): align Carbon icons after PatternFly icon migration
1 parent 829fa65 commit 652ea5b

5 files changed

Lines changed: 48 additions & 16 deletions

File tree

‎packages/ui/src/components/Visualization/Canvas/Canvas.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import './Canvas.scss';
22

3-
import { Catalog, FitToScreen, Network_2, ZoomIn, ZoomOut } from '@carbon/icons-react';
3+
import { Catalog, FitToScreen, Network_2 as NetworkIcon, ZoomIn, ZoomOut } from '@carbon/icons-react';
44
import {
55
action,
66
createTopologyControlButtons,
@@ -172,7 +172,7 @@ export const Canvas: FunctionComponent<PropsWithChildren<CanvasProps>> = ({
172172
customButtons.push(
173173
{
174174
id: 'topology-control-bar-h_layout-button',
175-
icon: <Network_2 />,
175+
icon: <NetworkIcon />,
176176
tooltip: 'Layout nodes horizontally',
177177
callback: action(() => {
178178
localStorage.setItem(LocalStorageKeys.CanvasLayout, LayoutType.DagreHorizontal);
@@ -182,7 +182,7 @@ export const Canvas: FunctionComponent<PropsWithChildren<CanvasProps>> = ({
182182
},
183183
{
184184
id: 'topology-control-bar-v_layout-button',
185-
icon: <Network_2 className="canvas-layout-icon-vertical" />,
185+
icon: <NetworkIcon className="canvas-layout-icon-vertical" />,
186186
tooltip: 'Layout nodes vertically',
187187
callback: action(() => {
188188
localStorage.setItem(LocalStorageKeys.CanvasLayout, LayoutType.DagreVertical);

‎packages/ui/src/components/Visualization/Canvas/CanvasToolbar/StepToolbar.tsx‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export const StepToolbar: FunctionComponent<IStepToolbar> = ({
145145

146146
{canBeDisabled && (
147147
<Button
148+
icon={isDisabled ? <Checkmark /> : <ErrorIcon />}
148149
className="step-toolbar__button"
149150
data-testid={`${label}|step-toolbar-button-disable`}
150151
variant="control"
@@ -153,9 +154,7 @@ export const StepToolbar: FunctionComponent<IStepToolbar> = ({
153154
event.stopPropagation();
154155
onToggleDisableNode();
155156
}}
156-
>
157-
{isDisabled ? <Checkmark /> : <ErrorIcon />}
158-
</Button>
157+
/>
159158
)}
160159

161160
{areMultipleStepsDisabled && (
@@ -188,6 +187,7 @@ export const StepToolbar: FunctionComponent<IStepToolbar> = ({
188187

189188
{onCollapseToggle && (
190189
<Button
190+
icon={isCollapsed ? <Maximize /> : <Minimize />}
191191
className="step-toolbar__button"
192192
data-testid={`${label}|step-toolbar-button-collapse`}
193193
variant="control"
@@ -196,9 +196,7 @@ export const StepToolbar: FunctionComponent<IStepToolbar> = ({
196196
event.stopPropagation();
197197
onCollapseToggle();
198198
}}
199-
>
200-
{isCollapsed ? <Maximize /> : <Minimize />}
201-
</Button>
199+
/>
202200
)}
203201

204202
{canRemoveStep && (

‎packages/ui/src/components/Visualization/ContextToolbar/Flows/FlowsMenu.tsx‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './FlowsMenu.scss';
22

33
import { List } from '@carbon/icons-react';
4-
import { Badge, Icon, MenuToggle, MenuToggleElement, Select } from '@patternfly/react-core';
4+
import { Badge, MenuToggle, MenuToggleElement, Select } from '@patternfly/react-core';
55
import { FunctionComponent, Ref, useContext, useState } from 'react';
66

77
import { getVisibleFlowsInformation } from '../../../../models/visualization/flows/support/flows-visibility';
@@ -25,14 +25,12 @@ export const FlowsMenu: FunctionComponent = () => {
2525
className="flows-menu"
2626
ref={toggleRef}
2727
onClick={onToggleClick}
28+
icon={<List />}
2829
>
29-
<Icon isInline>
30-
<List />
31-
</Icon>
3230
<span
3331
title={singleFlowId ?? 'Routes'}
3432
data-testid="flows-list-route-id"
35-
className="pf-v6-u-m-sm flows-menu-display"
33+
className="flows-menu-display"
3634
>
3735
{`${singleFlowId ?? 'Routes'}`}
3836
</span>

‎packages/ui/src/components/Visualization/ContextToolbar/NewEntity/NewEntity.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ export const NewEntity: FunctionComponent = () => {
8989
setIsOpen(!isOpen);
9090
}}
9191
isExpanded={isOpen}
92+
icon={<Add />}
9293
>
93-
<Add />
94-
<span className="pf-v6-u-m-sm">New</span>
94+
New
9595
</MenuToggle>
9696
}
9797
toggleRef={toggleRef}

‎packages/ui/src/styles/carbon-overrides.scss‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,39 @@ body {
125125
.pf-v6-c-form__label-text {
126126
--pf-v6-c-form__label-text--FontWeight: var(--pf-t--global--font--weight--400);
127127
}
128+
129+
/*
130+
PatternFly components align their children on the text baseline and relied on the
131+
PatternFly icons being 1em SVGs with `vertical-align: -0.125em`. Carbon icons are
132+
fixed-size SVGs without that offset, so they ride high next to the label.
133+
Center the element that holds the icon instead of depending on baselines:
134+
- `__icon`: the wrapper Button, MenuToggle, ToggleGroupItem and Label render for their `icon` prop.
135+
- the topology control bar passes its icon as a bare child, so it lands in `__text`.
136+
*/
137+
/* stylelint-disable selector-class-pattern */
138+
.pf-v6-c-button .pf-v6-c-button__icon,
139+
.pf-v6-c-menu-toggle .pf-v6-c-menu-toggle__icon,
140+
.pf-v6-c-toggle-group .pf-v6-c-toggle-group__icon,
141+
.pf-v6-c-label .pf-v6-c-label__icon,
142+
.pf-topology-control-bar__button .pf-v6-c-button__text {
143+
display: flex;
144+
align-items: center;
145+
align-self: center;
146+
justify-content: center;
147+
148+
/*
149+
Keep the line box the icon used to occupy so icon-only buttons don't shrink to the 16px glyph.
150+
`--pf-v6-c-button--LineHeight` is only defined inside buttons, hence the global fallback.
151+
*/
152+
min-block-size: calc(1em * var(--pf-v6-c-button--LineHeight, var(--pf-t--global--font--line-height--body)));
153+
}
154+
155+
/*
156+
Topology context menu items render `<Icon /> Label` as plain children, so the icon lands inline in
157+
`__item-text` instead of in a dedicated icon slot. Restore the baseline offset the PatternFly icons
158+
carried; a flex layout is avoided to keep the text ellipsis and the existing spacing untouched.
159+
*/
160+
.pf-topology-context-menu__c-dropdown__menu .pf-v6-c-menu__item-text > svg {
161+
vertical-align: -0.125em;
162+
}
163+
/* stylelint-enable selector-class-pattern */

0 commit comments

Comments
 (0)