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 all 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/logo/cow-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
47 changes: 47 additions & 0 deletions apps/cowswap-frontend/src/common/pure/PoweredFooter/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { COW_PROTOCOL_LINK } from '@cowprotocol/common-const'
import { ExternalLink } from '@cowprotocol/ui'

import { Trans } from '@lingui/macro'
import cowIcon from 'assets/logo/cow-icon.svg'
import SVG from 'react-inlinesvg'
import styled from 'styled-components/macro'

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

const Wrapper = styled.div`
display: flex;
flex-flow: row wrap;
align-items: center;
justify-content: center;
font-size: var(${UI.FONT_SIZE_SMALLER});
padding: 4px 0;
`

const StyledExternalLink = styled(ExternalLink)`
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
color: var(${UI.COLOR_TEXT2});

> svg {
--size: 14px;
width: var(--size);
height: var(--size);
}

> svg > g > path {
fill: var(${UI.COLOR_TEXT2});
}
`

export function PoweredFooter() {
return (
<Wrapper>
<StyledExternalLink href={COW_PROTOCOL_LINK}>
<SVG src={cowIcon} title="CoW Protocol" />
<Trans>Powered by CoW Protocol</Trans>
</StyledExternalLink>
</Wrapper>
)
}
4 changes: 4 additions & 0 deletions apps/cowswap-frontend/src/cow-react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ import { WithLDProvider } from 'modules/application/containers/WithLDProvider'
import { FortuneWidget } from 'modules/fortune/containers/FortuneWidget'

import { FeatureGuard } from 'common/containers/FeatureGuard'
import { IframeResizer } from 'utils/iframeResizer'

import { WalletUnsupportedNetworkBanner } from '../common/containers/WalletUnsupportedNetworkBanner'


// Node removeChild hackaround
// based on: https://github.com/facebook/react/issues/11538#issuecomment-417504600
nodeRemoveChildFix()
Expand Down Expand Up @@ -79,6 +81,8 @@ root.render(
</HashRouter>
</AtomProvider>
</Provider>

{isInjectedWidgetMode && <IframeResizer />}
</StrictMode>
)

Expand Down
15 changes: 2 additions & 13 deletions apps/cowswap-frontend/src/legacy/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react'
import React, { useCallback, useMemo, useState } from 'react'

import { toggleDarkModeAnalytics } from '@cowprotocol/analytics'
import { addBodyClass, removeBodyClass } from '@cowprotocol/common-utils'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { useWalletInfo } from '@cowprotocol/wallet'

Expand All @@ -10,11 +9,10 @@ import { useNavigate } from 'react-router-dom'

import CowBalanceButton from 'legacy/components/CowBalanceButton'
import { NetworkSelector } from 'legacy/components/Header/NetworkSelector'
import { LargeAndUp, upToLarge, upToMedium, upToSmall, useMediaQuery } from 'legacy/hooks/useMediaQuery'
import { upToLarge, upToSmall, useMediaQuery } from 'legacy/hooks/useMediaQuery'
import { useDarkModeManager } from 'legacy/state/user/hooks'
import { cowSwapLogo } from 'legacy/theme/cowSwapAssets'

import { useAccountModalState } from 'modules/account'
import { useInjectedWidgetParams } from 'modules/injectedWidget'
import { MainMenuContext } from 'modules/mainMenu'
import { MenuTree } from 'modules/mainMenu/pure/MenuTree'
Expand Down Expand Up @@ -52,14 +50,11 @@ export default function Header() {
}, [toggleDarkModeAux, darkMode])
const swapRawState = useSwapRawState()
const { state: tradeState } = useTradeState()
const { isOpen: isAccountModalOpen } = useAccountModalState()

const navigate = useNavigate()

const isUpToLarge = useMediaQuery(upToLarge)
const isUpToMedium = useMediaQuery(upToMedium)
const isUpToSmall = useMediaQuery(upToSmall)
const isLargeAndUp = useMediaQuery(LargeAndUp)

