Skip to content

Commit dcaa604

Browse files
Googlercopybara-github
authored andcommitted
Match journey graph nodes state background color to the UX mocks.
[mocks](https://www.figma.com/design/hjGhaADlX5DjElz8P8o9gE/GNP-journey-node-status-validation?node-id=903-21187&t=DbnW3pVRqFx54zeu-0) PiperOrigin-RevId: 831341679
1 parent 96b4b12 commit dcaa604

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/app/node.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ describe('DAG Node', () => {
141141
expect(createGroup).not.toThrow();
142142
});
143143

144+
it('Allows overriding the background color for the state badge',
145+
fakeAsync(async () => {
146+
const customBgColor = 'rgb(128, 0, 128)';
147+
const node = new DagNode('c', 'execution', 'FAILED', {
148+
options: {'stateBg': customBgColor},
149+
});
150+
fixture.componentInstance.fakeNode = node;
151+
152+
const stateElement = await harness.nodeStateElement();
153+
const style = await stateElement.getAttribute('style');
154+
expect(style).toContain(`background: ${customBgColor}`);
155+
}));
144156
});
145157

146158
describe('Internals', () => {

src/app/node.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ export class DagNodeEl implements OnInit, OnDestroy {
227227
icon ? fetchIcon(icon, key) : '';
228228

229229
isNoState = isNoState;
230-
bgForState = (state: NodeState) => bgForState(state, this.theme);
230+
bgForState = (state: NodeState) => {
231+
const stateBg = this.node?.options?.['stateBg'] as string | undefined;
232+
return stateBg ? stateBg : bgForState(state, this.theme);
233+
};
231234
iconForState = (state: NodeState) => iconForState(state, this.theme);
232235
isTextIcon = isTextIcon;
233236
convertStateToRuntime = convertStateToRuntime;

src/app/test_resources/node_harness.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ export class DagNodeElHarness extends ComponentHarness {
4747
MatIconHarness.with({selector: '.icon-space .icon.right .mat-icon'}))();
4848
}
4949

50+
/**
51+
* Returns the `<div>` element for the node state.
52+
*/
53+
async nodeStateElement(): Promise<TestElement> {
54+
return this.locatorFor('.icon-space.state')();
55+
}
56+
5057
/** Is the icon for the current node Text instead of SVG */
5158
async hasTextIcon() {
5259
const element =

0 commit comments

Comments
 (0)