Skip to content

Commit

Permalink
feat: social buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Nov 1, 2024
1 parent a6f2f34 commit 900857c
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 28 deletions.
2 changes: 1 addition & 1 deletion apps/lend/src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import useStore from '@/store/useStore'
import { APPS_LINKS } from '@/ui/AppNav'
import { CommunitySection, ResourcesSection } from '@/layout/Footer'
import { useTvl } from '@/entities/chain'
import { Header as NewHeader } from '@/common/widgets/Header/Header'
import { Header as NewHeader } from '@/common/widgets/Header'
import { ThemeKey } from '@ui-kit/shared/lib'


Expand Down
14 changes: 14 additions & 0 deletions packages/curve-common/src/widgets/Header/HeaderLogoWithMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { AppName } from 'ui/src/AppNav/types'
import IconButton from '@mui/material/IconButton'
import MenuIcon from '@mui/icons-material/Menu'
import { HeaderLogo } from './HeaderLogo'
import React from 'react'

export const HeaderLogoWithMenu = (props: { onClick: () => void, appName: AppName }) => (
<>
<IconButton onClick={props.onClick} sx={{ display: 'inline-flex' }}>
<MenuIcon fontSize="small" />
</IconButton>
<HeaderLogo appName={props.appName} />
</>
)
27 changes: 12 additions & 15 deletions packages/curve-common/src/widgets/Header/MobileHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { AppBar, Toolbar } from '@mui/material'
import { HeaderLogo } from './HeaderLogo'
import { Theme } from '@mui/system'
import { BaseHeaderProps, toolbarColors } from './types'
import IconButton from '@mui/material/IconButton'
import React, { useCallback, useMemo, useState } from 'react'
import { MenuIcon } from 'curve-ui-kit/src/shared/ui/MenuIcon'
import Drawer from '@mui/material/Drawer'
import { SidebarSection } from './SidebarSection'
import groupBy from 'lodash/groupBy'
Expand All @@ -16,19 +14,12 @@ import { LanguageSwitcher } from '../../features/switch-language'
import { ChainSwitcher } from '../../features/switch-chain'
import { ConnectWalletIndicator } from '../../features/connect-wallet'
import { APP_LINK } from 'ui'
import { AppName, AppNames } from 'ui/src/AppNav/types'
import { CloseIcon } from 'curve-ui-kit/src/shared/ui/CloseIcon'
import { AppNames } from 'ui/src/AppNav/types'
import CloseIcon from '@mui/icons-material/Close'
import { t } from '@lingui/macro'
import { HeaderStats } from './HeaderStats'

const HeaderLogoWithMenu = (props: { onClick: () => void, appName: AppName }) => (
<>
<IconButton onClick={props.onClick} sx={{ display: 'inline-flex' }}>
<MenuIcon fontSize="small" />
</IconButton>
<HeaderLogo appName={props.appName} />
</>
)
import { HeaderLogoWithMenu } from './HeaderLogoWithMenu'
import { SocialSidebarSection } from './SocialSidebarSection'


