Skip to content

Commit bb805e5

Browse files
committed
network: display testnet/regtest badge on Loop page
1 parent 691fd0a commit bb805e5

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

app/src/__tests__/components/loop/LoopPage.spec.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ describe('LoopPage component', () => {
2828
expect(getByText('Lightning Loop')).toBeInTheDocument();
2929
});
3030

31+
it('should display the network badge', () => {
32+
const { getByText, queryByText } = render();
33+
store.nodeStore.network = 'regtest';
34+
expect(getByText('regtest')).toBeInTheDocument();
35+
store.nodeStore.network = 'testnet';
36+
expect(getByText('testnet')).toBeInTheDocument();
37+
store.nodeStore.network = 'mainnet';
38+
expect(queryByText('mainnet')).not.toBeInTheDocument();
39+
});
40+
3141
it('should display the three tiles', () => {
3242
const { getByText } = render();
3343
expect(getByText('Loop History')).toBeInTheDocument();

app/src/components/base/shared.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ export const Pill = styled.span`
2525
border-radius: 40px;
2626
`;
2727

28+
export const Badge = styled.span`
29+
display: inline-block;
30+
margin-left: 10px;
31+
font-family: ${props => props.theme.fonts.open.light};
32+
font-size: ${props => props.theme.sizes.xxs};
33+
color: ${props => props.theme.colors.orange};
34+
border: 1px solid ${props => props.theme.colors.orange};
35+
border-radius: 4px;
36+
padding: 3px 5px 5px;
37+
text-transform: lowercase;
38+
line-height: 1;
39+
letter-spacing: 1.8px;
40+
`;
41+
2842
//
2943
// Button
3044
//

app/src/components/common/PageHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { ReactNode } from 'react';
22
import { observer } from 'mobx-react-lite';
33
import { usePrefixedTranslation } from 'hooks';
44
import { useStore } from 'store';
@@ -41,7 +41,7 @@ const Styled = {
4141
};
4242

4343
interface Props {
44-
title: string;
44+
title: ReactNode;
4545
onBackClick?: () => void;
4646
backText?: string;
4747
onHistoryClick?: () => void;

app/src/components/loop/LoopPage.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { observer } from 'mobx-react-lite';
33
import { usePrefixedTranslation } from 'hooks';
44
import { useStore } from 'store';
5+
import { Badge } from 'components/base';
56
import PageHeader from 'components/common/PageHeader';
67
import { styled } from 'components/theme';
78
import ChannelList from './ChannelList';
@@ -18,7 +19,18 @@ const Styled = {
1819

1920
const LoopPage: React.FC = () => {
2021
const { l } = usePrefixedTranslation('cmps.loop.LoopPage');
21-
const { uiStore, buildSwapStore, channelStore } = useStore();
22+
const { uiStore, buildSwapStore, channelStore, nodeStore } = useStore();
23+
24+
const title = (
25+
<>
26+
{l('pageTitle')}
27+
{nodeStore.network !== 'mainnet' && (
28+
<sup>
29+
<Badge>{nodeStore.network}</Badge>
30+
</sup>
31+
)}
32+
</>
33+
);
2234

2335
const { PageWrap } = Styled;
2436
return (
@@ -30,7 +42,7 @@ const LoopPage: React.FC = () => {
3042
) : (
3143
<>
3244
<PageHeader
33-
title={l('pageTitle')}
45+
title={title}
3446
onHistoryClick={uiStore.goToHistory}
3547
onExportClick={channelStore.exportChannels}
3648
/>

0 commit comments

Comments
 (0)