Skip to content

Commit

Permalink
Merge pull request #148 from curvefi/fix/main-logo-url-link
Browse files Browse the repository at this point in the history
fix: app logo link to its respective domain
  • Loading branch information
amytsang committed Apr 24, 2024
2 parents 6dfe6d9 + f1ae93e commit e3c0295
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 51 deletions.
8 changes: 0 additions & 8 deletions apps/lend/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export const ASSETS_BASE_PATH = 'https://cdn.jsdelivr.net/gh/curvefi/curve-assets'
export const INVALID_ADDRESS = '0x0000000000000000000000000000000000000000'
export const LARGE_APY = 5000000

Expand All @@ -23,13 +22,6 @@ export const REFRESH_INTERVAL = {
'11m': 660000,
}

const CURVE_FI_MAIN = process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : 'https://curve.fi'

export const CURVE_FI_ROUTE = {
MAIN: CURVE_FI_MAIN,
CRVUSD_POOLS: `${CURVE_FI_MAIN}/#/ethereum/pools?filter=crvusd`,
}

export const CONNECT_STAGE = {
CONNECT_API: 'api',
CONNECT_WALLET: 'connect-wallet',
Expand Down
5 changes: 1 addition & 4 deletions apps/lend/src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { useEffect, useMemo, useRef } from 'react'
import { t } from '@lingui/macro'
import { useNavigate, useParams } from 'react-router-dom'

import { CONNECT_STAGE, CURVE_FI_ROUTE, ROUTE } from '@/constants'
import { CONNECT_STAGE, ROUTE } from '@/constants'
import { DEFAULT_LOCALES } from '@/lib/i18n'
import { getNetworkFromUrl, getRestFullPathname } from '@/utils/utilsRouter'
import { getParamsFromUrl, getRestPartialPathname } from '@/utils/utilsRouter'
Expand Down Expand Up @@ -58,12 +58,9 @@ const Header = () => {
const setAppCache = useStore((state) => state.setAppCache)
const updateConnectState = useStore((state) => state.updateConnectState)

const network = networks[rChainId].id
const appLogoProps: AppLogoProps = {
showBeta: true,
appName: 'LlamaLend',
pathname: CURVE_FI_ROUTE.MAIN,
internalPathname: `${rLocalePathname}/${network}${ROUTE.PAGE_MARKETS}`,
}

const p: AppPage[] = isLgUp
Expand Down
2 changes: 1 addition & 1 deletion apps/loan/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const REFRESH_INTERVAL = {
const CURVE_FI_MAIN = process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : 'https://curve.fi'

export const CURVE_FI_ROUTE = {
MAIN: CURVE_FI_MAIN,
MAIN: process.env.NODE_ENV === 'development' ? 'http://localhost:3001' : 'https://crvusd.curve.fi',
CRVUSD_POOLS: `${CURVE_FI_MAIN}/#/ethereum/pools?filter=crvusd`,
}

Expand Down
7 changes: 2 additions & 5 deletions apps/loan/src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import React, { useMemo, useRef } from 'react'
import { t } from '@lingui/macro'
import { useNavigate, useParams } from 'react-router-dom'

import { CONNECT_STAGE, CRVUSD_ADDRESS, CURVE_FI_ROUTE, ROUTE } from '@/constants'
import { CONNECT_STAGE, CRVUSD_ADDRESS, ROUTE } from '@/constants'
import { DEFAULT_LOCALES } from '@/lib/i18n'
import { getLocaleFromUrl, getNetworkFromUrl, getPath, getRestFullPathname } from '@/utils/utilsRouter'
import { getWalletSignerAddress } from '@/store/createWalletSlice'
import { formatNumber, isLoading } from '@/ui/utils'
import { useConnectWallet } from '@/onboard'
import networks, { visibleNetworksList } from '@/networks'
import { visibleNetworksList } from '@/networks'
import useLayoutHeight from '@/hooks/useLayoutHeight'
import useStore from '@/store/useStore'

Expand Down Expand Up @@ -57,11 +57,8 @@ const Header = () => {

const rLocale = getLocaleFromUrl()

const network = networks[rChainId]?.id
const appLogoProps: AppLogoProps = {
appName: 'Crvusd',
pathname: CURVE_FI_ROUTE.MAIN,
internalPathname: `${rLocale?.rLocalePathname}/${network}${ROUTE.PAGE_MARKETS}`,
}

const p: AppPage[] = isLgUp
Expand Down
3 changes: 0 additions & 3 deletions apps/main/src/layout/default/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,8 @@ const Header = () => {
const { hasRouter } = getNetworkConfigFromApi(rChainId)
const routerCached = useStore((state) => state.storeCache.routerFormValues[rChainId])

const network = networks[rChainId]?.networkId
const appLogoProps: AppLogoProps = {
appName: '',
pathname: hasRouter ? ROUTE.PAGE_SWAP : ROUTE.PAGE_POOLS,
internalPathname: `${rLocalePathname}/${network}${hasRouter ? ROUTE.PAGE_SWAP : ROUTE.PAGE_POOLS}`,
}

// prettier-ignore
Expand Down
37 changes: 7 additions & 30 deletions packages/ui/src/Brand/AppLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
import * as React from 'react'
import { Link } from 'react-router-dom'
import Image from 'next/image'
import styled, { css } from 'styled-components'
import styled from 'styled-components'

import { breakpoints } from 'ui/src/utils/responsive'
import { LogoImg, RCLogoText } from 'ui/src/images'
import ExternalLink from 'ui/src/Link/ExternalLink'

export type AppLogoProps = {
className?: string
appName: string
pathname?: string
internalPathname: string
showBeta?: boolean
}

const AppLogo = ({ className = '', appName, internalPathname, pathname, showBeta }: AppLogoProps) => {
const LogoContent = (
<>
<CurveLogo src={LogoImg} alt="Curve" /> <StyledCurveLogoText />
<AppName>{appName}</AppName>
</>
)

const AppLogo = ({ className = '', appName, showBeta }: AppLogoProps) => {
return (
<Wrapper className={className}>
{pathname?.startsWith('http') ? (
<StyledExternalLink $noStyles $haveAppName={!!appName} href={pathname} target="_self">
{LogoContent}
</StyledExternalLink>
) : (
<StyledInternalLink to={internalPathname} $haveAppName={!!appName}>
{LogoContent}
</StyledInternalLink>
)}
<StyledInternalLink to="/" $haveAppName={!!appName}>
<CurveLogo src={LogoImg} alt="Curve" /> <StyledCurveLogoText />
<AppName>{appName}</AppName>
</StyledInternalLink>
{showBeta && (
<div>
<Beta>Beta</Beta>
Expand Down Expand Up @@ -89,7 +74,7 @@ const CurveLogo = styled(Image)`
margin-right: var(--spacing-2);
`

const LinkCss = css<{ $haveAppName: boolean }>`
const StyledInternalLink = styled(Link)<{ $haveAppName: boolean }>`
align-items: center;
color: inherit;
display: inline-flex;
Expand All @@ -107,12 +92,4 @@ const LinkCss = css<{ $haveAppName: boolean }>`
}};
`

const StyledExternalLink = styled(ExternalLink)`
${LinkCss}
`

const StyledInternalLink = styled(Link)`
${LinkCss}
`

export default AppLogo

0 comments on commit e3c0295

Please sign in to comment.