-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from lidofinance/develop
Merge develop into main
- Loading branch information
Showing
12 changed files
with
121 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import { useErrorMessage } from 'modules/blockChain/hooks/useErrorMessage' | ||
|
||
import { Container } from '@lidofinance/lido-ui' | ||
import { Wrap } from './NetworkSwitcherStyle' | ||
import DangerIconSVG from 'assets/danger.com.svg.react' | ||
import { AttentionBanner } from 'modules/shared/ui/Common/AttentionBanner' | ||
|
||
export function NetworkSwitcher() { | ||
const errorMessage = useErrorMessage() | ||
|
||
return ( | ||
<Container size="full"> | ||
<Wrap> | ||
<DangerIconSVG /> | ||
<span>{errorMessage}</span> | ||
</Wrap> | ||
<AttentionBanner>{errorMessage}</AttentionBanner> | ||
</Container> | ||
) | ||
} |
20 changes: 0 additions & 20 deletions
20
modules/blockChain/ui/NetworkSwitcher/NetworkSwitcherStyle.ts
This file was deleted.
Oops, something went wrong.
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
16 changes: 16 additions & 0 deletions
16
modules/shared/ui/Common/AttentionBanner/AttentionBanner.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,16 @@ | ||
import { Wrap } from './AttentionBannerStyle' | ||
import DangerIconSVG from 'assets/danger.com.svg.react' | ||
|
||
type Props = { | ||
type?: 'error' | 'warning' | ||
children?: React.ReactNode | ||
} | ||
|
||
export const AttentionBanner = ({ type = 'warning', children }: Props) => { | ||
return ( | ||
<Wrap type={type}> | ||
<DangerIconSVG /> | ||
<span>{children}</span> | ||
</Wrap> | ||
) | ||
} |
52 changes: 52 additions & 0 deletions
52
modules/shared/ui/Common/AttentionBanner/AttentionBannerStyle.ts
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,52 @@ | ||
import styled, { css } from 'styled-components' | ||
|
||
type WrapProps = { | ||
type: 'error' | 'warning' | ||
} | ||
|
||
export const Wrap = styled.div<WrapProps>` | ||
display: flex; | ||
align-items: center; | ||
margin-bottom: ${({ theme }) => theme.spaceMap.xxl}px; | ||
padding: ${({ theme }) => theme.spaceMap.lg}px; | ||
font-size: ${({ theme }) => theme.fontSizesMap.xxs}px; | ||
font-weight: 400; | ||
border-radius: ${({ theme }) => theme.borderRadiusesMap.md}px; | ||
& svg { | ||
display: block; | ||
flex: 0 0 auto; | ||
margin-right: ${({ theme }) => theme.spaceMap.sm}px; | ||
fill: var(--lido-color-textDark); | ||
} | ||
${({ type }) => | ||
type === 'error' && | ||
css` | ||
background-color: var(--lido-color-error); | ||
&, | ||
& a { | ||
color: var(--lido-color-errorContrast); | ||
} | ||
& svg { | ||
fill: var(--lido-color-errorContrast); | ||
} | ||
`} | ||
${({ type }) => | ||
type === 'warning' && | ||
css` | ||
background-color: var(--lido-color-warningBackground); | ||
&, | ||
& a { | ||
color: var(--lido-color-textDark); | ||
} | ||
& svg { | ||
fill: var(--lido-color-textDark); | ||
} | ||
`} | ||
` |
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 @@ | ||
export * from './AttentionBanner' |
32 changes: 32 additions & 0 deletions
32
modules/shared/ui/Common/FetchErrorBanner/FetchErrorBanner.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,32 @@ | ||
import Link from 'next/link' | ||
import { AttentionBanner } from '../AttentionBanner' | ||
import { ErrorMessageDisplayText } from 'modules/shared/utils/getErrorMessage' | ||
import * as urls from 'modules/network/utils/urls' | ||
|
||
type Props = { | ||
error: unknown | ||
} | ||
|
||
export const FetchErrorBanner = ({ error }: Props) => { | ||
let topLine = 'There is a problem with rpc node currently in use.' | ||
|
||
if ( | ||
error && | ||
typeof error === 'object' && | ||
'code' in error && | ||
error.code === 429 | ||
) { | ||
topLine = ErrorMessageDisplayText.RPC_TOO_MANY_REQUESTS | ||
} | ||
|
||
return ( | ||
<AttentionBanner type="error"> | ||
{topLine} | ||
<br /> | ||
You can set your own url on <Link href={urls.settings}> | ||
settings | ||
</Link>{' '} | ||
page. | ||
</AttentionBanner> | ||
) | ||
} |
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 @@ | ||
export * from './FetchErrorBanner' |
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
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