Skip to content

Commit a3fc3bd

Browse files
feat(js/frontend): improve faucet navigation UX (#805)
1 parent f96723e commit a3fc3bd

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

js/frontend/src/components/layout/header/consts.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { ROUTE } from '@/consts';
2+
import { NETWORK_TYPE } from '@/context/network-type';
23

34
const LINKS = {
45
[ROUTE.HOME]: 'Bridge',
56
[ROUTE.TRANSACTIONS]: 'Transactions',
6-
[ROUTE.TOKEN_TRACKER]: 'My Tokens',
7+
8+
[ROUTE.TOKEN_TRACKER]: {
9+
[NETWORK_TYPE.MAINNET]: 'My Tokens',
10+
[NETWORK_TYPE.TESTNET]: 'My Tokens & Faucet',
11+
},
12+
713
[ROUTE.FAQ]: 'FAQ',
814
} as const;
915

js/frontend/src/components/layout/header/header.module.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979

8080
justify-content: space-between;
8181
gap: 0;
82+
83+
font-size: 12px;
8284
}
8385

8486
&::before {

js/frontend/src/components/layout/header/header.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { Link, NavLink, useLocation } from 'react-router-dom';
33

44
import LogoSVG from '@/assets/logo.svg?react';
55
import { ROUTE } from '@/consts';
6+
import { useNetworkType } from '@/context/network-type';
67
import { TransactionsCounter } from '@/features/history';
78
import { NetworkSwitch } from '@/features/network-switch';
89
import { LockedBalanceTooltip } from '@/features/token-tracker';
910
import { Wallet } from '@/features/wallet';
1011
import { useAccountsConnection } from '@/hooks';
12+
import { isString } from '@/utils';
1113

1214
import { Container } from '../container';
1315

@@ -16,11 +18,13 @@ import styles from './header.module.scss';
1618

1719
function Header() {
1820
const { isAnyAccount } = useAccountsConnection();
21+
const { networkType } = useNetworkType();
1922

2023
const { pathname } = useLocation();
2124
const [linksStyle, setLinksStyle] = useState<CSSProperties>();
2225

2326
const linksRef = useRef<HTMLUListElement>(null);
27+
2428
const linkRefs = useRef<{ [key: string]: HTMLAnchorElement | null }>({
2529
[ROUTE.HOME]: null,
2630
[ROUTE.TRANSACTIONS]: null,
@@ -40,7 +44,7 @@ function Header() {
4044
'--active-link-width': `${linkRect.width}px`,
4145
'--active-link-offset': `${offset}px`,
4246
} as CSSProperties);
43-
}, [pathname, isAnyAccount]);
47+
}, [pathname, isAnyAccount, networkType]);
4448

4549
const renderLinks = () =>
4650
Object.entries(LINKS).map(([to, text]) => {
@@ -55,7 +59,7 @@ function Header() {
5559
return (
5660
<li key={to}>
5761
<NavLink to={to} className={styles.link} ref={setRef}>
58-
{text}
62+
{isString(text) ? text : text[networkType]}
5963
</NavLink>
6064

6165
{isTokensLink && <LockedBalanceTooltip />}

js/frontend/src/utils/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const asOptionalField = <T extends z.ZodTypeAny>(schema: T) => schema.or(z.liter
3737

3838
const isUndefined = (value: unknown): value is undefined => value === undefined;
3939
const isNull = (value: unknown): value is null => value === null;
40+
const isString = (value: unknown): value is string => typeof value === 'string';
4041
const isNumeric = (value: string) => /^\d+$/.test(value);
4142

4243
// asserts can't use arrow functions
@@ -67,6 +68,7 @@ export {
6768
asOptionalField,
6869
isUndefined,
6970
isNull,
71+
isString,
7072
isNumeric,
7173
getErrorMessage,
7274
definedAssert,

0 commit comments

Comments
 (0)