💄 style: Fix scroll layout and setting panel in mobile
parent
7a1a6cac1f
commit
2abac2dce0
File diff suppressed because one or more lines are too long
|
|
@ -1,12 +1,14 @@
|
||||||
import { Button, Popconfirm } from 'antd';
|
import { Button, Popconfirm } from 'antd';
|
||||||
|
import { useResponsive } from 'antd-style';
|
||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Flexbox } from 'react-layout-kit';
|
||||||
|
|
||||||
import { DEFAULT_SETTING, useAppStore } from '@/store';
|
import { DEFAULT_SETTING, useAppStore } from '@/store';
|
||||||
|
|
||||||
const Footer = memo(() => {
|
const Footer = memo(() => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { mobile } = useResponsive();
|
||||||
const onSetSetting = useAppStore((st) => st.onSetSetting);
|
const onSetSetting = useAppStore((st) => st.onSetSetting);
|
||||||
|
|
||||||
const onReset = useCallback(() => {
|
const onReset = useCallback(() => {
|
||||||
|
|
@ -15,7 +17,7 @@ const Footer = memo(() => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Flexbox gap={16} horizontal={!mobile} style={mobile ? { padding: 16, width: '100%' } : {}}>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
cancelText={t('cancel')}
|
cancelText={t('cancel')}
|
||||||
okText={t('confirm')}
|
okText={t('confirm')}
|
||||||
|
|
@ -23,14 +25,14 @@ const Footer = memo(() => {
|
||||||
onConfirm={onReset}
|
onConfirm={onReset}
|
||||||
title={t('setting.button.reset')}
|
title={t('setting.button.reset')}
|
||||||
>
|
>
|
||||||
<Button danger style={{ borderRadius: 4 }}>
|
<Button block={mobile} danger style={{ borderRadius: 4 }}>
|
||||||
{t('setting.button.reset')}
|
{t('setting.button.reset')}
|
||||||
</Button>
|
</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
<Button htmlType="submit" style={{ borderRadius: 4 }} type="primary">
|
<Button block={mobile} htmlType="submit" style={{ borderRadius: 4 }} type="primary">
|
||||||
{t('setting.button.submit')}
|
{t('setting.button.submit')}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</Flexbox>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
export default Footer;
|
export default Footer;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Segmented } from 'antd';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
|
import { SettingsTabs } from '@/features/Setting/Sidebar/index';
|
||||||
|
import { useTabItems } from '@/features/Setting/Sidebar/useTabItems';
|
||||||
|
|
||||||
|
interface SidebarProps {
|
||||||
|
setTab: (tab: SettingsTabs) => void;
|
||||||
|
tab: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MobileSidebar = memo<SidebarProps>(({ tab, setTab }) => {
|
||||||
|
const items = useTabItems();
|
||||||
|
return (
|
||||||
|
<Segmented
|
||||||
|
block
|
||||||
|
onChange={setTab as any}
|
||||||
|
options={items.map(({ value, label }) => ({ label, value }))}
|
||||||
|
value={tab}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export default MobileSidebar;
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { Brush, FlaskConical, Layout, PanelRight } from 'lucide-react';
|
|
||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import { Flexbox } from 'react-layout-kit';
|
import { Flexbox } from 'react-layout-kit';
|
||||||
|
|
||||||
|
import { useTabItems } from '@/features/Setting/Sidebar/useTabItems';
|
||||||
|
|
||||||
import Item from './Item';
|
import Item from './Item';
|
||||||
|
|
||||||
export enum SettingsTabs {
|
export enum SettingsTabs {
|
||||||
|
|
@ -18,14 +18,7 @@ interface SidebarProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Sidebar = memo<SidebarProps>(({ tab, setTab }) => {
|
const Sidebar = memo<SidebarProps>(({ tab, setTab }) => {
|
||||||
const { t } = useTranslation();
|
const items = useTabItems();
|
||||||
|
|
||||||
const items = [
|
|
||||||
{ icon: Brush, label: t('setting.tab.appearance'), value: SettingsTabs.Appearance },
|
|
||||||
{ icon: Layout, label: t('setting.tab.layout'), value: SettingsTabs.Layout },
|
|
||||||
{ icon: PanelRight, label: t('setting.tab.sidebar'), value: SettingsTabs.Sidebar },
|
|
||||||
{ icon: FlaskConical, label: t('setting.tab.experimental'), value: SettingsTabs.Experimental },
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flexbox gap={4}>
|
<Flexbox gap={4}>
|
||||||
|
|
@ -43,3 +36,5 @@ const Sidebar = memo<SidebarProps>(({ tab, setTab }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Sidebar;
|
export default Sidebar;
|
||||||
|
|
||||||
|
export { default as MobileSidebar } from './Mobile';
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { Brush, FlaskConical, Layout, PanelRight } from 'lucide-react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import { SettingsTabs } from '@/features/Setting/Sidebar/index';
|
||||||
|
|
||||||
|
export const useTabItems = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
return [
|
||||||
|
{ icon: Brush, label: t('setting.tab.appearance'), value: SettingsTabs.Appearance },
|
||||||
|
{ icon: Layout, label: t('setting.tab.layout'), value: SettingsTabs.Layout },
|
||||||
|
{ icon: PanelRight, label: t('setting.tab.sidebar'), value: SettingsTabs.Sidebar },
|
||||||
|
{ icon: FlaskConical, label: t('setting.tab.experimental'), value: SettingsTabs.Experimental },
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { ActionIcon, Modal, type ModalProps } from '@lobehub/ui';
|
import { ActionIcon, Modal, type ModalProps } from '@lobehub/ui';
|
||||||
|
import { useResponsive } from 'antd-style';
|
||||||
import { Book } from 'lucide-react';
|
import { Book } from 'lucide-react';
|
||||||
import { memo, useState } from 'react';
|
import { memo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
@ -11,7 +12,7 @@ import FormAppearance from './Form/Appearance';
|
||||||
import FormExperimental from './Form/Experimental';
|
import FormExperimental from './Form/Experimental';
|
||||||
import FormLayout from './Form/Layout';
|
import FormLayout from './Form/Layout';
|
||||||
import FormSidebar from './Form/Sidebar';
|
import FormSidebar from './Form/Sidebar';
|
||||||
import Sidebar, { SettingsTabs } from './Sidebar';
|
import Sidebar, { MobileSidebar, SettingsTabs } from './Sidebar';
|
||||||
|
|
||||||
export interface SettingProps {
|
export interface SettingProps {
|
||||||
onCancel?: ModalProps['onCancel'];
|
onCancel?: ModalProps['onCancel'];
|
||||||
|
|
@ -20,7 +21,18 @@ export interface SettingProps {
|
||||||
|
|
||||||
const Setting = memo<SettingProps>(({ open, onCancel }) => {
|
const Setting = memo<SettingProps>(({ open, onCancel }) => {
|
||||||
const [tab, setTab] = useState<SettingsTabs>(SettingsTabs.Appearance);
|
const [tab, setTab] = useState<SettingsTabs>(SettingsTabs.Appearance);
|
||||||
|
const { mobile } = useResponsive();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const content = (
|
||||||
|
<>
|
||||||
|
{tab === SettingsTabs.Appearance && <FormAppearance />}
|
||||||
|
{tab === SettingsTabs.Layout && <FormLayout />}
|
||||||
|
{tab === SettingsTabs.Sidebar && <FormSidebar />}
|
||||||
|
{tab === SettingsTabs.Experimental && <FormExperimental />}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
footer={false}
|
footer={false}
|
||||||
|
|
@ -40,13 +52,19 @@ const Setting = memo<SettingProps>(({ open, onCancel }) => {
|
||||||
}
|
}
|
||||||
width={960}
|
width={960}
|
||||||
>
|
>
|
||||||
<Flexbox gap={16} horizontal>
|
{mobile ? (
|
||||||
<Sidebar setTab={setTab} tab={tab} />
|
<Flexbox>
|
||||||
{tab === SettingsTabs.Appearance && <FormAppearance />}
|
<div style={{ padding: 16 }}>
|
||||||
{tab === SettingsTabs.Layout && <FormLayout />}
|
<MobileSidebar setTab={setTab} tab={tab} />
|
||||||
{tab === SettingsTabs.Sidebar && <FormSidebar />}
|
</div>
|
||||||
{tab === SettingsTabs.Experimental && <FormExperimental />}
|
{content}
|
||||||
</Flexbox>
|
</Flexbox>
|
||||||
|
) : (
|
||||||
|
<Flexbox gap={16} horizontal>
|
||||||
|
<Sidebar setTab={setTab} tab={tab} />
|
||||||
|
{content}
|
||||||
|
</Flexbox>
|
||||||
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@ import { readableColor } from 'polished';
|
||||||
|
|
||||||
export default (token: Theme) => {
|
export default (token: Theme) => {
|
||||||
return css`
|
return css`
|
||||||
|
body {
|
||||||
|
height: 100vh !important;
|
||||||
|
}
|
||||||
|
|
||||||
.gradio-group,
|
.gradio-group,
|
||||||
.gradio-row {
|
.gradio-row {
|
||||||
gap: 12px !important;
|
gap: 12px !important;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue