Skip to content

Commit

Permalink
chore: add btn, content, image positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
thechefpenguin committed Nov 1, 2024
1 parent ea20ca6 commit 92b4296
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 27 deletions.
17 changes: 13 additions & 4 deletions apps/web/src/components/AdPanel/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { Button, ButtonProps } from '@pancakeswap/uikit'
import { Button, ButtonProps, OpenNewIcon } from '@pancakeswap/uikit'
import { PropsWithChildren } from 'react'

interface AdButtonProps extends ButtonProps, PropsWithChildren {}
interface AdButtonProps extends ButtonProps, PropsWithChildren {
isExternal?: boolean
}

export const AdButton = ({ children }: AdButtonProps) => {
export const AdButton = ({ children, isExternal, endIcon, ...props }: AdButtonProps) => {
return (
<Button scale="sm" variant="subtle" padding="3px 4px 5px 4px" height="unset">
<Button
scale="sm"
variant="subtle"
width="fit-content"
padding="7px 8px 9px 8px"
endIcon={isExternal ? <OpenNewIcon color="invertedContrast" /> : endIcon}
{...props}
>
{children}
</Button>
)
Expand Down
15 changes: 13 additions & 2 deletions apps/web/src/components/AdPanel/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,21 @@ const Content = styled(Flex)`

const PositionedImage = styled(Image)`
position: absolute;
bottom: 0;
right: 0;
bottom: -2px;
right: -1px;
z-index: 1;
`

const SliderContainer = styled(Box)`
position: absolute;
bottom: 16px;
left: 16px;
width: 148px;
height: 8px;
border: 1px solid gray;
`

interface AdCardProps {
children?: React.ReactNode
imageUrl?: string
Expand All @@ -39,6 +49,7 @@ export const AdCard = ({ children, imageUrl, alt }: AdCardProps) => {
return (
<BaseCard>
<Content>{children}</Content>
<SliderContainer />
<PositionedImage src={imageUrl} alt={alt || 'Ad'} width={207} height={188} />
</BaseCard>
)
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/AdPanel/CardLayouts.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getPortalRoot, useMatchBreakpoints } from '@pancakeswap/uikit'
import { createPortal } from 'react-dom'
import { TitleAd } from './Variations/TitleAd'
import { TitleContentAd } from './Variations/TitleContentAd'

/**
* Renders floating Ad banners on desktop
Expand All @@ -9,13 +9,13 @@ export const DesktopCard = () => {
const portalRoot = getPortalRoot()
const { isDesktop } = useMatchBreakpoints()

return portalRoot && isDesktop ? createPortal(<TitleAd />, portalRoot) : null
return portalRoot && isDesktop ? createPortal(<TitleContentAd />, portalRoot) : null
}

/**
* Renders Ad banners on mobile and tablet
*/
export const MobileCard = () => {
const { isDesktop } = useMatchBreakpoints()
return !isDesktop ? <TitleAd /> : null
return !isDesktop ? <TitleContentAd /> : null
}
12 changes: 12 additions & 0 deletions apps/web/src/components/AdPanel/Content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Text, TextProps } from '@pancakeswap/uikit'
import { PropsWithChildren } from 'react'

interface ContentProps extends TextProps, PropsWithChildren {}

export const Content = ({ children, ...props }: ContentProps) => {
return (
<Text fontSize="14px" mb="16px" bold {...props}>
{children}
</Text>
)
}
5 changes: 2 additions & 3 deletions apps/web/src/components/AdPanel/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { Text, TextProps } from '@pancakeswap/uikit'
import { PropsWithChildren } from 'react'

interface TitleProps extends TextProps, PropsWithChildren {}

export const Title = ({ children, ...props }: TitleProps) => {
export const Title = ({ children }: TitleProps) => {
return (
<Text fontSize="14px" mb="16px" bold {...props}>
<Text color="secondary" small bold>
{children}
</Text>
)
Expand Down
13 changes: 0 additions & 13 deletions apps/web/src/components/AdPanel/Variations/TitleAd.tsx

This file was deleted.

15 changes: 15 additions & 0 deletions apps/web/src/components/AdPanel/Variations/TitleContentAd.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { AdButton } from '../Button'
import { AdCard } from '../Card'
import { Content } from '../Content'
import { Title } from '../Title'

export const TitleContentAd = () => {
return (
<AdCard imageUrl="/images/adpanel-test/bannerImg1.png">
<Title>Need Help?</Title>
<Content>Quick start now on How to Swap!</Content>

<AdButton isExternal>Quick start</AdButton>
</AdCard>
)
}
4 changes: 2 additions & 2 deletions apps/web/src/components/AdPanel/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AdButton as Button } from './Button'
import { AdCard as Card } from './Card'
import { DesktopCard, MobileCard } from './CardLayouts'
import { Title } from './Title'
import { Content } from './Content'

// TODO: Later move to widgets-internal with conventional exporting
export const AdPanel = {
DesktopCard,
MobileCard,
Card,
Title,
Content,
Button,
}

0 comments on commit 92b4296

Please sign in to comment.