2022-03-08 22:50:35 +01:00
import React from 'react' ;
2022-03-23 21:17:53 +01:00
import {
2022-09-14 16:55:31 +02:00
BUILT _IN _NETWORKS ,
NETWORK _TYPES ,
2022-03-23 21:17:53 +01:00
} from '../../../../shared/constants/network' ;
2023-08-29 01:06:56 +02:00
import { Severity , Size } from '../../../helpers/constants/design-system' ;
2022-03-23 21:17:53 +01:00
2023-08-29 01:06:56 +02:00
import { BannerAlert } from '../../component-library/banner-alert' ;
2022-03-08 22:50:35 +01:00
import NetworkDisplay from '.' ;
export default {
title : 'Components/App/NetworkDisplay' ,
2023-01-20 20:27:46 +01:00
2022-03-08 22:50:35 +01:00
argTypes : {
indicatorSize : {
2022-03-23 21:17:53 +01:00
control : 'select' ,
2023-02-02 21:15:26 +01:00
options : Object . values ( Size ) ,
2022-03-08 22:50:35 +01:00
} ,
labelProps : {
control : 'object' ,
} ,
2022-03-23 21:17:53 +01:00
targetNetwork : {
control : 'select' ,
2022-09-14 16:55:31 +02:00
options : [ ... Object . keys ( BUILT _IN _NETWORKS ) , NETWORK _TYPES . RPC ] ,
2022-03-08 22:50:35 +01:00
} ,
disabled : {
control : 'boolean' ,
} ,
onClick : {
action : 'onClick' ,
2022-03-23 21:17:53 +01:00
description :
'The onClick event handler of the NetworkDisplay. If it is not passed it is assumed that the NetworkDisplay SHOULD NOT be interactive and removes the caret and changes the border color of the NetworkDisplay to border-muted' ,
2022-03-08 22:50:35 +01:00
} ,
} ,
2022-03-23 21:17:53 +01:00
args : {
2022-09-29 05:26:01 +02:00
targetNetwork : 'goerli' ,
2022-03-23 21:17:53 +01:00
} ,
2022-03-08 22:50:35 +01:00
} ;
2022-03-23 21:17:53 +01:00
export const DefaultStory = ( args ) => (
2023-08-29 01:06:56 +02:00
< >
< BannerAlert
severity = { Severity . Warning }
title = "Deprecated"
description = " The < NetworkDisplay > component has been deprecated in favor of the new < PickerNetwork > component from the component - library .
Please update your code to use the new < PickerNetwork > component instead , which can be found at ui / components / component - library / picker - network / picker - network . tsx . "
actionButtonLabel = "See details"
actionButtonProps = { {
href : 'https://github.com/MetaMask/metamask-extension/issues/20485' ,
} }
marginBottom = { 4 }
/ >
< NetworkDisplay
{ ... args }
targetNetwork = { {
type : args . targetNetwork ,
nickname : args . targetNetwork ,
} }
/ >
< / >
2022-03-23 21:17:53 +01:00
) ;
2022-03-08 22:50:35 +01:00
DefaultStory . storyName = 'Default' ;
2022-03-23 21:17:53 +01:00
export const TargetNetwork = ( args ) => {
const targetNetworkArr = [
2022-09-14 16:55:31 +02:00
... Object . keys ( BUILT _IN _NETWORKS ) ,
NETWORK _TYPES . RPC ,
2022-03-23 21:17:53 +01:00
] ;
return (
< >
{ Object . values ( targetNetworkArr ) . map ( ( variant ) => (
< NetworkDisplay
{ ... args }
key = { variant }
targetNetwork = { {
type : variant ,
nickname : variant ,
} }
/ >
) ) }
< / >
) ;
} ;
export const DisplayOnly = ( args ) => {
const targetNetworkArr = [
2022-09-14 16:55:31 +02:00
... Object . keys ( BUILT _IN _NETWORKS ) ,
NETWORK _TYPES . RPC ,
2022-03-23 21:17:53 +01:00
] ;
return (
< >
{ Object . values ( targetNetworkArr ) . map ( ( variant ) => (
< NetworkDisplay
{ ... args }
key = { variant }
targetNetwork = { {
type : variant ,
nickname : variant ,
} }
onClick = { undefined }
/ >
) ) }
< / >
) ;
} ;