-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #618 from us3r-network/F-exploreHotCommunities-shi…
…xuewen feat: explore hot communities
- Loading branch information
Showing
5 changed files
with
154 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
apps/u3/src/components/explore/community/CommunityItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { ComponentPropsWithRef } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { CommunityInfo } from '@/services/community/types/community'; | ||
import { cn } from '@/lib/utils'; | ||
import JoinCommunityBtn from '@/components/community/JoinCommunityBtn'; | ||
|
||
export default function CommunityItem({ | ||
className, | ||
communityInfo, | ||
...props | ||
}: ComponentPropsWithRef<'div'> & { | ||
communityInfo: CommunityInfo; | ||
}) { | ||
const navigate = useNavigate(); | ||
const { logo, name, description, memberInfo, types } = communityInfo || {}; | ||
return ( | ||
<div | ||
className={cn( | ||
'h-[160px] flex p-[20px] box-border items-center gap-[20px] bg-[#1B1E23] rounded-[20px] cursor-pointer', | ||
'max-sm:p-[10px] max-sm:h-[120px]', | ||
className | ||
)} | ||
onClick={() => { | ||
navigate(`/community/${communityInfo.channelId}`); | ||
}} | ||
{...props} | ||
> | ||
<img | ||
src={logo} | ||
alt="" | ||
className="w-[120px] h-[120px] rounded-[20px] max-sm:w-[100px] max-sm:h-[100px]" | ||
/> | ||
<div className="flex-1 flex h-full flex-col justify-between items-start"> | ||
<div className="w-full flex justify-between items-start gap-[10px]"> | ||
<div className="flex-1 flex flex-col gap-[10px]"> | ||
{types?.length > 0 && ( | ||
<div className="text-[#718096] text-[12px] font-normal line-clamp-1"> | ||
{types.reduce((acc, cur) => { | ||
return `${acc}, ${cur}`; | ||
})} | ||
</div> | ||
)} | ||
<div className="text-[#FFF] text-[16px] font-medium">{name}</div> | ||
</div> | ||
<JoinCommunityBtn communityInfo={communityInfo} /> | ||
</div> | ||
<div className="flex gap-[10px] items-center"> | ||
{memberInfo?.newPostNumber > 0 && ( | ||
<div className="text-[#718096] text-[12px] font-normal leading-[15px]"> | ||
{memberInfo?.newPostNumber} new posts | ||
</div> | ||
)} | ||
{memberInfo?.totalNumber > 0 && ( | ||
<div className="text-[#718096] text-[12px] font-normal leading-[15px]"> | ||
{memberInfo?.totalNumber} members | ||
</div> | ||
)} | ||
</div> | ||
<div className="text-[#FFF] text-[14px] font-normal leading-[20px] line-clamp-2 max-sm:line-clamp-1"> | ||
{description} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
51 changes: 51 additions & 0 deletions
51
apps/u3/src/components/explore/community/HotCommunities.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import Title from '../Title'; | ||
import Loading from '../../common/loading/Loading'; | ||
import { cn } from '@/lib/utils'; | ||
import { CommunityInfo } from '@/services/community/types/community'; | ||
import CommunityItem from './CommunityItem'; | ||
|
||
export type HotCommunitiesData = Array<CommunityInfo>; | ||
|
||
export default function HotCommunities({ | ||
communities, | ||
isLoading, | ||
}: { | ||
communities: HotCommunitiesData; | ||
isLoading: boolean; | ||
}) { | ||
const navigate = useNavigate(); | ||
return ( | ||
<div className="w-full"> | ||
<Title | ||
text="Hot Communities" | ||
viewAllAction={() => { | ||
navigate(`/communities`); | ||
}} | ||
/> | ||
<div className={cn('w-full mt-[20px]', 'max-sm:mt-[10px]')}> | ||
{isLoading ? ( | ||
<div | ||
className={cn( | ||
'w-full h-full flex justify-center items-center', | ||
'max-sm:h-[430px]' | ||
)} | ||
> | ||
<Loading /> | ||
</div> | ||
) : ( | ||
<div | ||
className={cn( | ||
'w-full grid gap-[20px] grid-cols-3', | ||
'max-sm:grid-cols-1 max-sm:gap-[10px]' | ||
)} | ||
> | ||
{communities.map((item) => { | ||
return <CommunityItem key={item.id} communityInfo={item} />; | ||
})} | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters