-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v5.3.12
- Loading branch information
Showing
147 changed files
with
2,959 additions
and
2,890 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,99 @@ | ||
import { useState } from 'react'; | ||
import { toast, ToastContainer } from 'react-toastify'; | ||
import styled, { useTheme } from 'styled-components'; | ||
|
||
import ErrorIcon from 'assets/svg/app/error.svg'; | ||
import { truncateString } from 'utils/formatters/string'; | ||
|
||
function ToastContent({ message, error }: { message: string; error?: Error }) { | ||
const [expanded, setExpanded] = useState(false); | ||
if (!error) return <>{message}</>; | ||
return ( | ||
<div> | ||
<div>{message}</div> | ||
<TextButton onClick={() => setExpanded(!expanded)}> | ||
{expanded ? 'Hide' : 'Show'} Details | ||
</TextButton> | ||
{expanded ? <ErrorDetails>{error.message}</ErrorDetails> : null} | ||
</div> | ||
); | ||
} | ||
|
||
export const notifyError = (message: string, error?: Error) => { | ||
const formatted = formatError(message); | ||
const truncated = truncateString(formatted); | ||
toast.error(<ToastContent message={truncated} error={error} />, { | ||
position: toast.POSITION.TOP_RIGHT, | ||
toastId: truncated, | ||
containerId: 'errors', | ||
}); | ||
}; | ||
|
||
export default function ErrorNotifier() { | ||
const theme = useTheme(); | ||
return ( | ||
<StyledToastContainer | ||
icon={() => <ErrorIcon fill={theme.colors.selectedTheme.red} />} | ||
enableMultiContainer | ||
containerId="errors" | ||
position="top-right" | ||
autoClose={5000} | ||
hideProgressBar={false} | ||
newestOnTop={false} | ||
closeOnClick={false} | ||
rtl={false} | ||
pauseOnFocusLoss | ||
pauseOnHover | ||
/> | ||
); | ||
} | ||
|
||
const formatError = (message: string) => { | ||
if (!message) return ''; | ||
if (message.includes('insufficient funds for intrinsic transaction cost')) | ||
return 'Insufficient ETH balance for gas cost'; | ||
return message; | ||
}; | ||
|
||
const StyledToastContainer = styled(ToastContainer)` | ||
.Toastify__toast-container { | ||
border-radius: 4px; | ||
} | ||
.Toastify__toast { | ||
border: ${(props) => props.theme.colors.selectedTheme.border}; | ||
background: ${(props) => props.theme.colors.selectedTheme.button.fill}; | ||
color: ${(props) => props.theme.colors.selectedTheme.button.text.primary}; | ||
} | ||
.Toastify__toast-body { | ||
font-family: ${(props) => props.theme.fonts.regular}; | ||
font-size: 13px; | ||
line-height: 13px; | ||
overflow-wrap: break-word; | ||
word-break: break-word; | ||
} | ||
.Toastify__progress-bar { | ||
background: ${(props) => props.theme.colors.selectedTheme.red}; | ||
} | ||
.Toastify__close-button > svg { | ||
fill: white; | ||
} | ||
`; | ||
|
||
// TODO: Use re-useable component once merged with component refactor | ||
|
||
const TextButton = styled.div` | ||
text-decoration: underline; | ||
font-size: 13px; | ||
margin-top: 6px; | ||
line-height: 11px; | ||
color: ${(props) => props.theme.colors.selectedTheme.gray}; | ||
background-color: transparent; | ||
border: none; | ||
cursor: pointer; | ||
`; | ||
|
||
const ErrorDetails = styled.div` | ||
margin-top: 8px; | ||
font-size: 11px; | ||
color: ${(props) => props.theme.colors.selectedTheme.gray}; | ||
`; |
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
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,9 +1,8 @@ | ||
// Shows or hides the home page banner entirely when set to true/false | ||
export const BANNER_ENABLED = false; | ||
export const BANNER_ENABLED = true; | ||
// Sets the link destination for the banner component, or renders the banner as | ||
// plain, un-clickable text if set to a falsey value (`false`, `null`, '', etc...) | ||
export const BANNER_LINK_URL = | ||
'https://snapshot.org/#/kwenta.eth/proposal/0x4a2dbd3839de2b6407ebbdc47e7d51a5d69f3363a803a93ffd8cf4e5d08011ff'; | ||
export const BANNER_LINK_URL = 'https://docs.kwenta.io/overview/kwenta-futures-v1-deprecation'; | ||
// Sets the text displayed on the home page banner | ||
export const BANNER_TEXT = | ||
'Council elections are live on Snapshot until Nov 29th. $KWENTA stakers go cast your vote!'; | ||
'Attention! Perps (V1) will be phased out in favor of the upgraded version (V2) in the near future. Click for info.'; |
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 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
Oops, something went wrong.
bfa6cd3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
kwenta – ./
kwenta-git-main-kwenta.vercel.app
kwenta-kwenta.vercel.app
kwenta.io
dev.kwenta.io