Skip to content

Commit 132e440

Browse files
committed
feat: Update Upstream info Icon in break state
1 parent ddc7a4c commit 132e440

3 files changed

Lines changed: 35 additions & 21 deletions

File tree

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
.upstream-info-icon {
2-
&.size-md {
2+
&.size-one-md {
33
width: 32px;
44
height: 26px;
55
}
66

7-
&.size-sm {
7+
&.size-one-sm {
88
width: 28px;
99
height: 22px;
1010
}
1111

12-
&.size-xs {
12+
&.size-one-xs {
1313
width: 24px;
1414
height: 18px;
1515
}
1616

17-
.pgn__icon {
18-
// Removes the right margin
19-
margin-right: 0 !important;
17+
&.size-two-md {
18+
width: 60px;
19+
height: 26px;
20+
}
21+
22+
&.size-two-sm {
23+
width: 46px;
24+
height: 22px;
25+
}
26+
27+
&.size-two-xs {
28+
width: 36px;
29+
height: 18px;
2030
}
21-
};
31+
}

src/generic/upstream-info-icon/UpstreamInfoIcon.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ describe('<UpstreamInfoIcon>', () => {
1616
it('should render with link', () => {
1717
renderComponent({ upstreamRef: 'some-ref', errorMessage: null });
1818
expect(screen.getByTitle('This item is linked to a library item.')).toBeInTheDocument();
19+
expect(screen.queryByTitle('The link to the library item is broken.')).not.toBeInTheDocument();
1920
});
2021

2122
it('should render with broken link', () => {
2223
renderComponent({ upstreamRef: 'some-ref', errorMessage: 'upstream error' });
24+
expect(screen.getByTitle('This item is linked to a library item.')).toBeInTheDocument();
2325
expect(screen.getByTitle('The link to the library item is broken.')).toBeInTheDocument();
2426
});
2527

src/generic/upstream-info-icon/index.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,27 @@ export const UpstreamInfoIcon: React.FC<UpstreamInfoIconProps> = ({ upstreamInfo
1919
return null;
2020
}
2121

22-
const iconProps = !upstreamInfo?.errorMessage
23-
? {
24-
title: intl.formatMessage(messages.upstreamLinkOk),
25-
ariaLabel: intl.formatMessage(messages.upstreamLinkOk),
26-
src: Newsstand,
27-
}
28-
: {
29-
title: intl.formatMessage(messages.upstreamLinkError),
30-
ariaLabel: intl.formatMessage(messages.upstreamLinkError),
31-
src: LinkOff,
32-
};
22+
let hasTwoIcons = false;
23+
if (upstreamInfo?.errorMessage) {
24+
hasTwoIcons = true;
25+
}
3326

3427
return (
35-
<div className={`upstream-info-icon size-${size} box-shadow-centered-1 d-flex justify-content-center`}>
28+
<div className={`upstream-info-icon size-${hasTwoIcons ? 'two' : 'one'}-${size} box-shadow-centered-1 d-flex justify-content-center`}>
3629
<Icon
37-
{...iconProps}
30+
title={intl.formatMessage(messages.upstreamLinkOk)}
31+
aria-label={intl.formatMessage(messages.upstreamLinkOk)}
32+
src={Newsstand}
3833
size={size}
39-
className="mr-1"
4034
/>
35+
{upstreamInfo?.errorMessage && (
36+
<Icon
37+
title={intl.formatMessage(messages.upstreamLinkError)}
38+
aria-label={intl.formatMessage(messages.upstreamLinkError)}
39+
src={LinkOff}
40+
size={size}
41+
/>
42+
)}
4143
</div>
4244
);
4345
};

0 commit comments

Comments
 (0)