-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: widget init mods * feat: widget menu links * feat: select menu * feat: select menu * feat: select menu * Update apps/cowswap-frontend/src/modules/trade/containers/TradeWidget/index.tsx Co-authored-by: Alexandr Kazachenko <[email protected]> * feat: fix semicolons * feat: menu styling * feat: general styling * feat: connect wallet internal * feat: connect wallet internal * feat: connect wallet internal * feat: widget configurator app * feat: widget configurator app * feat: widget configurator app * feat: widget configurator app * feat: widget configurator app * feat: widget configurator app * feat: widget configurator app * feat: widget configurator app * feat: widget configurator app * feat: widget configurator app * feat: widget configurator app * refactor: extract AccountElement and AccountModalState * chore: update yarn.lock * chore: fix code style --------- Co-authored-by: Michel <[email protected]> Co-authored-by: Alexandr Kazachenko <[email protected]>
- Loading branch information
1 parent
ea85d84
commit 1a2c1de
Showing
68 changed files
with
1,720 additions
and
286 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
38 changes: 38 additions & 0 deletions
38
apps/cowswap-frontend/src/legacy/components/Header/AccountElement/index.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,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> | ||
) | ||
} |
58 changes: 58 additions & 0 deletions
58
apps/cowswap-frontend/src/legacy/components/Header/AccountElement/styled.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,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; | ||
`} | ||
` |
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.