Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ’„ style: improve market layout styles and mobile style #2347

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/app/(main)/(mobile)/me/features/AvatarBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@ import { createStyles } from 'antd-style';
import { PropsWithChildren, memo } from 'react';
import { Center, Flexbox } from 'react-layout-kit';

export const useStyles = createStyles(({ css, token }) => ({
export const AVATAR_SIZE = 80;

export const useStyles = createStyles(({ css, token, isDarkMode }) => ({
avatar: css`
position: absolute;
z-index: 10;

flex: none;

background: ${token.colorBgContainer};
border: 6px solid ${token.colorBgContainer};
margin-top: -${AVATAR_SIZE / 2 + 6}px;

background: ${isDarkMode ? token.colorBgLayout : token.colorBgContainer};
border: 6px solid ${isDarkMode ? token.colorBgLayout : token.colorBgContainer};
border-radius: 50%;
`,
banner: css`
position: relative;
flex: none;
background: ${isDarkMode ? token.colorBgLayout : token.colorBgContainer};
`,
bannerBox: css`
position: relative;

overflow: hidden;

width: 100%;
height: 180px;
height: 100px;

background: ${token.colorBgLayout};
`,
Expand Down
4 changes: 1 addition & 3 deletions src/app/(main)/(mobile)/me/features/Cate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';

import { useTheme } from 'antd-style';
import { useRouter } from 'next/navigation';
import { memo } from 'react';
import { Flexbox } from 'react-layout-kit';
Expand All @@ -11,12 +10,11 @@ import Cell from '@/components/Cell';
import Divider from '@/components/Cell/Divider';

const SettingCate = memo(() => {
const theme = useTheme();
const settingItems = useCategory({ mobile: true });
const router = useRouter();

return (
<Flexbox style={{ background: theme.colorBgContainer }} width={'100%'}>
<Flexbox width={'100%'}>
{settingItems?.map(({ key, icon, label, type }: any, index) => {
if (type === 'divider') return <Divider key={index} />;
return (
Expand Down
4 changes: 1 addition & 3 deletions src/app/(main)/(mobile)/me/features/ExtraCate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';

import { useTheme } from 'antd-style';
import { memo } from 'react';
import { Flexbox } from 'react-layout-kit';

Expand All @@ -10,11 +9,10 @@ import Divider from '@/components/Cell/Divider';
import { useExtraCate } from './useExtraCate';

const ExtraCate = memo(() => {
const theme = useTheme();
const mainItems = useExtraCate();

return (
<Flexbox style={{ background: theme.colorBgContainer }} width={'100%'}>
<Flexbox width={'100%'}>
{mainItems?.map(({ key, icon, label, type, onClick }: any, index) => {
if (type === 'divider') return <Divider key={index} />;
return <Cell icon={icon} key={key} label={label} onClick={onClick} />;
Expand Down
4 changes: 2 additions & 2 deletions src/app/(main)/(mobile)/me/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import BrandWatermark from '@/components/BrandWatermark';
import Avatar from '@/features/AvatarWithUpload';
import { isMobileDevice } from '@/utils/responsive';

import AvatarBanner from './features/AvatarBanner';
import AvatarBanner, { AVATAR_SIZE } from './features/AvatarBanner';
import Cate from './features/Cate';
import ExtraCate from './features/ExtraCate';

Expand All @@ -17,7 +17,7 @@ const Page = () => {
return (
<>
<AvatarBanner>
<Avatar size={88} />
<Avatar size={AVATAR_SIZE} />
</AvatarBanner>
<Cate />
<ExtraCate />
Expand Down
6 changes: 4 additions & 2 deletions src/app/(main)/market/features/AgentCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ const useStyles = createStyles(({ css, token, isDarkMode }) => ({

background: ${token.colorBgContainer};
border-radius: ${token.borderRadiusLG}px;
box-shadow: 0 0 1px 1px ${token.colorFillQuaternary} inset;
box-shadow: 0 0 1px 1px ${isDarkMode ? token.colorFillQuaternary : token.colorFillSecondary}
inset;

transition: box-shadow 0.2s ${token.motionEaseInOut};

&:hover {
box-shadow: 0 0 1px 1px ${token.colorFillSecondary} inset;
box-shadow: 0 0 1px 1px ${isDarkMode ? token.colorFillSecondary : token.colorFill} inset;
}
`,
desc: css`
Expand All @@ -50,6 +51,7 @@ const useStyles = createStyles(({ css, token, isDarkMode }) => ({
title: css`
margin-bottom: 0 !important;
font-size: 18px !important;
font-weight: bold;
`,
}));

Expand Down
11 changes: 10 additions & 1 deletion src/app/(main)/market/features/AgentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ const AgentList = memo<AgentListProps>(({ mobile }) => {
[],
);

if (isLoading) return <Skeleton paragraph={{ rows: 8 }} title={false} />;
if (isLoading || (!searchKeywords && agentList?.length === 0)) {
return (
<>
<h2 className={styles.title}>{t('title.recentSubmits')}</h2>
<Skeleton paragraph={{ rows: 8 }} title={false} />
<h2 className={styles.title}>{t('title.allAgents')}</h2>
<Skeleton paragraph={{ rows: 8 }} title={false} />
</>
);
}

if (searchKeywords) {
if (agentList.length === 0) return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
Expand Down
12 changes: 8 additions & 4 deletions src/app/(main)/market/features/TagList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { Button } from 'antd';
import { Button, Skeleton } from 'antd';
import { createStyles, useResponsive } from 'antd-style';
import isEqual from 'fast-deep-equal';
import { startCase } from 'lodash-es';
Expand All @@ -9,7 +9,7 @@ import { Flexbox } from 'react-layout-kit';

import { agentMarketSelectors, useMarketStore } from '@/store/market';

const useStyles = createStyles(({ css, token }) => ({
const useStyles = createStyles(({ css, token, isDarkMode }) => ({
active: css`
color: ${token.colorBgLayout};
background: ${token.colorPrimary};
Expand All @@ -20,11 +20,11 @@ const useStyles = createStyles(({ css, token }) => ({
}
`,
tag: css`
background: ${token.colorBgContainer};
background: ${isDarkMode ? token.colorBgContainer : token.colorFillTertiary};
border: none;

&:hover {
background: ${token.colorBgElevated} !important;
background: ${isDarkMode ? token.colorBgElevated : token.colorFill} !important;
}
`,
}));
Expand All @@ -38,6 +38,10 @@ const TagList = memo(() => {
]);
const agentTagList = useMarketStore(agentMarketSelectors.getAgentTagList, isEqual);

if (agentTagList?.length === 0) {
return <Skeleton paragraph={{ rows: 4 }} title={false} />;
}

const list = md ? agentTagList : agentTagList.slice(0, 20);

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Cell/Divider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { createStyles } from 'antd-style';
import { memo } from 'react';

const useStyles = createStyles(
({ css, token }) => css`
({ css, token, isDarkMode }) => css`
height: 6px;
background: ${token.colorBgLayout};
background: ${isDarkMode ? token.colorBgContainer : token.colorBgLayout};
`,
);

Expand Down
3 changes: 2 additions & 1 deletion src/components/Cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { ReactNode, memo } from 'react';

const { Item } = List;

const useStyles = createStyles(({ css }) => ({
const useStyles = createStyles(({ css, token, isDarkMode }) => ({
container: css`
position: relative;
padding-block: 16px !important;
background: ${isDarkMode ? token.colorBgLayout : token.colorBgContainer};
border-radius: 0;
`,
}));
Expand Down
Loading