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

Widget UI 7 #3251

Merged
merged 35 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2a1111d
feat: widget init mods
Sep 28, 2023
d6e6a76
feat: widget menu links
Sep 29, 2023
fc0113f
feat: select menu
Oct 3, 2023
6962653
feat: select menu
Oct 3, 2023
cd00476
feat: select menu
Oct 3, 2023
26de84c
Update apps/cowswap-frontend/src/modules/trade/containers/TradeWidget…
fairlighteth Oct 3, 2023
bac8ade
feat: fix semicolons
fairlighteth Oct 3, 2023
07ea891
feat: menu styling
fairlighteth Oct 3, 2023
3b76433
feat: general styling
fairlighteth Oct 9, 2023
a343871
feat: connect wallet internal
fairlighteth Oct 10, 2023
fe89695
feat: connect wallet internal
fairlighteth Oct 10, 2023
f931b09
feat: connect wallet internal
fairlighteth Oct 10, 2023
9180d5e
feat: widget configurator app
fairlighteth Oct 10, 2023
d96c8c7
feat: widget configurator app
fairlighteth Oct 11, 2023
c23d531
feat: widget configurator app
fairlighteth Oct 12, 2023
30565eb
feat: widget configurator app
fairlighteth Oct 12, 2023
64c8533
feat: widget configurator app
fairlighteth Oct 12, 2023
d0b064e
feat: widget configurator app
fairlighteth Oct 12, 2023
6c39e14
feat: widget configurator app
fairlighteth Oct 12, 2023
8638950
feat: widget configurator app
fairlighteth Oct 12, 2023
790abd0
feat: widget configurator app
fairlighteth Oct 13, 2023
65c6f00
feat: widget configurator app
fairlighteth Oct 16, 2023
527108a
Merge branch 'develop' into widget-ui-6
fairlighteth Oct 16, 2023
a133ca5
feat: widget configurator app
fairlighteth Oct 16, 2023
0abd19e
refactor: extract AccountElement and AccountModalState
shoom3301 Oct 18, 2023
964aaa2
feat: update theme
fairlighteth Oct 18, 2023
9374bf8
feat: update modalheader
fairlighteth Oct 18, 2023
7e8aa60
feat: update modalheader
fairlighteth Oct 18, 2023
4047b4b
Merge branch 'widget-ui-6' into widget-ui-7
fairlighteth Oct 18, 2023
e47fcb6
feat: update modalheader
fairlighteth Oct 18, 2023
3833a91
feat: refactor code
fairlighteth Oct 19, 2023
6e1716c
feat: iframe resizer
fairlighteth Oct 19, 2023
20ad131
Merge branch 'develop' into widget-ui-7
fairlighteth Oct 20, 2023
76c2fba
feat: update
fairlighteth Oct 20, 2023
4b16986
feat: powered by footer (#3254)
fairlighteth Oct 20, 2023
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
1 change: 1 addition & 0 deletions apps/cowswap-frontend/src/assets/icon/carret.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/src/assets/icon/gas-free.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/cowswap-frontend/src/assets/icon/wallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/cowswap-frontend/src/common/constants/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export enum UI {

// Icons
ICON_SIZE_NORMAL = '--cow-icon-size-normal',
ICON_SIZE_SMALL = '--cow-icon-size-small',
ICON_SIZE_XSMALL = '--cow-icon-size-xsmall',
ICON_SIZE_LARGE = '--cow-icon-size-large',
ICON_COLOR_NORMAL = '--cow-icon-color-normal',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,19 @@ export const StepsWrapper = styled.div`
margin: auto;
position: absolute;
width: 100%;
max-width: 162px;
max-width: 35%;
left: 0;
right: 0;
top: 32px;
z-index: 1;

${({ theme }) => theme.mediaWidth.upToSmall`
max-width: 25%;
`}

${({ theme }) => theme.mediaWidth.upToVerySmall`
max-width: 20%;
`}
}

> hr::before {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ReactComponent as DropDown } from '@cowprotocol/assets/images/dropdown.
import { lighten, transparentize } from 'polished'
import styled from 'styled-components/macro'

import { UI } from 'common/constants/theme'

export const CurrencySelectWrapper = styled.button<{ isLoading: boolean; $stubbed: boolean; readonlyMode: boolean }>`
display: flex;
justify-content: space-between;
Expand All @@ -19,7 +21,7 @@ export const CurrencySelectWrapper = styled.button<{ isLoading: boolean; $stubbe
: `0px 4px 8px ${transparentize(0.96, theme.text1)}`};
opacity: ${({ isLoading }) => (isLoading ? 0.6 : 1)};
pointer-events: ${({ readonlyMode }) => (readonlyMode ? 'none' : '')};
border-radius: 16px;
border-radius: var(${UI.BORDER_RADIUS_NORMAL});
padding: 6px;
transition: background-color 0.15s ease-in-out;
max-width: 190px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ModalContentWrapper = styled.div`
padding: 24px;
color: var(${UI.COLOR_TEXT2});
background-color: var(${UI.COLOR_CONTAINER_BG_01});
border-radius: 24px;
border-radius: var(${UI.BORDER_RADIUS_NORMAL});

> p {
line-height: 1.4;
Expand Down
16 changes: 12 additions & 4 deletions apps/cowswap-frontend/src/cow-react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Provider as AtomProvider } from 'jotai'
import { StrictMode } from 'react'

import { BlockNumberProvider } from '@cowprotocol/common-hooks'
import { isInjectedWidget } from '@cowprotocol/common-utils'
import { nodeRemoveChildFix } from '@cowprotocol/common-utils'
import { jotaiStore } from '@cowprotocol/core'
import { SnackbarsWidget } from '@cowprotocol/snackbars'
Expand Down Expand Up @@ -41,6 +42,7 @@ if (window.ethereum) {
}

const root = createRoot(document.getElementById('root')!)
const isInjectedWidgetMode = isInjectedWidget()

root.render(
<StrictMode>
Expand All @@ -56,12 +58,18 @@ root.render(
<BlockNumberProvider>
<WithLDProvider>
<Updaters />
<FeatureGuard featureFlag="cowFortuneEnabled">
<FortuneWidget />
</FeatureGuard>

{!isInjectedWidgetMode && (
<>
<FeatureGuard featureFlag="cowFortuneEnabled">
<FortuneWidget />
</FeatureGuard>
<AppziButton />
</>
)}

<Popups />
<SnackbarsWidget />
<AppziButton />
<App />
</WithLDProvider>
</BlockNumberProvider>
Expand Down
5 changes: 3 additions & 2 deletions apps/cowswap-frontend/src/legacy/components/Copy/CopyMod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { UI } from 'common/constants/theme'

// MOD imports
export const CopyIcon = styled(LinkStyledButton)`
--iconSize: var(${UI.ICON_SIZE_NORMAL});
color: ${({ theme }) => theme.text3};
flex-shrink: 0;
display: flex;
Expand All @@ -22,8 +23,8 @@ export const CopyIcon = styled(LinkStyledButton)`
font-size: 0.825rem;
border-radius: 50%;
background-color: transparent;
min-width: 20px;
min-height: 20px;
min-width: var(--iconSize);
min-height: var(--iconSize);
align-self: flex-end;
:hover,
:active,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { ErrorInfo, PropsWithChildren } from 'react'

import { sendError } from '@cowprotocol/analytics'
import { isInjectedWidget } from '@cowprotocol/common-utils'

import * as Sentry from '@sentry/react'
import styled from 'styled-components/macro'


import { ChunkLoadError } from 'legacy/components/ErrorBoundary/ChunkLoadError'
import { ErrorWithStackTrace } from 'legacy/components/ErrorBoundary/ErrorWithStackTrace'
import Footer from 'legacy/components/Footer'
Expand Down Expand Up @@ -128,6 +130,8 @@ export default class ErrorBoundary extends React.Component<PropsWithChildren, Er

return (
<AppWrapper>

{!isInjectedWidget() &&
<HeaderWrapper>
<HeaderRow marginRight="0">
<a href={Routes.HOME}>
Expand All @@ -137,6 +141,8 @@ export default class ErrorBoundary extends React.Component<PropsWithChildren, Er
</a>
</HeaderRow>
</HeaderWrapper>
}

<Wrapper>{isChunkLoadError ? <ChunkLoadError /> : <ErrorWithStackTrace error={error} />}</Wrapper>
<FooterWrapper>
<Footer />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react'

import { NATIVE_CURRENCY_BUY_TOKEN } from '@cowprotocol/common-const'
import { TokenAmount } from '@cowprotocol/ui'
import { useWalletInfo } from '@cowprotocol/wallet'

import { useToggleAccountModal } from 'modules/account'
import { useNativeCurrencyBalances } from 'modules/tokens/hooks/useCurrencyBalance'
import { Web3Status } from 'modules/wallet/containers/Web3Status'

import { useIsProviderNetworkUnsupported } from 'common/hooks/useIsProviderNetworkUnsupported'

import { Wrapper, BalanceText } from './styled'

interface AccountElementProps {
pendingActivities: string[]
isWidgetMode?: boolean
className?: string
}

export function AccountElement({ className, isWidgetMode, pendingActivities }: AccountElementProps) {
const { account, chainId } = useWalletInfo()
const isChainIdUnsupported = useIsProviderNetworkUnsupported()
const userEthBalance = useNativeCurrencyBalances(account ? [account] : [])?.[account ?? '']
const toggleAccountModal = useToggleAccountModal()
const nativeToken = NATIVE_CURRENCY_BUY_TOKEN[chainId].symbol

return (
<Wrapper className={className} active={!!account} onClick={() => account && toggleAccountModal()}>
{!isWidgetMode && account && !isChainIdUnsupported && userEthBalance && chainId && (
<BalanceText>
<TokenAmount amount={userEthBalance} tokenSymbol={{ symbol: nativeToken }} />
</BalanceText>
)}
<Web3Status pendingActivities={pendingActivities} />
</Wrapper>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { transparentize } from 'polished'
import { Text } from 'rebass'
import styled from 'styled-components/macro'

export const BalanceText = styled(Text)`
font-weight: 500;
font-size: 13px;
padding: 0 6px 0 12px;
min-width: initial;

${({ theme }) => theme.mediaWidth.upToExtraSmall`
display: none;
`};

${({ theme }) => theme.mediaWidth.upToMedium`
overflow: hidden;
max-width: 100px;
text-overflow: ellipsis;
`};

${({ theme }) => theme.mediaWidth.upToSmall`
display: none;
`};
`

export const Wrapper = styled.div<{ active: boolean }>`
display: flex;
flex-direction: row;
align-items: center;
background-color: ${({ theme, active }) => (!active ? theme.bg1 : theme.bg3)};
white-space: nowrap;
cursor: pointer;
background-color: ${({ theme, active }) => (!active ? theme.bg1 : theme.bg1)};
border-radius: 21px;
border: 2px solid transparent;
transition: border 0.2s ease-in-out;
pointer-events: auto;
width: auto;

:focus {
border: 1px solid blue;
}

&:hover {
border: 2px solid ${({ theme }) => transparentize(0.7, theme.text1)};
}

${({ theme }) => theme.mediaWidth.upToMedium`
height: 100%;
`}

${({ theme }) =>
theme.isInjectedWidgetMode &&
`
margin: 0 20px 0 auto!important;
border: 0!important;
`}
`
Loading
Loading