-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add rpc url and block explorer modals
- Loading branch information
Showing
7 changed files
with
257 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...onents/multichain/network-list-menu/add-block-explorer-modal/add-block-explorer-modal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { | ||
Box, | ||
ButtonPrimary, | ||
ButtonPrimarySize, | ||
FormTextField, | ||
FormTextFieldSize, | ||
HelpText, | ||
HelpTextSeverity, | ||
} from '../../../component-library'; | ||
import { | ||
BackgroundColor, | ||
BlockSize, | ||
BorderRadius, | ||
Display, | ||
FlexDirection, | ||
JustifyContent, | ||
TextVariant, | ||
} from '../../../../helpers/constants/design-system'; | ||
import { useI18nContext } from '../../../../hooks/useI18nContext'; | ||
import { isWebUrl } from '../../../../../app/scripts/lib/util'; | ||
|
||
const AddBlockExplorerModal = ({ | ||
onAdded, | ||
}: { | ||
onAdded: (url: string) => void; | ||
}) => { | ||
const t = useI18nContext(); | ||
const [url, setUrl] = useState<string>(); | ||
const [error, setError] = useState<string>(); | ||
|
||
useEffect(() => { | ||
if (url && url?.length > 0 && !isWebUrl(url)) { | ||
setError(t('urlErrorMsg')); | ||
} else { | ||
setError(undefined); | ||
} | ||
}, [url]); | ||
|
||
return ( | ||
<Box | ||
className="add-block-explorer-modal" | ||
display={Display.Flex} | ||
flexDirection={FlexDirection.Column} | ||
justifyContent={JustifyContent.spaceBetween} | ||
height={BlockSize.Full} | ||
> | ||
<Box paddingLeft={4} paddingRight={4}> | ||
<FormTextField | ||
size={FormTextFieldSize.Lg} | ||
textFieldProps={{ borderRadius: BorderRadius.LG }} | ||
error={Boolean(error)} | ||
id="additional-rpc-url" | ||
label={t('blockExplorerUrl')} | ||
inputProps={{ | ||
'data-testid': 'explorer-url-input', | ||
}} | ||
labelProps={{ | ||
children: undefined, | ||
variant: TextVariant.bodyMdMedium, | ||
}} | ||
onChange={(e) => setUrl(e.target.value)} | ||
/> | ||
{error && ( | ||
<HelpText severity={HelpTextSeverity.Danger}>{error}</HelpText> | ||
)} | ||
</Box> | ||
<Box | ||
className="add-block-explorer-modal__footer" | ||
backgroundColor={BackgroundColor.backgroundDefault} | ||
padding={4} | ||
width={BlockSize.Full} | ||
> | ||
<ButtonPrimary | ||
width={BlockSize.Full} | ||
disabled={Boolean(error)} | ||
size={ButtonPrimarySize.Lg} | ||
onClick={async () => { | ||
if (url) { | ||
onAdded(url); | ||
} | ||
}} | ||
> | ||
{t('addUrl')} | ||
</ButtonPrimary> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default AddBlockExplorerModal; |
9 changes: 9 additions & 0 deletions
9
ui/components/multichain/network-list-menu/add-block-explorer-modal/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.add-block-explorer-modal { | ||
overflow-y: auto; | ||
|
||
&__footer { | ||
position: sticky; | ||
bottom: 0; | ||
box-shadow: 0 0 8px 0 var(--color-shadow-default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 87 additions & 20 deletions
107
ui/components/multichain/network-list-menu/add-rpc-url-modal/add-rpc-url-modal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
ui/components/multichain/network-list-menu/add-rpc-url-modal/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.add-rpc-modal { | ||
overflow-y: auto; | ||
|
||
&__footer { | ||
position: sticky; | ||
bottom: 0; | ||
box-shadow: 0 0 8px 0 var(--color-shadow-default); | ||
} | ||
} |