Skip to content

Commit

Permalink
Merge pull request #531 from us3r-network/u3-degen
Browse files Browse the repository at this point in the history
U3 degen
  • Loading branch information
friendlysxw authored Feb 8, 2024
2 parents 6ab3c45 + b18a307 commit b956474
Show file tree
Hide file tree
Showing 33 changed files with 1,756 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps/u3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4",
Expand Down
34 changes: 34 additions & 0 deletions apps/u3/src/components/layout/LoginButtonV2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useNavigate } from 'react-router-dom';
import { UserAvatar, UserName } from '@us3r-network/profile';
import useLogin from '../../hooks/shared/useLogin';

export default function LoginButtonV2() {
const { isLogin, login } = useLogin();
const navigate = useNavigate();

return (
<button
type="button"
className="flex items-center gap-[8px] rounded-[12px] text-white text-[16px] font-bold"
onClick={() => {
if (isLogin) {
navigate('/u');
} else {
login();
}
}}
>
{isLogin ? (
<>
<UserAvatar
className="w-[40px] h-[40px] flex-shrink-0"
style={{ width: '40px', height: '40px' }}
/>
<UserName className="text-[#FFF] text-[16px] font-normal" />
</>
) : (
<span className="wl-user-button_no-login-text">Login</span>
)}
</button>
);
}
18 changes: 13 additions & 5 deletions apps/u3/src/components/layout/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @Description: file description
*/
import styled from 'styled-components';
import { useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { useMemo, useState } from 'react';
import LoginButton from './LoginButton';
import Nav, { NavWrapper, PcNavItem, NavItemIconBox } from './Nav';
Expand All @@ -21,7 +21,8 @@ import { useFarcasterCtx } from '@/contexts/social/FarcasterCtx';
export default function Menu() {
const [isOpen, setIsOpen] = useState(false);
const navigate = useNavigate();

const { pathname } = useLocation();
const isCommunityRoute = pathname.includes('/community/');
return (
<MenuWrapper
onMouseEnter={() => setIsOpen(true)}
Expand Down Expand Up @@ -63,9 +64,11 @@ export default function Menu() {
<MessageButton />
<ContactUsButton />
</NavWrapper>
<LoginButtonBox>
<LoginButton onlyIcon={!isOpen} />
</LoginButtonBox>
{!isCommunityRoute && (
<LoginButtonBox>
<LoginButton onlyIcon={!isOpen} />
</LoginButtonBox>
)}
</FooterBox>
</MenuWrapper>
);
Expand Down Expand Up @@ -93,11 +96,16 @@ function ChannelItem({ parent_url }: { parent_url: string }) {
return getChannelFromUrl(parent_url);
}, [parent_url, getChannelFromUrl]);

const toCommunityChannelIds = ['degen'];
if (!item) return null;

return (
<div
onClick={() => {
if (toCommunityChannelIds.includes(item.channel_id)) {
navigate(`community/${item.channel_id}`);
return;
}
navigate(`/social/channel/${item.channel_id}`);
}}
className="cursor-pointer relative"
Expand Down
6 changes: 6 additions & 0 deletions apps/u3/src/components/news/links/LinksPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type LinksPageProps = {
hasMore?: boolean;
links?: Array<LinkListItem>;
getMore?: () => void;
quickView?: (link: LinkListItem) => void;
currentSearchParams?: {
keywords?: string;
orderBy?: any;
Expand All @@ -49,6 +50,7 @@ export default function LinksPage({
currentSearchParams,
searchParamsChange,
getMore,
quickView,
}: LinksPageProps) {
const navigate = useNavigate();
const { group, link } = useParams();
Expand Down Expand Up @@ -162,6 +164,10 @@ export default function LinksPage({
data={links}
activeLink={selectLink}
onItemClick={(item) => {
if (quickView) {
quickView(item);
return;
}
navigate(
`${ROUTE_PREFIX}/${group}/${encodeLinkURL(
item?.url
Expand Down
133 changes: 133 additions & 0 deletions apps/u3/src/components/news/links/community/CommunityLinks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
* @Author: shixuewen [email protected]
* @Date: 2022-07-05 15:35:42
* @LastEditors: bufan [email protected]
* @LastEditTime: 2023-12-06 10:36:45
* @Description: 首页任务看板
*/
import styled from 'styled-components';
// import { useNavigate } from 'react-router-dom';
import InfiniteScroll from 'react-infinite-scroll-component';
import Loading from '../../../common/loading/Loading';
import ListScrollBox from '../../../common/box/ListScrollBox';
import { MainWrapper } from '../../../layout/Index';
import NoResult from '../../../layout/NoResult';
import { LinksPageProps } from '../LinksPage';
import LinksList from './LinksList';

export default function CommunityLinks({
loading,
hasMore,
links,
// currentSearchParams,
// searchParamsChange,
getMore,
quickView,
}: LinksPageProps) {
// const navigate = useNavigate();

return (
<Box>
{(() => {
if (loading) {
return (
<LinksWrapper>
<div className="loading">
<Loading />
</div>
</LinksWrapper>
);
}
if (links.length === 0) {
return (
<LinksWrapper>
<NoResult />
</LinksWrapper>
);
}

return (
<ListBox id="links-scroll-wrapper">
<InfiniteScroll
style={{ overflow: 'hidden' }}
dataLength={links?.length || 0}
next={() => {
if (loading) return;
getMore();
}}
hasMore={hasMore}
scrollThreshold="600px"
loader={
<LoadingMoreWrapper>
<Loading />
</LoadingMoreWrapper>
}
scrollableTarget="links-scroll-wrapper"
>
<LinksList
data={links}
onItemClick={(item) => {
// navigate(item?.url);
if (quickView) {
quickView(item);
return;
}
window.open(item?.url, '_blank');
}}
/>
</InfiniteScroll>
</ListBox>
);
})()}
</Box>
);
}

const Box = styled(MainWrapper)`
width: 100%;
display: flex;
flex-direction: column;
gap: 24px;
`;
const LinksWrapper = styled.div`
border-radius: 20px;
overflow: hidden;
display: flex;
flex-grow: 1;
& .loading {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
`;
const ListBox = styled(ListScrollBox)`
width: 100%;
height: calc(100%);
overflow: scroll;
& .load-more {
margin: 20px;
text-align: center;
color: #718096;
> button {
cursor: pointer;
background-color: inherit;
color: #fff;
border: 1px solid gray;
border-radius: 5px;
padding: 10px 20px;
outline: none;
}
}
`;

const LoadingMoreWrapper = styled.div`
width: 100%;
display: flex;
justify-content: center;
align-items: center;
margin-top: 20px;
`;
41 changes: 41 additions & 0 deletions apps/u3/src/components/news/links/community/LinksList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* @Author: shixuewen [email protected]
* @Date: 2022-12-08 14:04:04
* @LastEditors: bufan [email protected]
* @LastEditTime: 2023-11-14 17:42:47
* @Description: file description
*/
import styled from 'styled-components';
import { LinkListItem } from 'src/services/news/types/links';
import AnimatedListItem, {
useAnimatedListTransition,
} from '../../../common/animation/AnimatedListItem';
import ListItem from './LinksListItem';

export type LinksListProps = {
data: LinkListItem[];
onItemClick?: (item: LinkListItem) => void;
};
export default function LinksList({ data, onItemClick }: LinksListProps) {
const transitions = useAnimatedListTransition(data);
return (
<Wrapper>
{transitions((styles, item) => {
return (
<AnimatedListItem key={item.url} styles={{ ...styles }}>
<ListItem
data={item}
onClick={() => onItemClick && onItemClick(item)}
/>
</AnimatedListItem>
);
})}
</Wrapper>
);
}
const Wrapper = styled.div`
width: 100%;
display: flex;
flex-direction: column;
gap: 20px;
`;
84 changes: 84 additions & 0 deletions apps/u3/src/components/news/links/community/LinksListItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* @Author: shixuewen [email protected]
* @Date: 2023-03-01 10:08:00
* @LastEditors: bufan [email protected]
* @LastEditTime: 2023-11-15 16:43:21
* @Description: file description
*/
import styled, { StyledComponentPropsWithRef } from 'styled-components';
import { LinkListItem } from 'src/services/news/types/links';
import { useMemo } from 'react';
import EllipsisText from '../../../common/text/EllipsisText';
import LinkLogo from '../LinkLogo';

type Props = StyledComponentPropsWithRef<'div'> & {
data: LinkListItem;
};
export default function ListItem({ data, ...otherProps }: Props) {
const { url, metadata } = data;
const platformLogo = useMemo(() => metadata?.icon || '', [metadata]);
return (
<CardWrapper {...otherProps}>
<CardBody>
<Logo logo={platformLogo} link={url} />
<Right>
<Title>{metadata?.title}</Title>
<Url>{url}</Url>
</Right>
</CardBody>
</CardWrapper>
);
}

const CardWrapper = styled.div`
width: 100%;
background: #1b1e23;
overflow: hidden;
cursor: pointer;
`;
const CardBody = styled.div`
width: 100%;
height: 100%;
box-sizing: border-box;
display: flex;
align-items: center;
gap: 10px;
transition: all 0.3s;
&:hover {
transform: scale(1.05);
}
`;
const Logo = styled(LinkLogo)`
width: 48px;
height: 48px;
border-radius: 40px;
`;
const Right = styled.div`
width: 0;
flex: 1;
display: flex;
flex-direction: column;
gap: 6px;
`;
const Title = styled(EllipsisText)`
color: #fff;
width: 100%;
/* medium-16 */
font-family: Rubik;
font-size: 16px;
font-style: normal;
font-weight: 500;
line-height: normal;
text-align: left;
`;
const Url = styled(EllipsisText)`
color: var(--718096, #718096);
width: 100%;
/* Regular-16 */
font-family: Rubik;
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: normal;
text-align: left;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const Wrapper = styled.div`
background: #1b1e23;
border: 1px solid #39424c;
border-radius: 10px;
cursor: pointer;
`;
const Title = styled(EllipsisText)`
font-weight: 500;
Expand Down
Loading

0 comments on commit b956474

Please sign in to comment.