Skip to content

Commit

Permalink
Merge branch 'main' into feat/issues-834-loader-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
begonaalvarezd authored Apr 19, 2024
2 parents d84ee5f + a225a88 commit bcaf95c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
3 changes: 2 additions & 1 deletion client/src/app/components/NetworkSwitcher.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
}

&.opened {
max-height: 1000px;
max-height: 80vh;
overflow-y: scroll;

@include desktop-down {
top: $navbar-height-mobile * 2;
Expand Down
23 changes: 19 additions & 4 deletions client/src/app/components/NetworkSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import classNames from "classnames";
import React, { Component, ReactNode } from "react";
import DevnetIcon from "~assets/devnet.svg?react";
import MainnetIcon from "~assets/mainnet.svg?react";
import ShimmerIcon from "~assets/shimmer-logo-header.svg?react";
import { NetworkSwitcherProps } from "./NetworkSwitcherProps";
import { getNetworkOrder } from "~helpers/networkHelper";
import { MAINNET } from "~models/config/networkType";
import { MAINNET, SHIMMER, NetworkType } from "~models/config/networkType";
import { CHRYSALIS, LEGACY, STARDUST } from "~models/config/protocolVersion";
import "./NetworkSwitcher.scss";

Expand All @@ -18,6 +19,22 @@ const PROTOCOL_VERIONS_TO_LABEL = {
* Component which will show the switcher.
*/
class NetworkSwitcher extends Component<NetworkSwitcherProps> {
/**
* Get the appropriate icon based on the network type.
* @param networkType The network type.
* @returns The icon component.
*/
getIcon(networkType: NetworkType) {
switch (networkType) {
case MAINNET:
return <MainnetIcon />;
case SHIMMER:
return <ShimmerIcon />;
default:
return <DevnetIcon />;
}
}

/**
* Render the component.
* @returns The node to render.
Expand Down Expand Up @@ -55,9 +72,7 @@ class NetworkSwitcher extends Component<NetworkSwitcherProps> {
className={classNames("network--card row middle", { selected: network.label === label })}
onClick={() => onChange(network.network)}
>
<div className="network--icon row middle center">
{network.network === MAINNET ? <MainnetIcon /> : <DevnetIcon />}
</div>
<div className="network--icon row middle center">{this.getIcon(network.network)}</div>
<div className="network--content">
<div className="label">{network.label}</div>
<div className="protocol">{PROTOCOL_VERIONS_TO_LABEL[network.protocolVersion]}</div>
Expand Down
19 changes: 12 additions & 7 deletions client/src/helpers/networkHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import {
CHRYSALIS_MAINNET,
CUSTOM,
DEVNET,
IOTA_TESTNET,
LEGACY_MAINNET,
MAINNET,
NetworkType,
SHIMMER,
SHIMMER_TESTNET,
TESTNET,
} from "~models/config/networkType";
import { SHIMMER_UI, Theme } from "~models/config/uiTheme";
Expand All @@ -21,27 +23,30 @@ export const getNetworkOrder = (networkType: NetworkType) => {
case MAINNET: {
return 0;
}
case CHRYSALIS_MAINNET: {
case SHIMMER: {
return 1;
}
case SHIMMER: {
case IOTA_TESTNET: {
return 2;
}
case TESTNET: {
case SHIMMER_TESTNET: {
return 3;
}
case ALPHANET: {
case DEVNET: {
return 4;
}
case LEGACY_MAINNET: {
case CHRYSALIS_MAINNET: {
return 5;
}
case DEVNET: {
case LEGACY_MAINNET: {
return 6;
}
default: {
case ALPHANET: {
return 7;
}
default: {
return 8;
}
}
};

Expand Down
4 changes: 4 additions & 0 deletions client/src/models/config/networkType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const MAINNET = "mainnet";
export const DEVNET = "devnet";
export const SHIMMER = "shimmer";
export const TESTNET = "testnet";
export const IOTA_TESTNET = "iota-testnet";
export const SHIMMER_TESTNET = "shimmer-testnet";
export const ALPHANET = "alphanet";
export const CUSTOM = "custom";

Expand All @@ -18,5 +20,7 @@ export type NetworkType =
| typeof DEVNET
| typeof SHIMMER
| typeof TESTNET
| typeof IOTA_TESTNET
| typeof SHIMMER_TESTNET
| typeof ALPHANET
| typeof CUSTOM;

0 comments on commit bcaf95c

Please sign in to comment.