Skip to content

Commit

Permalink
Merge pull request #484 from 0xMillz/profile-dao-links
Browse files Browse the repository at this point in the history
feat: make DAO list linkable in user profile
  • Loading branch information
neokry authored Oct 18, 2024
2 parents 470eb01 + 0990a96 commit 6413968
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { Box } from '@zoralabs/zord'
import { exploreSkeleton } from '../Explore/Explore.css'
import { GridContainer } from './DaoFeed'

export const DaoFeedCardSkeleton = ({ key }: { key?: any }) => {
export const DaoFeedCardSkeleton = () => {
return (
<Box
key={key}
borderRadius="curved"
backgroundColor="background2"
width={'100%'}
aspectRatio={1 / 1}
aspectRatio={1}
position="relative"
className={exploreSkeleton}
/>
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/modules/dashboard/DaoAuctionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { auctionAbi } from 'src/data/contract/abis'
import { useCountdown, useIsMounted } from 'src/hooks'
import { AddressType } from 'src/typings'

import { chainIdToSlug } from '../../utils/helpers'
import { overflowEllipsis } from '../auction/components/Auction.css'
import { AuctionPaused } from './AuctionPaused'
import { BidActionButton } from './BidActionButton'
Expand Down Expand Up @@ -75,7 +76,7 @@ export const DaoAuctionCard = (props: DaoAuctionCardProps) => {
const handleSelectAuction = () => {
router.push(`/dao/${currentChainSlug}/${tokenAddress}`)
}
const currentChainSlug = PUBLIC_ALL_CHAINS.find((chain) => chain.id === chainId)?.slug
const currentChainSlug = chainIdToSlug(chainId)

if (!currentAuction) {
return (
Expand Down
45 changes: 31 additions & 14 deletions apps/web/src/pages/profile/[user].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useLayoutStore } from 'src/stores'
import { useChainStore } from 'src/stores/useChainStore'
import { artworkSkeleton } from 'src/styles/Artwork.css'
import { getEnsAddress } from 'src/utils/ens'
import { walletSnippet } from 'src/utils/helpers'
import { chainIdToSlug, walletSnippet } from 'src/utils/helpers'

import { NextPageWithLayout } from '../_app'
import { UserTokensResponse } from '../api/profile/[network]/[user]/tokens'
Expand Down Expand Up @@ -52,8 +52,6 @@ const ProfilePage: NextPageWithLayout<ProfileProps> = ({ userAddress }) => {

const { handlePageBack, handlePageForward } = usePagination(tokens?.hasNextPage)

const daosString = daos?.map((x) => x.name).join(', ')

return (
<Flex
align={'center'}
Expand Down Expand Up @@ -118,17 +116,36 @@ const ProfilePage: NextPageWithLayout<ProfileProps> = ({ userAddress }) => {
<Text mr="x4" fontWeight={'display'}>
DAOs
</Text>
{isLoading ? (
<Box
backgroundColor="background2"
h="x6"
w="100%"
className={artworkSkeleton}
borderRadius="normal"
/>
) : (
<Text color="text3">{daosString || 'No DAO tokens owned.'}</Text>
)}
{
isLoading ? (
<Box
backgroundColor="background2"
h="x6"
w="100%"
className={artworkSkeleton}
borderRadius="normal"
/>
) : (
daos && daos?.length > 0 ? (
<Text color="text3">
{daos.map((dao, index) => (
<>
<Link
href={`https://nouns.build/dao/${chainIdToSlug(dao.chainId)}/${dao.collectionAddress}`}
style={{ textDecoration: 'none', color: 'inherit' }}
className='profile-dao-links'
>
{dao.name}
</Link>
{index < daos.length - 1 && ', '}
</>
))}
</Text>
) : (
<Text>No DAO tokens owned.</Text>
)
)
}
</Flex>
</Box>
{!isMobile && (
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import isEqual from 'lodash/isEqual'
import { isAddress } from 'viem'

import { Duration } from 'src/typings'
import { PUBLIC_ALL_CHAINS } from '../constants/defaultChains'

/**
*
Expand Down Expand Up @@ -276,9 +277,13 @@ export const isPossibleMarkdown = (text: string) => {
/(?:\*\*[^\*]+\*\*)|(?:__[^\_]+__)|(?:\*[^\*]+\*)|(?:_[^\_]+_)|(?:\#[^\#]+\#)|(?:\!\[[^\]]*\]\([^\)]+\))|(?:\[[^\]]+\]\([^\)]+\))/g
return markdownRegex.test(text)
}

export function maxChar(str: string, maxLength: number) {
if (str.length <= maxLength) {
return str
}
return str.slice(0, maxLength) + '...'
}

export const chainIdToSlug = (chainId: number) =>
PUBLIC_ALL_CHAINS.find((chain) => chain.id === chainId)?.slug
8 changes: 8 additions & 0 deletions packages/zoralabs-zord/src/theme.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,11 @@ globalStyle('h1,h2,h3,h4,h5,h6,p', {
padding: 0,
margin: 0,
})

globalStyle('.profile-dao-links', {
marginRight: '0 !important',
})

globalStyle('.profile-dao-links::after', {
content: 'none !important',
})

0 comments on commit 6413968

Please sign in to comment.