Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Comment Banner #188

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/images/banners/comment-desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/banners/comment-mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/components/main/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { UpOutlined } from '@ant-design/icons'
import { Affix, BackTop, Button, Tabs, Tooltip } from 'antd'
import clsx from 'clsx'
import { NextPage } from 'next'
import dynamic from 'next/dynamic'
import { useRouter } from 'next/router'
Expand All @@ -18,6 +19,7 @@ import { CreatorDashboardHomeVariant } from '../creators/CreatorDashboardSidebar
import MobileActiveStakingSection from '../creators/MobileActiveStakingSection'
import { useIsMobileWidthOrDevice } from '../responsive'
import { CreatorsSpaces } from '../spaces/LatestSpacesPage'
import CommentBanner from '../utils/banners/CommentBanner'
import Section from '../utils/Section'
import style from './HomePage.module.sass'
import { dateFilterOpt, Filters, PostFilterView, SpaceFilterView } from './HomePageFilters'
Expand Down Expand Up @@ -187,6 +189,9 @@ const TabsHomePage = ({
return (
<>
<MobileActiveStakingSection />
<div className={clsx(isMobile ? 'mt-3' : '')}>
<CommentBanner />
</div>
<span>
{!isMobile && <AffixTabs tabKey={tab} setKey={onChangeKey} visible={hidden} {...props} />}
</span>
Expand Down
16 changes: 16 additions & 0 deletions src/components/utils/banners/CommentBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import MultiBanner from './MultiBanner'

const bannersKind = ['']

const BANNER_STORAGE_KEY = 'df.comments'

const CommentBanner = () => (
<MultiBanner
uid={BANNER_STORAGE_KEY}
kinds={bannersKind}
withCloseButtonBackground
buildUrl={({ isMobile }) => `/images/banners/comment${isMobile ? '-mobile' : '-desktop'}.png`}
/>
)

export default CommentBanner
7 changes: 6 additions & 1 deletion src/components/utils/banners/MultiBanner/index.module.sass
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
.DfCloseButton
color: #fff
cursor: pointer
font-size: 1.25rem
padding-right: 0
float: right
position: absolute
top: $space_small
right: $space_small

&.DfCloseButtonBg
padding: $space_mini
border-radius: $border_radius_normal
background: rgba(0, 0, 0, .3)
backdrop-filter: blur(4px) saturate(180%)

&:hover
color: $color_link_hover

Expand Down
32 changes: 25 additions & 7 deletions src/components/utils/banners/MultiBanner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CloseOutlined } from '@ant-design/icons'
import clsx from 'clsx'
import Link from 'next/link'
import React, { useState } from 'react'
import { useResponsiveSize } from 'src/components/responsive'
Expand All @@ -15,10 +16,17 @@ type MultiBannerProps = {
uid: string
kinds: string[]
buildUrl: (props: BuildUrlFnProps) => string
href: string
href?: string
withCloseButtonBackground?: boolean
}

export const MultiBanner = ({ uid, kinds, buildUrl, href }: MultiBannerProps) => {
export const MultiBanner = ({
uid,
kinds,
buildUrl,
href,
withCloseButtonBackground,
}: MultiBannerProps) => {
const { isMobile } = useResponsiveSize()

const bannerFromStorage = store.get(uid)
Expand All @@ -40,15 +48,25 @@ export const MultiBanner = ({ uid, kinds, buildUrl, href }: MultiBannerProps) =>
store.set(uid, false)
}

const closeButton = <CloseOutlined className={styles.DfCloseButton} onClick={closeBanner} />
const closeButton = (
<CloseOutlined
className={clsx(styles.DfCloseButton, withCloseButtonBackground && styles.DfCloseButtonBg)}
onClick={closeBanner}
/>
)
const content = (
<div className={styles.Banner}>
<img src={backgroundImage} className={styles.BannerImg} alt='Banner image' />
{closeButton}
</div>
)

if (!href) return content

return (
<Link href={href}>
<a target='_blank' rel='noreferrer'>
<div className={styles.Banner}>
<img src={backgroundImage} className={styles.BannerImg} alt='Banner image' />
{closeButton}
</div>
{content}
</a>
</Link>
)
Expand Down