const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false)
const handleMobileMenuOnClick = useCallback(() => {
Expand Down Expand Up @@ -95,12 +90,6 @@ export default function Header() {
tradeContext: tradeMenuContext,
}

// Toggle the 'noScroll' class on body, whenever the mobile menu or orders panel is open.
// This removes the inner scrollbar on the page body, to prevent showing double scrollbars.
useEffect(() => {
isMobileMenuOpen || isAccountModalOpen ? addBodyClass('noScroll') : removeBodyClass('noScroll')
}, [isAccountModalOpen, isMobileMenuOpen, isUpToLarge, isUpToMedium, isUpToSmall, isLargeAndUp])

return (
<Wrapper isMobileMenuOpen={isMobileMenuOpen}>
<HeaderModWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const Fader = styled.div`
export const PopupWrapper = styled.div<{ css?: FlattenInterpolation<ThemeProps<DefaultTheme>> }>`
display: inline-block;
width: 100%;
//padding: 1em;
background-color: var(${UI.COLOR_CONTAINER_BG_01});
position: relative;
border-radius: 10px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ import { BaseWrapper, CommonBasesRow, MobileWrapper } from './index'
export const StyledScrollarea = styled.div`
overflow-y: auto; // fallback for 'overlay'
overflow-y: overlay;
padding: 0 20px;
padding: 0 20px 0;
overflow-y: hidden;
overflow-x: auto;
${({ theme }) => theme.colorScrollbar};

${({ theme }) => theme.mediaWidth.upToSmall`
overflow-y: hidden;
overflow-x: auto;
`}
`

const MAX_LENGTH_OVERFLOW = 12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ export const AutoColumn = styled(AutoColumnUni)`
`

export const CommonBasesRow = styled(AutoRow)`
${({ theme }) => theme.mediaWidth.upToSmall`
flex-flow: row nowrap;
overflow-x: scroll;
padding: 0 100px 0 0;
position: relative;
${({ theme }) => theme.colorScrollbar};
`}
margin: 0;
flex-flow: row nowrap;
overflow-x: scroll;
padding: 0 100px 5px 0;
position: relative;
${({ theme }) => theme.colorScrollbar};
`

export const MobileWrapper = styled(AutoColumn)<{ showOverflow?: boolean }>`
Expand All @@ -50,7 +49,6 @@ export const MobileWrapper = styled(AutoColumn)<{ showOverflow?: boolean }>`
&::after {
content: '';
display: block;
// background: linear-gradient(to top, #163861 0%, rgba(22, 56, 97, 0) 100%);
pointer-events: none;
height: 40px;
width: 100%;
Expand All @@ -61,35 +59,30 @@ export const MobileWrapper = styled(AutoColumn)<{ showOverflow?: boolean }>`
margin: auto;
}
`}
${({ theme }) => theme.mediaWidth.upToSmall`
/* display: none; */
`};

overflow-y: auto; // fallback for 'overlay'
overflow-y: overlay;
max-height: 135px;
padding-bottom: 20px;
padding: 0;
`

export const BaseWrapperMod = styled.div<{ disable?: boolean }>`
border: 1px solid ${({ theme, disable }) => (disable ? 'transparent' : theme.bg3)};
border-radius: 10px;
display: flex;
padding: 6px;

align-items: center;
:hover {
cursor: ${({ disable }) => !disable && 'pointer'};
background-color: ${({ theme, disable }) => !disable && theme.bg4};
}

color: ${({ theme, disable }) => disable && theme.text3};
background-color: ${({ theme, disable }) => disable && theme.bg3};
filter: ${({ disable }) => disable && 'grayscale(1)'};

flex: 0 0 calc(33% - 8px);
justify-content: center;

&:hover {
cursor: ${({ disable }) => !disable && 'pointer'};
background-color: ${({ theme, disable }) => !disable && theme.bg4};
}

${({ theme }) => theme.mediaWidth.upToSmall`
flex: auto;
`}
Expand Down
4 changes: 3 additions & 1 deletion apps/cowswap-frontend/src/legacy/pages/AppBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import styled from 'styled-components/macro'

import { Z_INDEX } from 'legacy/theme'

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

export const BodyWrapper = styled.main<{ margin?: string; maxWidth?: string }>`
position: relative;
margin-top: ${({ margin }) => margin ?? '0px'};
Expand All @@ -12,7 +14,7 @@ export const BodyWrapper = styled.main<{ margin?: string; maxWidth?: string }>`
background: ${({ theme }) => theme.bg0};
box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.01), 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 16px 24px rgba(0, 0, 0, 0.04),
0px 24px 32px rgba(0, 0, 0, 0.01);
border-radius: 24px;
border-radius: var(${UI.BORDER_RADIUS_NORMAL});
margin-top: 1rem;
margin-left: auto;
margin-right: auto;
Expand Down
8 changes: 4 additions & 4 deletions apps/cowswap-frontend/src/legacy/theme/baseTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,9 @@ export const ThemedGlobalStyle = createGlobalStyle`
${UniThemedGlobalStyle}

html {
background-color: ${({ theme }) => theme.isInjectedWidgetMode ? 'transparent' : `var(${UI.COLOR_CONTAINER_BG_02})`};
${({ theme }) => theme.body.background};
background-color: ${({ theme }) =>
theme.isInjectedWidgetMode ? 'transparent' : `var(${UI.COLOR_CONTAINER_BG_02})`};
${({ theme }) => (theme.isInjectedWidgetMode ? 'transparent' : theme.body.background)};
}

*, *:after, *:before { box-sizing:border-box; }
Expand Down Expand Up @@ -533,8 +534,7 @@ export const ThemedGlobalStyle = createGlobalStyle`
body #wcm-modal.wcm-overlay {
${({ theme }) => theme.mediaWidth.upToSmall`
align-items: flex-start;
`
}
`}

a {
text-decoration: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const AppWrapper = styled.div<Partial<CSS.Properties>>`
flex-flow: column;
align-items: flex-start;
min-height: 100vh;
height: 100vh;
`

export const HeaderWrapper = styled.div`
Expand Down Expand Up @@ -36,10 +37,10 @@ export const BodyWrapper = styled.div`
justify-content: center;
flex: 1 1 auto;
z-index: 2;
padding: ${({ theme }) => theme.isInjectedWidgetMode ? '0' : '5vh 16px 0'};
padding: ${({ theme }) => (theme.isInjectedWidgetMode ? '16px 16px 0' : '5vh 16px 0')};

${({ theme }) => theme.mediaWidth.upToMedium`
padding: ${({ theme }) => theme.isInjectedWidgetMode ? '0' : '0 10px 16px'};
padding: ${({ theme }) => (theme.isInjectedWidgetMode ? '0 0 16px' : '0 10px 16px')};
flex: none;
`}
`
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import IMAGE_CARRET from 'assets/icon/carret.svg'
import SVG from 'react-inlinesvg'
import { matchPath, useLocation } from 'react-router-dom'

import { ModalHeader } from 'modules/tokensList/pure/ModalHeader'
import { useTradeRouteContext } from 'modules/trade/hooks/useTradeRouteContext'
import { parameterizeTradeRoute } from 'modules/trade/utils/parameterizeTradeRoute'

Expand Down Expand Up @@ -50,7 +51,7 @@ export function TradeWidgetLinks({
const location = useLocation()
const [isDropdownVisible, setDropdownVisible] = useState(false)

const handleMenuItemClick = (_item: MenuItemConfig) => {
const handleMenuItemClick = (_item?: MenuItemConfig) => {
if (menuItems.length === 1) return
setDropdownVisible(false)
}
Expand Down Expand Up @@ -81,23 +82,32 @@ export function TradeWidgetLinks({
)
})

const singleMenuItem = menuItems.length === 1;
const singleMenuItem = menuItems.length === 1

return isDropdown ? (
<>
<styledEl.MenuItem onClick={() => !singleMenuItem && setDropdownVisible(!isDropdownVisible)} isDropdownVisible={isDropdownVisible}>
<styledEl.MenuItem
onClick={() => !singleMenuItem && setDropdownVisible(!isDropdownVisible)}
isDropdownVisible={isDropdownVisible}
>
<styledEl.Link to={menuItems.find((item) => item.props.isActive)?.props.routePath || '#'}>
<Trans>
{menuItems.find((item) => item.props.isActive)?.props.item.label}
{!singleMenuItem ? <SVG src={IMAGE_CARRET} title="select" /> : null}
</Trans>
</styledEl.Link>
</styledEl.MenuItem>
{isDropdownVisible && <styledEl.SelectMenu>{menuItems}</styledEl.SelectMenu>}

{isDropdownVisible && (
<styledEl.SelectMenu>
<ModalHeader onBack={handleMenuItemClick}>Trading mode</ModalHeader>
{menuItems}
</styledEl.SelectMenu>
)}
</>
) : (
<styledEl.Wrapper>{menuItems}</styledEl.Wrapper>
);
)
}

const MenuItem = ({
Expand Down
Loading
Loading