Skip to content

Commit

Permalink
feat(widget): add widget link to main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 authored and anxolin committed Nov 10, 2023
1 parent c953137 commit cbf125d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
11 changes: 11 additions & 0 deletions apps/cowswap-frontend/src/modules/mainMenu/constants/mainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import IMAGE_PIE from '@cowprotocol/assets/cow-swap/pie.svg'
import IMAGE_PRIVACY_POLICY from '@cowprotocol/assets/cow-swap/privacy-policy.svg'
import IMAGE_TERMS_AND_CONDITIONS from '@cowprotocol/assets/cow-swap/terms-and-conditions.svg'
import IMAGE_TWITTER from '@cowprotocol/assets/cow-swap/twitter.svg'
import IMAGE_WIDGET_ICON from '@cowprotocol/assets/cow-swap/widget-icon.svg'
import {
CONTRACTS_CODE_LINK,
DISCORD_LINK,
DOCS_LINK,
DUNE_DASHBOARD_LINK,
TWITTER_LINK,
WIDGET_LANDING_LINK,
} from '@cowprotocol/common-const'
import { getExplorerBaseUrl } from '@cowprotocol/common-utils'
import { ExternalLink } from '@cowprotocol/ui'
Expand Down Expand Up @@ -126,6 +128,15 @@ export const MAIN_MENU: MenuTreeItem[] = [
iconSVG: IMAGE_CODE,
kind: MenuItemKind.EXTERNAL_LINK,
},

{
id: MainMenuItemId.WIDGET,
title: 'Widget',
url: WIDGET_LANDING_LINK,
iconSVG: IMAGE_WIDGET_ICON,
kind: MenuItemKind.EXTERNAL_LINK,
badge: 'New!',
},
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { parameterizeTradeRoute } from 'modules/trade/utils/parameterizeTradeRou

import { RoutesValues } from 'common/constants/routes'

import { MenuBadge } from './styled'

import { MAIN_MENU } from '../../constants/mainMenu'

// Assets
Expand Down Expand Up @@ -58,7 +60,7 @@ function Link({ link, context }: InternalExternalLinkProps) {
return <>{LinkComponent()}</>
}

const { kind, title, url, iconSVG, icon } = link
const { kind, title, url, iconSVG, icon, badge } = link
const menuImage = <MenuImage title={title} icon={icon} iconSVG={iconSVG} />
const isExternal = kind === MenuItemKind.EXTERNAL_LINK
const isDynamic = kind === MenuItemKind.PARAMETRIZED_LINK
Expand All @@ -70,6 +72,7 @@ function Link({ link, context }: InternalExternalLinkProps) {
<ExternalLinkComponent href={url} onClickOptional={handleMobileMenuOnClick}>
{menuImage}
{title}
{badge && <MenuBadge>{badge}</MenuBadge>}
</ExternalLinkComponent>
)
}
Expand All @@ -78,6 +81,7 @@ function Link({ link, context }: InternalExternalLinkProps) {
<StyledNavLink to={internalUrl} end onClick={handleMobileMenuOnClick}>
{menuImage}
{title}
{badge && <MenuBadge>{badge}</MenuBadge>}
</StyledNavLink>
)
}
Expand Down
20 changes: 20 additions & 0 deletions apps/cowswap-frontend/src/modules/mainMenu/pure/MenuTree/styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import styled from 'styled-components/macro'

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

export const MenuBadge = styled.div`
display: flex;
align-items: center;
padding: 0 5px;
margin-left: 5px;
background: var(${UI.COLOR_ALERT2_BG});
color: var(${UI.COLOR_ALERT2_TEXT});
border: 0;
cursor: pointer;
border-radius: 16px;
font-size: 9px;
text-transform: uppercase;
letter-spacing: 0.2px;
font-weight: 600;
transition: color 0.15s ease-in-out;
`
2 changes: 2 additions & 0 deletions apps/cowswap-frontend/src/modules/mainMenu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export enum MainMenuItemId {
OTHER_TERMS_AND_CONDITIONS = 'OTHER_TERMS_AND_CONDITIONS',
OTHER_COOKIE_POLICY = 'OTHER_COOKIE_POLICY',
OTHER_PRIVACY_POLICY = 'OTHER_PRIVACY_POLICY',
WIDGET = 'WIDGET',
}

export interface BasicMenuLink {
Expand All @@ -43,6 +44,7 @@ export interface BasicMenuLink {
url: string
icon?: string // If icon uses a regular <img /> tag
iconSVG?: string
badge?: string
}

export interface InternalLink extends BasicMenuLink {
Expand Down
7 changes: 7 additions & 0 deletions libs/assets/src/cow-swap/widget-icon.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 libs/common-const/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const TWITTER_LINK = 'https://twitter.com/CoWSwap'
export const GPAUDIT_LINK = 'https://github.com/cowprotocol/contracts/blob/main/audits/GnosisProtocolV2May2021.pdf'
export const FLASHBOYS_LINK = 'https://arxiv.org/abs/1904.05234'
export const COWWIKI_LINK = 'https://en.wikipedia.org/wiki/Coincidence_of_wants'
export const WIDGET_LANDING_LINK = 'https://cow.fi/widget'
export const GNOSIS_FORUM_ROADTODECENT_LINK = 'https://forum.gnosis.io/t/gpv2-road-to-decentralization/1245'

// MEV Metrics from https://explore.flashbots.net/
Expand Down

0 comments on commit cbf125d

Please sign in to comment.