Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: style TWAP warning banner #5204

Open
wants to merge 1 commit into
base: feat/twap-fbh-warning
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useSetAtom } from 'jotai/index'
import { useEffect, useState } from 'react'

import { usePrevious } from '@cowprotocol/common-hooks'
import { ButtonPrimary, InlineBanner, Loader } from '@cowprotocol/ui'
import { ButtonPrimary, InlineBanner, Loader, BannerOrientation, UI } from '@cowprotocol/ui'
import { useWalletInfo } from '@cowprotocol/wallet'

import styled from 'styled-components/macro'
Expand All @@ -15,13 +15,47 @@ import { verifyExtensibleFallback } from '../../services/verifyExtensibleFallbac
import { updateFallbackHandlerVerificationAtom } from '../../state/fallbackHandlerVerificationAtom'

const Banner = styled(InlineBanner)`
margin-bottom: 20px;
/* TODO: Make all these part of the InlineBanner props */
position: relative;
font-size: 15px;

> span {
gap: 20px;
}

> span > span {
gap: 20px;
}

&::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: var(${UI.COLOR_PAPER});
z-index: -1;
border-radius: inherit;
}

&::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: inherit;
z-index: -1;
border-radius: inherit;
}
`

const ActionButton = styled(ButtonPrimary)`
display: inline-block;
width: auto;
font-size: 15px;
width: 100%;
font-size: 16px;
padding: 16px 24px;
min-height: auto;
`
Expand Down Expand Up @@ -58,14 +92,23 @@ export function SetupFallbackHandlerWarning() {
}, [txWasMined, account, extensibleFallbackContext, updateFallbackHandlerVerification])

return (
<Banner bannerType="danger">
<p>
Your Safe fallback handler was changed after TWAP orders ware placed. All open TWAP orders are not getting
created because of that. Please, update the fallback handler in order to make the orders work again.
</p>
<ActionButton disabled={isTransactionPending} onClick={handleUpdateClick}>
{isTransactionPending ? <Loader /> : 'Update fallback handler'}
</ActionButton>
<Banner
bannerType="danger"
backDropBlur
orientation={BannerOrientation.Horizontal}
iconSize={46}
noWrapContent
padding="20px"
>
<span>
<p>
Your Safe fallback handler was changed after TWAP orders ware placed. All open TWAP orders are not getting
created because of that. Please, update the fallback handler in order to make the orders work again.
</p>
<ActionButton disabled={isTransactionPending} onClick={handleUpdateClick}>
{isTransactionPending ? <Loader /> : 'Update fallback handler'}
</ActionButton>
</span>
</Banner>
)
}
Expand Down
5 changes: 2 additions & 3 deletions apps/cowswap-frontend/src/pages/AdvancedOrders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default function AdvancedOrdersPage() {
<SetupAdvancedOrderAmountsFromUrlUpdater />
<styledEl.PageWrapper isUnlocked={isUnlocked}>
<styledEl.PrimaryWrapper>
{isFallbackHandlerRequired && allEmulatedOrders.length > 0 && <SetupFallbackHandlerWarning />}
<AdvancedOrdersWidget
updaters={<TwapUpdaters />}
confirmContent={<TwapConfirmModal />}
Expand All @@ -65,9 +66,7 @@ export default function AdvancedOrdersPage() {
displayOrdersOnlyForSafeApp={true}
orderType={TabOrderTypes.ADVANCED}
orders={allEmulatedOrders}
>
{isFallbackHandlerRequired && allEmulatedOrders.length > 0 && <SetupFallbackHandlerWarning />}
</OrdersTableWidget>
/>
)}
</styledEl.SecondaryWrapper>
</styledEl.PageWrapper>
Expand Down
Loading