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: adjust layout #186

Merged
merged 3 commits into from
Dec 22, 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
7 changes: 1 addition & 6 deletions src/app/chat/CameraMode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import React, { memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import ChatDialog from '@/app/chat/CameraMode/ChatDialog';
import { HEADER_HEIGHT } from '@/constants/token';
import AgentViewer from '@/features/AgentViewer';
import { sessionSelectors, useSessionStore } from '@/store/session';

Expand All @@ -31,11 +30,7 @@ export default memo(() => {
<Flexbox flex={1} style={{ position: 'relative' }}>
{currentAgent ? (
<div className={styles.viewer}>
<AgentViewer
height={`calc(100vh - ${HEADER_HEIGHT}px)`}
agentId={currentAgent.agentId}
interactive={interactive}
/>
<AgentViewer agentId={currentAgent.agentId} interactive={interactive} />
</div>
) : null}
<ChatDialog className={classNames(styles.dialog, styles.content)} />
Expand Down
38 changes: 38 additions & 0 deletions src/app/chat/ChatMode/SideBar/ChatHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use client';

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

import { BRANDING_NAME } from '@/constants/branding';

export const useStyles = createStyles(({ css, token }) => ({
logo: css`
color: ${token.colorText};
fill: ${token.colorText};
`,
top: css`
position: sticky;
inset-block-start: 0;
height: 64px;
`,
}));

const ChatHeader = memo(() => {
const { styles } = useStyles();

return (
<Flexbox className={styles.top} gap={16} padding={12}>
<Flexbox distribution={'space-between'} horizontal>
<Flexbox align={'center'} gap={4} horizontal>
<Typography.Title level={4} style={{ margin: 0, height: 40, lineHeight: '40px' }}>
{BRANDING_NAME}
</Typography.Title>
</Flexbox>
</Flexbox>
</Flexbox>
);
});

export default ChatHeader;
2 changes: 1 addition & 1 deletion src/app/chat/ChatMode/SideBar/SessionList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const SessionList = () => {
const { t } = useTranslation('chat');
return (
<div className={styles.session}>
<Flexbox style={{ padding: '16px 8px 0' }}>
<Flexbox style={{ padding: '0 8px 0' }}>
<SearchBar
enableShortKey
onChange={(e) => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/chat/ChatMode/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import isEqual from 'lodash-es/isEqual';
import { rgba } from 'polished';
import { memo, useEffect, useState } from 'react';

import { CHAT_HEADER_HEIGHT, SIDEBAR_WIDTH } from '@/constants/token';
import { SIDEBAR_WIDTH } from '@/constants/token';
import { useGlobalStore } from '@/store/global';

import ChatHeader from './ChatHeader';
import SessionList from './SessionList';

const useStyles = createStyles(({ css, token }) => ({
Expand Down Expand Up @@ -58,9 +59,8 @@ const SideBar = memo(() => {
onExpandChange={handleExpand}
expand={showSessionList}
>
<div style={{ height: `calc(100vh - ${CHAT_HEADER_HEIGHT}px)`, overflowY: 'auto' }}>
<SessionList />
</div>
<ChatHeader />
<SessionList />
</DraggablePanel>
);
});
Expand Down
3 changes: 1 addition & 2 deletions src/app/chat/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { ReactNode, memo } from 'react';

import AppLayout from '@/layout/AppLayout';
import { HeaderNavKey } from '@/layout/type';

import Effect from './Effect';

Expand All @@ -15,7 +14,7 @@ const LayoutDesktop = (props: LayoutProps) => {
const { children } = props;

return (
<AppLayout headerKey={HeaderNavKey.Chat}>
<AppLayout>
{children}
<Effect />
</AppLayout>
Expand Down
1 change: 1 addition & 0 deletions src/app/discover/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const useStyles = createStyles(({ css, token }) => ({
padding-inline: ${token.paddingSM}px;
`,
tabsNav: css`
margin-bottom: ${token.margin}px;
padding-inline: ${token.paddingSM}px;
`,
list: css`
Expand Down
3 changes: 1 addition & 2 deletions src/app/discover/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ReactNode, memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import AppLayout from '@/layout/AppLayout';
import { HeaderNavKey } from '@/layout/type';

export interface LayoutProps {
children?: ReactNode;
Expand All @@ -11,7 +10,7 @@ export interface LayoutProps {
const Layout = (props: LayoutProps) => {
const { children } = props;
return (
<AppLayout headerKey={HeaderNavKey.Discover}>
<AppLayout>
<Flexbox flex={1} height={'100%'} width={'100%'} style={{ position: 'relative' }} horizontal>
<Flexbox align={'center'} flex={1} style={{ overflow: 'scroll' }}>
{children}
Expand Down
3 changes: 1 addition & 2 deletions src/app/discover/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import React, { useState } from 'react';
import { Flexbox } from 'react-layout-kit';
import useSWR from 'swr';

import { HEADER_HEIGHT } from '@/constants/token';
import { getAgentIndex } from '@/services/agent';
import { configSelectors, useSettingStore } from '@/store/setting';
import { Agent } from '@/types/agent';
Expand All @@ -20,7 +19,7 @@ const useStyles = createStyles(({ css, responsive }) => ({
overflow-y: auto;

width: 100%;
height: calc(100% - ${HEADER_HEIGHT}px);
height: 100%;
min-height: 500px;
padding: 0 32px 16px;

Expand Down
8 changes: 1 addition & 7 deletions src/app/role/RoleEdit/Shell/ViewerWithUpload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React, { CSSProperties, memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import { HEADER_HEIGHT } from '@/constants/token';
import AgentViewer from '@/features/AgentViewer';
import { agentSelectors, useAgentStore } from '@/store/agent';
import { useGlobalStore } from '@/store/global';
Expand Down Expand Up @@ -41,12 +40,7 @@ const ViewerWithUpload = memo<ViewerWithUploadProps>(({ style }) => {
};

return currentAgent3DModel && currentAgentId ? (
<AgentViewer
height={`calc(100vh - ${HEADER_HEIGHT}px)`}
agentId={currentAgentId}
interactive={false}
toolbar={false}
/>
<AgentViewer agentId={currentAgentId} interactive={false} toolbar={false} />
) : (
<Upload
beforeUpload={handleUploadAvatar}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PlusOutlined } from '@ant-design/icons';
import { Modal } from '@lobehub/ui';
import { ActionIcon, Modal } from '@lobehub/ui';
import { Avatar, Button, message } from 'antd';
import { createStyles } from 'antd-style';
import { MessageSquarePlus } from 'lucide-react';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -82,9 +82,12 @@ export default function CreateRole() {

return (
<>
<Button type={'default'} onClick={() => setIsModalOpen(true)} icon={<PlusOutlined />}>
{t('role.create')}
</Button>
<ActionIcon
onClick={() => setIsModalOpen(true)}
icon={MessageSquarePlus}
size="large"
title={t('role.create')}
/>

<Modal
allowFullscreen
Expand Down
42 changes: 42 additions & 0 deletions src/app/role/SideBar/RoleHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use client';

import { Typography } from 'antd';
import { createStyles } from 'antd-style';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { Flexbox } from 'react-layout-kit';

import CreateRole from './CreateRole';

export const useStyles = createStyles(({ css, token }) => ({
logo: css`
color: ${token.colorText};
fill: ${token.colorText};
`,
top: css`
position: sticky;
inset-block-start: 0;
height: 64px;
line-height: 64px;
`,
}));

const RoleHeader = memo(() => {
const { styles } = useStyles();
const { t } = useTranslation('role');

return (
<Flexbox className={styles.top} gap={16} padding={12}>
<Flexbox distribution={'space-between'} horizontal>
<Flexbox align={'center'} gap={4} horizontal>
<Typography.Title level={4} style={{ margin: 0 }}>
{t('role.myRole')}
</Typography.Title>
</Flexbox>
<CreateRole />
</Flexbox>
</Flexbox>
);
});

export default RoleHeader;
53 changes: 0 additions & 53 deletions src/app/role/SideBar/RoleList/AgentCreate.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/role/SideBar/RoleList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const RoleList = () => {

return (
<div className={styles.role}>
<Flexbox style={{ padding: '16px 8px 0' }}>
<Flexbox style={{ padding: '0 8px 0' }} gap={8}>
<SearchBar
enableShortKey
onChange={(e) => {
Expand Down
2 changes: 2 additions & 0 deletions src/app/role/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useEffect, useState } from 'react';
import { SIDEBAR_MAX_WIDTH, SIDEBAR_WIDTH } from '@/constants/token';
import { useGlobalStore } from '@/store/global';

import RoleHeader from './RoleHeader';
import RoleList from './RoleList';

const useStyles = createStyles(({ css, token }) => ({
Expand Down Expand Up @@ -52,6 +53,7 @@ const SideBar = () => {
onExpandChange={handleExpand}
expand={showRoleList}
>
<RoleHeader />
<RoleList />
</DraggablePanel>
);
Expand Down
3 changes: 1 addition & 2 deletions src/app/role/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { ReactNode, memo } from 'react';

import AppLayout from '@/layout/AppLayout';
import { HeaderNavKey } from '@/layout/type';

export interface LayoutProps {
children?: ReactNode;
Expand All @@ -12,7 +11,7 @@ export interface LayoutProps {
const LayoutDesktop = (props: LayoutProps) => {
const { children } = props;

return <AppLayout headerKey={HeaderNavKey.Role}>{children}</AppLayout>;
return <AppLayout>{children}</AppLayout>;
};

export default memo(LayoutDesktop);
9 changes: 9 additions & 0 deletions src/app/settings/@category/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import CategoryContent from './features/CategoryContent';

const Category = () => {
return <CategoryContent />;
};

Category.displayName = 'SettingCategory';

export default Category;
37 changes: 37 additions & 0 deletions src/app/settings/@category/features/CategoryContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use client';

import { memo } from 'react';
import urlJoin from 'url-join';

import Menu from '@/components/Menu';
import { useQuery } from '@/hooks/useQuery';
import { useQueryRoute } from '@/hooks/useQueryRoute';
import { SettingsTabs } from '@/store/global/index';

import { useActiveSettingsKey } from '../../hooks/useActiveSettingsKey';
import { useCategory } from '../../hooks/useCategory';

const CategoryContent = memo<{ modal?: boolean }>(({ modal }) => {
const activeTab = useActiveSettingsKey();
const { tab = SettingsTabs.Common } = useQuery();
const cateItems = useCategory();
const router = useQueryRoute();

return (
<Menu
items={cateItems}
onClick={({ key }) => {
if (modal) {
router.replace('/settings/modal', { query: { tab: key } });
} else {
router.push(urlJoin('/settings', key));
}
}}
selectable
selectedKeys={[modal ? tab : (activeTab as any)]}
variant={'compact'}
/>
);
});

export default CategoryContent;
Loading
Loading