Skip to content

Commit

Permalink
Merge pull request #536 from us3r-network/u3-dev
Browse files Browse the repository at this point in the history
release U3 giveaway
  • Loading branch information
qbig authored Feb 9, 2024
2 parents 0580d96 + 32bc854 commit 7dc0585
Show file tree
Hide file tree
Showing 38 changed files with 2,117 additions and 39 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
56 changes: 32 additions & 24 deletions apps/u3/src/components/layout/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import styled from 'styled-components';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.min.css';
import { isMobile } from 'react-device-detect';
import { useLocation } from 'react-router-dom';
import { useLocation, useSearchParams } from 'react-router-dom';
import { useAuthentication } from '@us3r-network/auth-with-rainbowkit';
import { MEDIA_BREAK_POINTS } from '../../constants/index';
import Main from './Main';
Expand All @@ -20,37 +20,45 @@ import MobileHeader from './mobile/MobileHeader';
import MobileNav from './mobile/MobileNav';
import { MobileGuide } from './mobile/MobileGuide';
import AddPostMobile from '../social/AddPostMobile';
import ClaimOnboard from '../onboard/Claim';

function Layout() {
const { ready } = useAuthentication();
const location = useLocation();
const [searchParams, setSearchParams] = useSearchParams();
const claim = searchParams.get('claim');

useGAPageView();

return (
<LayoutWrapper id="layout-wrapper">
{ready ? isMobile ? <MobileHeader /> : <Menu /> : null}
{ready && isMobile ? <MobileNav /> : null}
{isMobile ? (
<MobileContentBox>
<Main />
<div className="fixed right-[20px] bottom-[80px]">
<AddPostMobile />
</div>
</MobileContentBox>
) : (
<RightBox>
<RightInner id="layout-main-wrapper">
{location.pathname.includes('social') ? (
<Main />
) : (
<MainBox className="main-box">
<>
{ready ? isMobile ? <MobileHeader /> : <Menu /> : null}
{ready && isMobile ? <MobileNav /> : null}
{isMobile ? (
<MobileContentBox>
<Main />
<div className="fixed right-[20px] bottom-[80px]">
<AddPostMobile />
</div>
</MobileContentBox>
) : (
<RightBox>
<RightInner id="layout-main-wrapper">
{location.pathname.includes('social') ? (
<Main />
</MainBox>
)}
</RightInner>
<DappMenu />
</RightBox>
)}
<MobileGuide />
) : (
<MainBox className="main-box">
<Main />
</MainBox>
)}
</RightInner>
<DappMenu />
</RightBox>
)}
<MobileGuide />
{claim === 'true' && <ClaimOnboard />}
</>
<ToastContainer
position="top-right"
autoClose={3000}
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;
`;
Loading

0 comments on commit 7dc0585

Please sign in to comment.