mirror of https://github.com/msgbyte/tailchat
refactor: group panel wrapper
parent
5701165b0c
commit
a8d91c6700
@ -0,0 +1,31 @@
|
|||||||
|
import { SectionHeader } from '@/components/SectionHeader';
|
||||||
|
import { Space } from 'antd';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
interface PanelCommonHeaderProps {
|
||||||
|
prefix?: React.ReactNode;
|
||||||
|
suffix?: React.ReactNode;
|
||||||
|
actions?: React.ReactNode[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 右侧面板的头部
|
||||||
|
*/
|
||||||
|
export const PanelCommonHeader: React.FC<PanelCommonHeaderProps> = React.memo(
|
||||||
|
(props) => {
|
||||||
|
return (
|
||||||
|
<SectionHeader>
|
||||||
|
<div className="flex flex-wrap text-xl justify-between">
|
||||||
|
<div className="flex items-center">
|
||||||
|
<div className="text-gray-500 mr-1">{props.prefix}</div>
|
||||||
|
<div className="text-base">{props.children}</div>
|
||||||
|
<div className="ml-2">{props.suffix}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Space>{props.actions}</Space>
|
||||||
|
</div>
|
||||||
|
</SectionHeader>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
PanelCommonHeader.displayName = 'PanelCommonHeader';
|
@ -0,0 +1,27 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { useGroupPanel } from 'tailchat-shared';
|
||||||
|
import { PanelCommonHeader } from '../common/Header';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群组面板通用包装器
|
||||||
|
*/
|
||||||
|
interface GroupPanelWrapperProps {
|
||||||
|
groupId: string;
|
||||||
|
panelId: string;
|
||||||
|
}
|
||||||
|
export const GroupPanelWrapper: React.FC<GroupPanelWrapperProps> = React.memo(
|
||||||
|
(props) => {
|
||||||
|
const panelInfo = useGroupPanel(props.groupId, props.panelId);
|
||||||
|
if (panelInfo === undefined) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-full h-full flex flex-col overflow-hidden">
|
||||||
|
<PanelCommonHeader>{panelInfo.name}</PanelCommonHeader>
|
||||||
|
<div className="flex-1 overflow-hidden">{props.children}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
GroupPanelWrapper.displayName = 'GroupPanelWrapper';
|
Loading…
Reference in New Issue