Skip to content

Commit

Permalink
feat(widgets): move uniswap protocol branding from header to bottom o…
Browse files Browse the repository at this point in the history
…f output (Uniswap#3194)

* move branding from header to bottom of output

* remove old prop

* BrandingFooter component

* pr feedback
  • Loading branch information
JFrankfurt authored Jan 28, 2022
1 parent 043fb95 commit 4a8f1d9
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 30 deletions.
38 changes: 38 additions & 0 deletions src/lib/components/BrandedFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Trans } from '@lingui/macro'
import Row from 'lib/components/Row'
import { Logo } from 'lib/icons'
import styled, { ThemedText } from 'lib/theme'

import ExternalLink from './ExternalLink'

const UniswapA = styled(ExternalLink)`
color: ${({ theme }) => theme.secondary};
cursor: pointer;
text-decoration: none;
${Logo} {
fill: ${({ theme }) => theme.secondary};
height: 1em;
transition: transform 0.25s ease;
width: 1em;
will-change: transform;
:hover {
fill: ${({ theme }) => theme.onHover(theme.secondary)};
transform: rotate(-5deg);
}
}
`

export default function BrandedFooter() {
return (
<UniswapA href={`https://app.uniswap.org/`}>
<Row gap={0.4} justify="center">
<Logo />
<ThemedText.Caption color="secondary">
<Trans>Powered by the Uniswap protocol</Trans>
</ThemedText.Caption>
</Row>
</UniswapA>
)
}
17 changes: 17 additions & 0 deletions src/lib/components/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { HTMLProps } from 'react'

/**
* Outbound link
*/
export default function ExternalLink({
target = '_blank',
href,
rel = 'noopener noreferrer',
...rest
}: Omit<HTMLProps<HTMLAnchorElement>, 'as' | 'ref' | 'onClick'> & { href: string }) {
return (
<a target={target} rel={rel} href={href} {...rest}>
{rest.children}
</a>
)
}
31 changes: 3 additions & 28 deletions src/lib/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
import { largeIconCss, Logo } from 'lib/icons'
import { largeIconCss } from 'lib/icons'
import styled, { ThemedText } from 'lib/theme'
import { ReactElement, ReactNode } from 'react'

import Row from './Row'

const UniswapA = styled.a`
cursor: pointer;
${Logo} {
fill: ${({ theme }) => theme.secondary};
height: 1.5em;
transition: transform 0.25s ease;
width: 1.5em;
will-change: transform;
:hover {
fill: ${({ theme }) => theme.onHover(theme.secondary)};
transform: rotate(-5deg);
}
}
`

const HeaderRow = styled(Row)`
height: 1.75em;
margin: 0 0.75em 0.75em;
Expand All @@ -30,21 +13,13 @@ const HeaderRow = styled(Row)`

export interface HeaderProps {
title?: ReactElement
logo?: boolean
children: ReactNode
}

export default function Header({ title, logo, children }: HeaderProps) {
export default function Header({ title, children }: HeaderProps) {
return (
<HeaderRow iconSize={1.2}>
<Row gap={0.5}>
{logo && (
<UniswapA href={`https://app.uniswap.org/`}>
<Logo />
</UniswapA>
)}
{title && <ThemedText.Subhead1>{title}</ThemedText.Subhead1>}
</Row>
<Row gap={0.5}>{title && <ThemedText.Subhead1>{title}</ThemedText.Subhead1>}</Row>
<Row gap={1}>{children}</Row>
</HeaderRow>
)
Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/Swap/Output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Trans } from '@lingui/macro'
import { useUSDCValue } from 'hooks/useUSDCPrice'
import { atom } from 'jotai'
import { useAtomValue } from 'jotai/utils'
import BrandedFooter from 'lib/components/BrandedFooter'
import { useSwapAmount, useSwapCurrency, useSwapInfo } from 'lib/hooks/swap'
import useCurrencyColor from 'lib/hooks/useCurrencyColor'
import { Field } from 'lib/state/swap'
Expand Down Expand Up @@ -101,6 +102,7 @@ export default function Output({ disabled, children }: OutputProps) {
</ThemedText.Body2>
</TokenInput>
{children}
<BrandedFooter />
</OutputColumn>
</DynamicThemeProvider>
)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function Swap(props: SwapProps) {
return (
<SwapPropValidator {...props}>
<SwapInfoUpdater />
<Header logo title={<Trans>Swap</Trans>}>
<Header title={<Trans>Swap</Trans>}>
{active && <Wallet disabled={!account} />}
<Settings disabled={!active} />
</Header>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const WidgetWrapper = styled.div<{ width?: number | string }>`
font-size: 16px;
font-smooth: always;
font-variant: none;
height: 348px;
height: 376px;
min-width: 300px;
overflow-y: hidden;
padding: 0.25em;
Expand Down

0 comments on commit 4a8f1d9

Please sign in to comment.