From c2852c6591ac768f6bea01a5b09a5e535fba0844 Mon Sep 17 00:00:00 2001 From: shixuewen Date: Fri, 26 Jan 2024 13:14:27 +0800 Subject: [PATCH 1/3] feat: nav icon size --- apps/u3/src/components/layout/Nav.tsx | 37 +++++++++++++++---- apps/u3/src/components/layout/menu.tsx | 10 ++--- .../notification/MobileNotificationNavBtn.tsx | 6 +-- .../notification/NotificationNavBtn.tsx | 6 +-- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/apps/u3/src/components/layout/Nav.tsx b/apps/u3/src/components/layout/Nav.tsx index e8e77865..f13ff9b4 100644 --- a/apps/u3/src/components/layout/Nav.tsx +++ b/apps/u3/src/components/layout/Nav.tsx @@ -5,13 +5,14 @@ * @LastEditTime: 2023-10-30 14:54:49 * @Description: file description */ -import { useCallback, useRef, useState } from 'react'; +import { ComponentPropsWithRef, useCallback, useRef, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import styled from 'styled-components'; import { isMobile } from 'react-device-detect'; import useLogin from '../../hooks/shared/useLogin'; import { CustomNavObject, navs } from '../../route/nav'; import useRoute from '../../route/useRoute'; +import { cn } from '@/lib/utils'; type Props = { onlyIcon?: boolean; @@ -72,7 +73,7 @@ export default function Nav({ onlyIcon }: Props) { isActive={isActive} onClick={() => navigate(nav.route.path)} > - {nav.icon} + {nav.icon} {!isMobile && renderNavItemText(nav)} ); @@ -116,9 +117,9 @@ export default function Nav({ onlyIcon }: Props) { isActive={groupIsActive} onClick={() => handleGroupClick(item.key)} > - + {item.icon} - + {!isMobile && renderNavItemText(item)} @@ -179,16 +180,36 @@ export const PcNavItem = styled.div<{ isActive?: boolean; disabled?: boolean }>` cursor: not-allowed; `}; `; -export const PcNavItemIconBox = styled.div<{ isActive?: boolean }>` - flex-shrink: 0; +export function NavItemIconBox({ + isActive, + className, + children, + ...props +}: ComponentPropsWithRef<'div'> & { isActive?: boolean }) { + return ( +
+ {children} +
+ ); +} +export const NavItemIconInner = styled.div<{ isActive?: boolean }>` + width: 100%; + height: 100%; svg { + width: 100%; + height: 100%; path { stroke: ${({ isActive }) => (isActive ? `#fff` : '#718096')}; transition: all 0.3s ease-out; } } - transition: all 0.3s ease-out; - position: relative; `; export const PcNavItemTextBox = styled.div` overflow: hidden; diff --git a/apps/u3/src/components/layout/menu.tsx b/apps/u3/src/components/layout/menu.tsx index 1a1b389f..3e5030d9 100644 --- a/apps/u3/src/components/layout/menu.tsx +++ b/apps/u3/src/components/layout/menu.tsx @@ -9,7 +9,7 @@ import styled from 'styled-components'; import { useNavigate } from 'react-router-dom'; import { useState } from 'react'; import LoginButton from './LoginButton'; -import Nav, { NavWrapper, PcNavItem, PcNavItemIconBox } from './Nav'; +import Nav, { NavWrapper, PcNavItem, NavItemIconBox } from './Nav'; import { ReactComponent as LogoIconSvg } from '../common/assets/imgs/logo-icon.svg'; import { ReactComponent as MessageChatSquareSvg } from '../common/assets/svgs/message-chat-square.svg'; import { ReactComponent as ContactUsSvg } from '../common/assets/svgs/contact-us.svg'; @@ -71,9 +71,9 @@ function ContactUsButton() { switchNavModal(NavModalName.ContactUs); }} > - + - + {renderNavItemText('Contact US')} @@ -92,9 +92,9 @@ function MessageButton() { switchNavModal(NavModalName.Message); }} > - + - + {renderNavItemText('Message')} diff --git a/apps/u3/src/components/notification/MobileNotificationNavBtn.tsx b/apps/u3/src/components/notification/MobileNotificationNavBtn.tsx index 6baf57af..8a154623 100644 --- a/apps/u3/src/components/notification/MobileNotificationNavBtn.tsx +++ b/apps/u3/src/components/notification/MobileNotificationNavBtn.tsx @@ -1,7 +1,7 @@ import { useIsAuthenticated } from '@us3r-network/auth-with-rainbowkit'; import { useMemo } from 'react'; import { useNavigate } from 'react-router-dom'; -import { PcNavItem, PcNavItemIconBox } from '../layout/Nav'; +import { PcNavItem, NavItemIconBox } from '../layout/Nav'; import { ReactComponent as BellSvg } from '../../route/svgs/bell.svg'; import { useNotificationStore, @@ -58,7 +58,7 @@ function NotificationButtonStyled({ }) { return ( - + {unreadCount > 0 && (
)} - + ); } diff --git a/apps/u3/src/components/notification/NotificationNavBtn.tsx b/apps/u3/src/components/notification/NotificationNavBtn.tsx index c69a7c16..844312d8 100644 --- a/apps/u3/src/components/notification/NotificationNavBtn.tsx +++ b/apps/u3/src/components/notification/NotificationNavBtn.tsx @@ -6,7 +6,7 @@ * @Description: file description */ import { useIsAuthenticated } from '@us3r-network/auth-with-rainbowkit'; -import { PcNavItem, PcNavItemIconBox } from '../layout/Nav'; +import { PcNavItem, NavItemIconBox } from '../layout/Nav'; import { ReactComponent as BellSvg } from '../../route/svgs/bell.svg'; import { useNotificationStore, @@ -63,7 +63,7 @@ function NotificationButtonStyled({ const { renderNavItemText } = useNav(); return ( - + {unreadCount > 0 && (
)} - + {renderNavItemText(`Notifications`)} {unreadCount > 0 && (
Date: Fri, 26 Jan 2024 15:44:05 +0800 Subject: [PATCH 2/3] feat: cast ui optimization --- apps/u3/src/components/social/Embed.tsx | 79 ++++++++----- apps/u3/src/components/social/PostCard.tsx | 110 +----------------- .../social/farcaster/U3ZoraMinter.tsx | 54 ++++++--- apps/u3/src/container/social/SocialLayout.tsx | 17 +-- 4 files changed, 94 insertions(+), 166 deletions(-) diff --git a/apps/u3/src/components/social/Embed.tsx b/apps/u3/src/components/social/Embed.tsx index a14948d1..b2445fea 100644 --- a/apps/u3/src/components/social/Embed.tsx +++ b/apps/u3/src/components/social/Embed.tsx @@ -10,12 +10,7 @@ import { FarCastEmbedMeta, FarCastEmbedMetaCast, } from '../../services/social/types'; -import { - PostCardCastWrapper, - PostCardEmbedWrapper, - PostCardImgWrapper, - PostCardNftWrapper, -} from './PostCard'; +import { PostCardEmbedWrapper, PostCardImgWrapper } from './PostCard'; import { getFarcasterEmbedCast, getFarcasterEmbedMetadata, @@ -94,13 +89,14 @@ export default function Embed({ } return ( - +
{embedImgs.length > 0 && ( <> {embedImgs.map((img, idx) => ( // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions )} -
+
{[...metadata, ...metadataCasts].map( (item: FarCastEmbedMeta | FarCastEmbedMetaCast) => { if ((item as any).type === 'cast') { @@ -149,7 +145,7 @@ export default function Embed({ } )}
- +
); } @@ -178,7 +174,8 @@ function EmbedCast({ data }: { data: FarCastEmbedMetaCast }) { }, [data.cast]); return ( - { e.stopPropagation(); navigate( @@ -188,27 +185,38 @@ function EmbedCast({ data }: { data: FarCastEmbedMetaCast }) { ); }} > -
-
+
+
-
- {userData.username} - +
+ + {userData.username} + + @{userData.uname} {' '}ยท{' '} {dayjs(data.cast.created_at).fromNow()}
-

{data.cast.text}

+

+ {data.cast.text} +

- {castImg && } - + {castImg && ( + + )} +
); } @@ -218,16 +226,25 @@ function EmbedNFT({ item }: { item: FarCastEmbedMeta }) { } return ( - { e.stopPropagation(); }} > - -
-

{item.collection}

+ +
+

+ {item.collection} +

- +
); } @@ -264,14 +281,18 @@ export function EmbedWebsite({ > {(isImg(img || '') && (
)) || (
- +
)}
@@ -345,9 +366,3 @@ export function isImg(url?: string) { url.endsWith('.gif') ); } - -const EmbedBox = styled.div` - display: flex; - flex-direction: column; - gap: 10px; -`; diff --git a/apps/u3/src/components/social/PostCard.tsx b/apps/u3/src/components/social/PostCard.tsx index 9905d366..4c279a85 100644 --- a/apps/u3/src/components/social/PostCard.tsx +++ b/apps/u3/src/components/social/PostCard.tsx @@ -377,7 +377,7 @@ export const PostCardImgWrapper = styled.div<{ len: number }>` ? 'calc(33% - 12px)' : props.len === 2 ? 'calc(50% - 10px)' - : '70%'}; + : '100%'}; border-radius: 10px; overflow: hidden; cursor: pointer; @@ -393,112 +393,6 @@ export const PostCardVideoWrapper = styled.div` max-width: 100%; `; -export const PostCardCastWrapper = styled.div` - border-radius: 10px; - color: #fff; - padding: 20px; - cursor: pointer; - display: flex; - gap: 10px; - justify-content: space-between; - background-color: #14171a; - > div { - > div { - display: flex; - align-items: center; - gap: 10px; - > img { - width: 21px; - height: 21px; - border-radius: 50%; - } - > div { - display: flex; - align-items: center; - gap: 5px; - } - .username { - color: #fff; - font-family: Rubik; - font-size: 12px; - font-style: normal; - font-weight: 700; - line-height: normal; - margin-right: 5px; - } - .uname { - color: #718096; - font-family: Rubik; - font-size: 12px; - font-style: normal; - font-weight: 400; - line-height: normal; - } - } - > p { - color: #c8c4c4; - margin-bottom: 0; - margin-top: 10px; - padding: 0; - word-break: break-all; - text-overflow: ellipsis; - display: -webkit-box; - -webkit-box-orient: vertical; - -webkit-line-clamp: 3; - overflow: hidden; - } - } - > img { - flex-shrink: 0; - width: 100px; - height: 100px; - border-radius: 10px; - overflow: hidden; - } -`; - -export const PostCardNftWrapper = styled.div` - color: #fff; - width: 100%; - border-radius: 10px; - overflow: hidden; - background-color: #14171a; - cursor: initial; - > img { - width: 100%; - } - > div { - display: flex; - justify-content: space-between; - align-items: center; - padding: 20px; - > h4 { - margin: 0; - color: #fff; - font-family: Rubik; - font-size: 16px; - font-style: normal; - font-weight: 400; - line-height: 30px; /* 187.5% */ - } - > button { - cursor: pointer; - border-radius: 10px; - background: #454c99; - padding: 10px 20px; - border: none; - outline: none; - color: inherit; - color: #fff; - font-family: Rubik; - font-size: 16px; - font-style: normal; - font-weight: 700; - line-height: normal; - } - } -`; - export const PostCardEmbedWrapper = styled.div` color: #fff; border-radius: 10px; @@ -506,7 +400,7 @@ export const PostCardEmbedWrapper = styled.div` background-color: #14171a; text-decoration: none; width: 100%; - min-height: 373px; + min-height: 349px; display: flex; flex-direction: column; cursor: default; diff --git a/apps/u3/src/components/social/farcaster/U3ZoraMinter.tsx b/apps/u3/src/components/social/farcaster/U3ZoraMinter.tsx index 36107d02..fe8638a9 100644 --- a/apps/u3/src/components/social/farcaster/U3ZoraMinter.tsx +++ b/apps/u3/src/components/social/farcaster/U3ZoraMinter.tsx @@ -1,4 +1,10 @@ -import { useCallback, useEffect, useMemo, useState } from 'react'; +import { + ComponentPropsWithRef, + useCallback, + useEffect, + useMemo, + useState, +} from 'react'; import { UrlMetadata } from '@mod-protocol/core'; import { useAccount, useNetwork } from 'wagmi'; import { useConnectModal } from '@rainbow-me/rainbowkit'; @@ -13,8 +19,6 @@ import { getMetadataWithMod } from '@/services/social/api/farcaster'; import { FarCastEmbedMeta } from '@/services/social/types'; import useLogin from '@/hooks/shared/useLogin'; -import { PostCardNftWrapper } from '../PostCard'; - type ModTransactionData = { status: string; orderIds: string[]; @@ -161,21 +165,28 @@ export default function U3ZoraMinter({ }, []); return ( - { e.stopPropagation(); }} > - -
-

{embedMetadata.collection}

- {(minting && ) || + +
+

+ {embedMetadata.collection} +

+ {(minting && Minting) || (modMetadataCheckDone && ((modData && modData.nft?.tokenId && ((transactionHash && ( - + )) || ( - + ))) || ( - + )))}
- +
+ ); +} +function MintButton(props: ComponentPropsWithRef<'button'>) { + return ( + )} - {showMenuBtn && ( + {/* {showMenuBtn && (
- )} + )} */}
diff --git a/apps/u3/src/route/nav.tsx b/apps/u3/src/route/nav.tsx index 6eaef2eb..88ad0d4f 100644 --- a/apps/u3/src/route/nav.tsx +++ b/apps/u3/src/route/nav.tsx @@ -92,6 +92,7 @@ export const navs: CustomNavObject[] = [ navMap.news, navMap.notifications, navMap.apps, + navMap.save, ] : [ navMap.explore,