export const MobileHeader = <TChainId extends number>({
Expand All @@ -48,6 +39,12 @@ export const MobileHeader = <TChainId extends number>({

const openSidebar = useCallback(() => setSidebarOpen(true), [])
const closeSidebar = useCallback(() => setSidebarOpen(false), [])
const onConnectWallet = wallet.onConnectWallet
const onConnect = useCallback(() => {
closeSidebar()
onConnectWallet()
}, [onConnectWallet, closeSidebar])

return (
<AppBar color="transparent" position="relative">
<Toolbar sx={{ backgroundColor: (t: Theme) => toolbarColors[t.palette.mode][0] }}>
Expand Down Expand Up @@ -87,14 +84,14 @@ export const MobileHeader = <TChainId extends number>({
currentPath={currentPath}
/>

{/* TODO: <SidebarSection title={t`Socials`} currentPath={currentPath} />*/}
<SocialSidebarSection currentPath={currentPath} />

<SidebarSection title={t`Options`} currentPath={currentPath}>
<Box display="flex" flexDirection="column" marginLeft={2} justifyContent="flex-end" gap={3}>
<AdvancedModeSwitcher advancedMode={isAdvancedMode} onChange={setAdvancedMode} />
<LanguageSwitcher {...languages} />
<ThemeSwitcherButton theme={theme} onChange={setTheme} />
<ConnectWalletIndicator {...wallet} />
<ConnectWalletIndicator {...wallet} onConnectWallet={onConnect} />
</Box>
</SidebarSection>
</Drawer>
Expand Down
39 changes: 39 additions & 0 deletions packages/curve-common/src/widgets/Header/SocialSidebarSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { SidebarSection } from './SidebarSection'
import { t } from '@lingui/macro'
import IconButton from '@mui/material/IconButton'
import { ReactElement } from 'react'
import TelegramIcon from '@mui/icons-material/Telegram'
import TwitterIcon from '@mui/icons-material/Twitter'
import YouTubeIcon from '@mui/icons-material/YouTube'
import Tooltip from '@mui/material/Tooltip'
import Link from '@mui/material/Link'
import { DiscordIcon } from 'curve-ui-kit/src/shared/ui/DiscordIcon'
import { Box } from 'curve-ui-kit/src/shared/ui/Box'
import SvgIcon from '@mui/material/SvgIcon';

type SocialButtonProps = {
label: string,
href: string,
icon: typeof SvgIcon
}

const SocialButton = ({ icon: Icon, href, label }: SocialButtonProps) => (
<IconButton component={Link} href={href} target="_blank" rel="noopener noreferrer">
<Tooltip title={label}>
<Icon fontSize="large" color="primary" />
</Tooltip>
</IconButton>
)

type SocialSidebarSectionProps = { currentPath: string }

export const SocialSidebarSection = (props: SocialSidebarSectionProps) => (
<SidebarSection title={t`Socials`} currentPath={props.currentPath}>
<Box display="flex" justifyContent="space-around">
<SocialButton label="Discord" href="https://discord.gg/rgrfS7W" icon={DiscordIcon} />
<SocialButton label="Telegram" href="https://t.me/curvefi" icon={TelegramIcon} />
<SocialButton label="Twitter" href="https://x.com/curvefinance" icon={TwitterIcon} />
<SocialButton label="YouTube" href="https://www.youtube.com/@CurveFinanceChannel" icon={YouTubeIcon} />
</Box>
</SidebarSection>
)
1 change: 1 addition & 0 deletions packages/curve-common/src/widgets/Header/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {Header} from './Header';
1 change: 1 addition & 0 deletions packages/curve-ui-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/icons-material": "^6.1.4",
"@mui/material": "^6.1.4",
"@mui/utils": "^6.1.4"
},
Expand Down
12 changes: 0 additions & 12 deletions packages/curve-ui-kit/src/shared/ui/CloseIcon.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions packages/curve-ui-kit/src/shared/ui/DiscordIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createSvgIcon } from '@mui/material/utils'
import React from 'react'

export const DiscordIcon = createSvgIcon(
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34 34" fill="currentColor">
<path
d="M26.0015 6.9529C24.0021 6.03845 21.8787 5.37198 19.6623 5C19.3833 5.48048 19.0733 6.13144 18.8563 6.64292C16.4989 6.30193 14.1585 6.30193 11.8336 6.64292C11.6166 6.13144 11.2911 5.48048 11.0276 5C8.79575 5.37198 6.67235 6.03845 4.6869 6.9529C0.672601 12.8736 -0.41235 18.6548 0.130124 24.3585C2.79599 26.2959 5.36889 27.4739 7.89682 28.2489C8.51679 27.4119 9.07477 26.5129 9.55525 25.5675C8.64079 25.2265 7.77283 24.808 6.93587 24.312C7.15286 24.1571 7.36986 23.9866 7.57135 23.8161C12.6241 26.1255 18.0969 26.1255 23.0876 23.8161C23.3046 23.9866 23.5061 24.1571 23.7231 24.312C22.8861 24.808 22.0182 25.2265 21.1037 25.5675C21.5842 26.5129 22.1422 27.4119 22.7621 28.2489C25.2885 27.4739 27.8769 26.2959 30.5288 24.3585C31.1952 17.7559 29.4733 12.0212 26.0015 6.9529ZM10.2527 20.8402C8.73376 20.8402 7.49382 19.4608 7.49382 17.7714C7.49382 16.082 8.70276 14.7025 10.2527 14.7025C11.7871 14.7025 13.0425 16.082 13.0115 17.7714C13.0115 19.4608 11.7871 20.8402 10.2527 20.8402ZM20.4373 20.8402C18.9183 20.8402 17.6768 19.4608 17.6768 17.7714C17.6768 16.082 18.8873 14.7025 20.4373 14.7025C21.9717 14.7025 23.2271 16.082 23.1961 17.7714C23.1961 19.4608 21.9872 20.8402 20.4373 20.8402Z" />
</svg>, 'Discord'
)
26 changes: 26 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2882,6 +2882,15 @@ __metadata:
languageName: node
linkType: hard

"@babel/runtime@npm:^7.26.0":
version: 7.26.0
resolution: "@babel/runtime@npm:7.26.0"
dependencies:
regenerator-runtime: "npm:^0.14.0"
checksum: 10c0/12c01357e0345f89f4f7e8c0e81921f2a3e3e101f06e8eaa18a382b517376520cd2fa8c237726eb094dab25532855df28a7baaf1c26342b52782f6936b07c287
languageName: node
linkType: hard

"@babel/template@npm:^7.18.10":
version: 7.18.10
resolution: "@babel/template@npm:7.18.10"
Expand Down Expand Up @@ -6326,6 +6335,22 @@ __metadata:
languageName: node
linkType: hard

"@mui/icons-material@npm:^6.1.4":
version: 6.1.6
resolution: "@mui/icons-material@npm:6.1.6"
dependencies:
"@babel/runtime": "npm:^7.26.0"
peerDependencies:
"@mui/material": ^6.1.6
"@types/react": ^17.0.0 || ^18.0.0 || ^19.0.0
react: ^17.0.0 || ^18.0.0 || ^19.0.0
peerDependenciesMeta:
"@types/react":
optional: true
checksum: 10c0/a6eb10be3cc356fd404febf29a3b26fa63b6b09d3148736fb05279954905186e9804869ff18220840ae92dbdeddfd407c2d0c72b9e165e01fd6bbc620b6b39d7
languageName: node
linkType: hard

"@mui/material@npm:^6.1.4":
version: 6.1.4
resolution: "@mui/material@npm:6.1.4"
Expand Down Expand Up @@ -15115,6 +15140,7 @@ __metadata:
"@chromatic-com/storybook": "npm:^2.0.2"
"@emotion/react": "npm:^11.13.3"
"@emotion/styled": "npm:^11.13.0"
"@mui/icons-material": "npm:^6.1.4"
"@mui/material": "npm:^6.1.4"
"@mui/utils": "npm:^6.1.4"
"@storybook/addon-a11y": "npm:^8.3.5"
Expand Down

0 comments on commit 900857c

Please sign in to comment.