Skip to content

Commit

Permalink
update new ui
Browse files Browse the repository at this point in the history
  • Loading branch information
imhson committed Jan 17, 2025
1 parent 5cb56cb commit fde271c
Show file tree
Hide file tree
Showing 14 changed files with 448 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/components/Input/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function Checkbox({
</svg>
)}
</div>
{label && <span className='whitespace-nowrap text-text-primary'>{label}</span>}
{label && <span className='whitespace-nowrap '>{label}</span>}
</div>
)
}
2 changes: 1 addition & 1 deletion src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Layout({ children }: any) {
return (
<main className={`bg-gray-50 max-w-screen ${roboto.variable}`}>
{width < 1280 ? <NHeader /> : <Header />}
<div className='min-h-[70vh] text-text-primary pb-20 relative pt-14'>{children}</div>
<div className='min-h-[70vh] text-text-primary relative pt-14 pb-20 xl:pt-0 xl:pb-0'>{children}</div>
{width < 1280 ? <BottomNavigation /> : <Footer />}
</main>
)
Expand Down
162 changes: 162 additions & 0 deletions src/components/pages/artworks/ArtworkDetail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import Copy2Clipboard from 'components/Copy2Clipboard'
import Dropdown, { DropdownMenu, DropdownToggle } from 'components/Dropdown'
import DOMPurify from 'dompurify'
import getConfig from 'next/config'
import Image from 'next/image'
import Link from 'next/link'
import { useContext, useState } from 'react'
import ReactShowMoreText from 'react-show-more-text'
import { toast } from 'react-toastify'
import { Context } from 'src/context'
import { ModalContext } from 'src/context/modals'
import { eventService } from 'src/services/eventService'
import { formatNumber, shorten } from 'src/utils'

export default function ArtworkDetail({ data }) {
const { setSignInOpen } = useContext(ModalContext)
const { account } = useContext(Context)
const [likeCount, setLikeCount] = useState(data?.artwork?.likes_aggregate?.aggregate?.count || 0)
const [isLiked, setIsLiked] = useState(data?.artwork?.likes?.length > 0)
const likeHandler = async () => {
try {
if (!account) {
setSignInOpen(true)
return
}
if (isLiked) {
setLikeCount((prev) => prev - 1)
setIsLiked(false)
await eventService.story.unlikeArtwork(data?.artwork?.id)
} else {
const newLikeCount = likeCount + 1
setLikeCount(newLikeCount)
setIsLiked(true)
await eventService.story.likeArtwork(data?.artwork?.id)
}
} catch (error) {
toast(error.message, {
type: 'error',
})
}
}
return (
<div>
<Image src={data.artwork.url} alt='' className='w-full aspect-square object-cover' width={500} height={500} />
<div className='mt-4'>
<div className='h-8 flex items-center justify-between'>
<div onClick={likeHandler} className='cursor-pointer flex items-center gap-1 text-sm font-semibold'>
{isLiked ? (
<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='red'>
<path
fillRule='evenodd'
clipRule='evenodd'
d='M3.17115 5.17232C3.92126 4.42244 4.93849 4.00118 5.99915 4.00118C7.0598 4.00118 8.07703 4.42244 8.82714 5.17232L9.99914 6.34332L11.1711 5.17232C11.5401 4.79028 11.9815 4.48555 12.4695 4.27592C12.9575 4.06628 13.4824 3.95594 14.0135 3.95132C14.5447 3.94671 15.0714 4.04791 15.563 4.24904C16.0545 4.45016 16.5012 4.74717 16.8767 5.12274C17.2523 5.49832 17.5493 5.94492 17.7504 6.43651C17.9516 6.92809 18.0528 7.45481 18.0481 7.98593C18.0435 8.51705 17.9332 9.04193 17.7235 9.52994C17.5139 10.018 17.2092 10.4593 16.8271 10.8283L9.99914 17.6573L3.17115 10.8283C2.42126 10.0782 2 9.06098 2 8.00032C2 6.93967 2.42126 5.92244 3.17115 5.17232V5.17232Z'
stroke='red'
strokeWidth='1.5'
strokeLinejoin='round'
/>
</svg>
) : (
<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'>
<path
fillRule='evenodd'
clipRule='evenodd'
d='M3.17115 5.17232C3.92126 4.42244 4.93849 4.00118 5.99915 4.00118C7.0598 4.00118 8.07703 4.42244 8.82714 5.17232L9.99914 6.34332L11.1711 5.17232C11.5401 4.79028 11.9815 4.48555 12.4695 4.27592C12.9575 4.06628 13.4824 3.95594 14.0135 3.95132C14.5447 3.94671 15.0714 4.04791 15.563 4.24904C16.0545 4.45016 16.5012 4.74717 16.8767 5.12274C17.2523 5.49832 17.5493 5.94492 17.7504 6.43651C17.9516 6.92809 18.0528 7.45481 18.0481 7.98593C18.0435 8.51705 17.9332 9.04193 17.7235 9.52994C17.5139 10.018 17.2092 10.4593 16.8271 10.8283L9.99914 17.6573L3.17115 10.8283C2.42126 10.0782 2 9.06098 2 8.00032C2 6.93967 2.42126 5.92244 3.17115 5.17232V5.17232Z'
stroke='#F6F6F6'
strokeWidth='1.5'
strokeLinejoin='round'
/>
</svg>
)}
{formatNumber(likeCount)}
</div>
<Dropdown>
<DropdownToggle>
<svg
xmlns='http://www.w3.org/2000/svg'
width='24'
height='24'
viewBox='0 0 24 24'
fill='none'
className='cursor-pointer'>
<path
d='M12 13C12.5523 13 13 12.5523 13 12C13 11.4477 12.5523 11 12 11C11.4477 11 11 11.4477 11 12C11 12.5523 11.4477 13 12 13Z'
stroke='white'
strokeWidth='2'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M12 6C12.5523 6 13 5.55228 13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5C11 5.55228 11.4477 6 12 6Z'
stroke='white'
strokeWidth='2'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M12 20C12.5523 20 13 19.5523 13 19C13 18.4477 12.5523 18 12 18C11.4477 18 11 18.4477 11 19C11 19.5523 11.4477 20 12 20Z'
stroke='white'
strokeWidth='2'
strokeLinecap='round'
strokeLinejoin='round'
/>
</svg>
</DropdownToggle>
<DropdownMenu customClass='right-0'>
<div className='p-4 rounded-lg bg-gray-900 text-white space-y-4 text-sm'>
<div
className='cursor-pointer'
onClick={() => {
navigator.share({
url: location.href,
})
}}>
Share
</div>
{data.story_ip_asset.ip_asset_id && (
<Link
className='block'
target='_blank'
href={`${getConfig().STORY_EXPLORER_URL}/ipa/${data.story_ip_asset.ip_asset_id}`}>
View on Story Protocol
</Link>
)}
</div>
</DropdownMenu>
</Dropdown>
</div>
<div className='mt-4 space-y-1.5'>
<div className='text-lg font-medium'>{data.artwork.name}</div>
<div className='w-fit text-sm'>
by{' '}
<Link target='_blank' href={`/artist/${data?.artwork?.creator?.slug}`} className='text-text-brand-defaul'>
{data?.artwork?.creator?.pen_name || data?.artwork?.authorizer_user?.nickname || 'Unknown creator'}
</Link>
</div>
<div className='h-[18px] flex items-center gap-1.5 leading-tight'>
IP ID:{' '}
<Link
target='_blank'
href={`${getConfig().STORY_EXPLORER_URL}/ipa/${data.story_ip_asset.ip_asset_id}`}
className='text-text-brand-defaul'>
{shorten(data?.story_ip_asset?.ip_asset_id)}
</Link>{' '}
<Copy2Clipboard text={data?.story_ip_asset?.ip_asset_id} />
</div>
</div>
<div className='mt-4'>
<ReactShowMoreText
lines={2}
more='View more'
less='View less'
className='text-sm'
anchorClass='text-text-info-primary text-sm font-medium'
expanded={false}
truncatedEndingComponent={'... '}>
<div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(data.artwork.description) }}></div>
</ReactShowMoreText>
</div>
</div>
</div>
)
}
35 changes: 23 additions & 12 deletions src/components/pages/campaigns/campaign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,19 @@ export default function CampaignPage() {
}
}
return (
<div className='pk-container'>
<div className='sticky md:top-[80px] top-[54px] pb-8 pt-5 md:pt-8 bg-gray-50'>
<div className='bg-background text-white pk-container'>
<div className='sticky md:top-[80px] top-[54px] p-4 md:pt-8 bg-background '>
<div className='flex md:items-center justify-between flex-wrap flex-col md:flex-row gap-4'>
<div className='text-lg leading-[26px] md:text-xl font-medium whitespace-nowrap'>
<div onClick={() => router.back()} className='flex z-10 items-center gap-3 text-xl font-medium '>
<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'>
<path
d='M15 17L10 12L15 7'
stroke='white'
strokeWidth='1.5'
strokeLinecap='round'
strokeLinejoin='round'
/>
</svg>
{t('Campaign')} <span className=''>{` (${list.length})`}</span>
</div>
{list.length > 0 && (
Expand Down Expand Up @@ -147,7 +156,7 @@ export default function CampaignPage() {
</div>
</div>
{list.length > 0 ? (
<div className='grid mt-0.5 grid-cols-1 lg:grid-cols-2 gap-4 xl:gap-x-8 xl:gap-y-4 xl:grid-cols-3'>
<div className='grid mt-0.5 grid-cols-1 lg:grid-cols-2 gap-4 xl:gap-x-8 xl:gap-y-4 xl:grid-cols-3 p-4'>
{list?.map((campaign, index) => {
const expImage =
campaign.campaign_chain?.punkga_config?.reward_point_name == 'KP'
Expand All @@ -158,7 +167,7 @@ export default function CampaignPage() {
return (
<div
key={index}
className='cursor-pointer p-4 flex gap-5 bg-white border border-border-teriary rounded-mlg md:min-h-[206px] min-h-[229px] hover:shadow-[0px_4px_4px_0px_rgba(0,0,0,0.10)]'
className='cursor-pointer p-4 flex gap-5 bg-neutral-black border border-neutral-950 rounded-mlg md:min-h-[206px] min-h-[200px] hover:shadow-[0px_4px_4px_0px_rgba(0,0,0,0.10)]'
onClick={() => clickHandler(campaign.slug)}>
<div className='flex flex-col justify-between flex-1 max-w-[calc(100%-156px)]'>
<div className='flex flex-col'>
Expand All @@ -185,11 +194,11 @@ export default function CampaignPage() {
{campaign[locale].name}
</div>
<div
className=' text-text-teriary mt-1 xl:mt-3 line-clamp-3 max-h-[60px] overflow-hidden text-sm max-w'
className=' text-text-quatenary mt-1 xl:mt-3 line-clamp-3 max-h-[60px] overflow-hidden text-sm max-w'
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(campaign[locale].description) }}></div>
</div>
</div>
<div className='text-sm text-text-teriary mt-3'>
<div className='text-sm text-text-quatenary mt-3'>
{moment(campaign.start_date).isAfter() ? (
<Countdown
date={campaign.start_date}
Expand Down Expand Up @@ -252,7 +261,7 @@ export default function CampaignPage() {
</div>
</div>
<div className='flex flex-col gap-1.5 items-center'>
<div className='reward rounded-mlg bg-[#F0F0F0] p-2.5 w-[130px] shrink-0 min-h-[130px] gap-1.5 flex flex-col justify-center items-center'>
<div className='reward rounded-mlg bg-neutral-900 p-2.5 w-[130px] shrink-0 min-h-[130px] gap-1.5 flex flex-col justify-center items-center'>
{campaign?.reward?.nft?.nft_name ? (
<>
<Image
Expand All @@ -262,22 +271,24 @@ export default function CampaignPage() {
alt=''
className='w-[80px] h-[80px] rounded-lg object-cover'
/>
<div className='text-xs leading-[18px] text-text-teriary w-[110px] truncate text-center'>
<div className='text-xs leading-[18px] text-text-quatenary w-[110px] truncate text-center'>
{campaign?.reward?.nft?.nft_name}
</div>
</>
) : (
<Image src={expImage} width={80} height={80} alt='' className='w-[80px] h-[80px] rounded-lg' />
)}
{!!campaign?.reward?.xp && campaign?.reward?.nft?.nft_name ? (
<div className='rounded pt-0.5 bg-neutral-white min-w-[76px] text-center text-text-brand-defaul font-bold text-xs leading-[15px]'>{`+ ${campaign?.reward?.xp} ${campaign.campaign_chain?.punkga_config?.reward_point_name||'XP'}`}</div>
<div className='rounded pt-0.5 bg-neutral-white min-w-[76px] text-center text-text-brand-defaul font-bold text-xs leading-[15px]'>{`+ ${
campaign?.reward?.xp
} ${campaign.campaign_chain?.punkga_config?.reward_point_name || 'XP'}`}</div>
) : (
<div className='text-text-teriary text-center font-semibold'>{`+ ${campaign?.reward?.xp || 0} ${
<div className='text-text-quatenary text-center font-semibold'>{`+ ${campaign?.reward?.xp || 0} ${
campaign.campaign_chain?.punkga_config?.reward_point_name || 'XP'
}`}</div>
)}
</div>
<div className='text-xs text-text-teriary text-center md:leading-[18px]'>
<div className='text-xs text-text-quatenary text-center md:leading-[18px]'>
{t('Bonus to')} {t('1st place')}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/homepage/mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function MobileVersion() {
}
}, [selectedTags.length])
return (
<div className='bg-background py-4 text-white'>
<div className='bg-background py-4 text-white min-h-screen'>
<div className='space-y-4'>
<Link
href={config.ADMIN_URL}
Expand Down
6 changes: 4 additions & 2 deletions src/components/pages/homepage/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,11 @@ export default function Post({ data }) {
</div>
</div>
<div className='space-y-2'>
<div className='w-full h-full block aspect-square'>
<Link
href={`/artworks/${data.artwork?.story_artworks?.[0]?.id}`}
className='w-full h-full block aspect-square'>
<Image src={data.artwork.url} width={400} height={400} alt='' className='w-full h-full' />
</div>
</Link>
<div className='text-xs font-semibold text-neutral-400 leading-8'>
{likeCount} {pluralize('likes', likeCount)}
</div>
Expand Down
37 changes: 37 additions & 0 deletions src/context/artworkList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { createContext, useState } from 'react'
export const ArtworkListContext = createContext<{
data: {
list: any[]
offset: number
remaining: boolean
}
setData?: (data: any) => void
}>({
data: {
list: [],
offset: 0,
remaining: true,
},
setData: () => {},
})
function ArtworkListProvider({ children }) {
const [artworkData, setArtworkData] = useState({
list: [],
offset: 0,
remaining: true,
})
return (
<ArtworkListContext.Provider
value={{
data: artworkData,
setData: (newData) => {
setArtworkData((prev) => {
return { ...prev, ...newData }
})
},
}}>
{children}
</ArtworkListContext.Provider>
)
}
export default ArtworkListProvider
7 changes: 5 additions & 2 deletions src/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ListProvider from './characterList'
import ModalProvider from './modals'
import PostListProvider from './postList'
import ComicListProvider from './comicList'
import ArtworkListProvider from './artworkList'

const queryClient = new QueryClient()

Expand Down Expand Up @@ -506,8 +507,10 @@ function ContextProvider({ children }: any) {
<ListProvider>
<PostListProvider>
<ComicListProvider>
{location.pathname.includes('events/ava-2024') && <BackgroundAudio />}
{children}
<ArtworkListProvider>
{location.pathname.includes('events/ava-2024') && <BackgroundAudio />}
{children}
</ArtworkListProvider>
</ComicListProvider>
</PostListProvider>
</ListProvider>
Expand Down
Loading

0 comments on commit fde271c

Please sign in to comment.