Skip to content

Commit

Permalink
fix(flat-components): fix antd warnings, close #1547 (#1707)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious authored Sep 21, 2022
1 parent 6456334 commit 575d11e
Show file tree
Hide file tree
Showing 27 changed files with 171 additions and 162 deletions.
47 changes: 23 additions & 24 deletions packages/flat-components/src/components/ChatPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,31 @@ export const ChatPanel = /* @__PURE__ */ observer<ChatPanelProps>(function ChatP
<div className="chat-panel">
<Tabs
activeKey={activeTab}
items={[
{
key: "messages",
label: (
<ChatTabTitle>
<span>{t("messages")}</span>
</ChatTabTitle>
),
children: <ChatMessages {...props} visible={activeTab === "messages"} />,
},
{
key: "users",
label: (
<ChatTabTitle {...props}>
<span>
{t("users")} {usersCount}
</span>
</ChatTabTitle>
),
children: <ChatUsers {...props} />,
},
]}
tabBarGutter={0}
onChange={setActiveTab as (key: string) => void}
>
<Tabs.TabPane
key="messages"
tab={
<ChatTabTitle>
<span>{t("messages")}</span>
</ChatTabTitle>
}
>
<ChatMessages {...props} visible={activeTab === "messages"} />
</Tabs.TabPane>
<Tabs.TabPane
key="users"
tab={
<ChatTabTitle {...props}>
<span>
{t("users")} {usersCount}
</span>
</ChatTabTitle>
}
>
<ChatUsers {...props} />
</Tabs.TabPane>
</Tabs>
></Tabs>
</div>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export const StopClassConfirmModal: FC<StopClassConfirmModalProps> = ({
return (
<Modal
okButtonProps={{ loading }}
open={visible}
title={t("confirmation-of-the-end-of-classes")}
visible={visible}
onCancel={onCancel}
onOk={onStop}
>
Expand Down Expand Up @@ -68,8 +68,8 @@ export const CloseRoomConfirmModal: FC<CloseRoomConfirmModalProps> = ({
{t("end-the-class")}
</Button>,
]}
open={visible}
title={t("close-option")}
visible={visible}
onCancel={onCancel}
onOk={onCancel}
>
Expand All @@ -96,8 +96,8 @@ export const ExitRoomConfirmModal: FC<ExitRoomConfirmModalProps> = ({
const t = useTranslate();
return (
<Modal
open={visible}
title={t("student-sure-to-exit-the-room")}
visible={visible}
onCancel={onCancel}
onOk={onExit}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const RecordHintTips: FC<RecordHintTipsProps> = ({ visible, onClose, chil
return (
<Tooltip
color="rgba(68, 78, 96, 0.72)"
open={visible}
overlayClassName="record-hint-tips"
placement="bottom"
title={
Expand All @@ -30,7 +31,6 @@ export const RecordHintTips: FC<RecordHintTipsProps> = ({ visible, onClose, chil
/>
</div>
}
visible={visible}
>
{children}
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,13 @@ export const CloudStorageFileListFileName =
getPopupContainer={getPopupContainer}
overlay={
<Menu
onClick={({ key }) =>
onItemMenuClick && onItemMenuClick(file.fileUUID, key)
}
>
{menuItems.map(({ key, name, className = "" }) => (
<Menu.Item key={key} className={className}>
{name}
</Menu.Item>
))}
</Menu>
items={menuItems.map(e => ({
key: e.key,
className: e.className,
label: e.name,
}))}
onClick={({ key }) => onItemMenuClick?.(file.fileUUID, key)}
/>
}
overlayClassName="cloud-storage-file-list-menu"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { renderBeginTimePicker } from "./renderBeginTimePicker";
import { renderEndTimePicker } from "./renderEndTimePicker";
import { renderPeriodicForm } from "./renderPeriodicForm";
import { ClassPicker } from "../../HomePage/ClassPicker";
import { Fragment } from "react";

export enum Region {
CN_HZ = "cn-hz",
Expand Down Expand Up @@ -106,17 +107,19 @@ export const EditRoomBody: React.FC<EditRoomBodyProps> = ({
const regionMenu = (
<Menu
className="edit-room-body-menu-item"
items={regions.map(region => ({
key: region,
label: (
<Fragment>
<img alt={region} src={RegionSVG[region]} style={{ width: 22 }} />
<span style={{ paddingLeft: 8 }}>{t(`region-${region}`)}</span>
</Fragment>
),
}))}
prefix="hello"
style={{ width: "auto" }}
onClick={e => setRegion(e.key as Region)}
>
<div style={{ padding: "4px 12px 0 14px", color: "gray" }}>{t("servers")}</div>
{regions.map(region => (
<Menu.Item key={region}>
<img alt={region} src={RegionSVG[region]} style={{ width: 22 }} />
<span style={{ paddingLeft: 8 }}>{t(`region-${region}`)}</span>
</Menu.Item>
))}
</Menu>
/>
);

return (
Expand Down Expand Up @@ -251,8 +254,8 @@ export const EditRoomBody: React.FC<EditRoomBodyProps> = ({
{t("confirm")}
</Button>,
]}
open={isShowEditSubmitConfirm}
title={renderModalTitle(type)}
visible={isShowEditSubmitConfirm}
onCancel={hideEditSubmitConfirm}
onOk={onSubmitForm}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export const FullTimePicker: FC<FullTimePickerProps> = ({
<Col span={12}>
<TimePicker
allowClear={false}
disabledHours={disabledHours}
disabledMinutes={disabledMinutes}
disabledTime={() => ({ disabledHours, disabledMinutes })}
format="HH:mm"
value={value}
onChange={date => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export function RoomListItemMenus<TKey extends string = string>({
return (
<Dropdown
overlay={
<Menu>
{actions.map(action => (
<Menu.Item key={action.key} onClick={() => onAction(action.key)}>
{action.text}
</Menu.Item>
))}
</Menu>
<Menu
items={actions.map(action => ({
key: action.key,
onClick: () => onAction(action.key),
label: action.text,
}))}
/>
}
overlayClassName="room-list-item-sub-menu"
trigger={["click"]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export function RoomList<T extends string>({
{filters && (
<Dropdown
overlay={
<Menu>
{filters.map(({ title, key }) => (
<Menu.Item key={key} onClick={() => onTabActive?.(key)}>
{title}
</Menu.Item>
))}
</Menu>
<Menu
items={filters.map(({ title, key }) => ({
key,
onClick: () => onTabActive?.(key),
label: title,
}))}
/>
}
>
<span className="room-list-filters">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const InviteModal: React.FC<InviteModalProps> = ({
cancelText={t("cancel")}
className="invite-modal"
okText={t("copy")}
visible={visible}
open={visible}
width={460}
onCancel={onCancel}
onOk={onCopyClicked}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export const MainPageNavAvatar: React.FC<MainPageNavAvatarProps> = ({
return (
<Popover
content={renderPopMenuInner}
open={popMenuVisible}
overlayClassName="main-page-nav-popover"
placement="bottomRight"
title={renderPopMenuTitle}
trigger="click"
visible={popMenuVisible}
onVisibleChange={togglePopMenuVisible}
onOpenChange={togglePopMenuVisible}
>
<Avatar
className="main-page-nav-avatar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export const MainPageNavHorizontal: React.FC<MainPageNavHorizontalProps> = ({
generateAvatar,
title,
}) => {
const { TabPane } = Tabs;

return (
<div className="main-page-nav-horizontal-container">
<div className="main-page-nav-horizontal-content">
Expand All @@ -48,6 +46,17 @@ export const MainPageNavHorizontal: React.FC<MainPageNavHorizontalProps> = ({
leftMenu.some(menuItem => menuItem.key === key),
) || "none"
}
items={leftMenu.map(menuItem => ({
key: menuItem.key,
label: (
<div className="main-page-nav-horizontal-left-menu-item">
<div className="main-page-nav-horizontal-left-menu-item-icon">
{menuItem.icon(activeKeys.includes(menuItem.key))}
</div>
{menuItem.title}
</div>
),
}))}
onChange={key => {
const item = leftMenu.find(e => e.key === key);
if (item) {
Expand All @@ -58,25 +67,7 @@ export const MainPageNavHorizontal: React.FC<MainPageNavHorizontalProps> = ({
}
}
}}
>
{leftMenu.map(menuItem => {
return (
<TabPane
key={menuItem.key}
tab={
<div className="main-page-nav-horizontal-left-menu-item">
<div className="main-page-nav-horizontal-left-menu-item-icon">
{menuItem.icon(
activeKeys.includes(menuItem.key),
)}
</div>
{menuItem.title}
</div>
}
/>
);
})}
</Tabs>
></Tabs>
)}
</div>
<div className="main-page-nav-horizontal-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const CancelPeriodicRoomModal: React.FC<CancelPeriodicRoomModalProps> = (
{t("confirm")}
</Button>,
]}
open={visible}
title={title}
visible={visible}
onCancel={onCancel}
>
{content()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const CancelSubPeriodicRoomModal: React.FC<CancelSubPeriodicRoomModalProp
{t("confirm")}
</Button>,
]}
open={visible}
title={t("cancel-room")}
visible={visible}
onCancel={onCancel}
>
<span>{t("cancel-sub-periodic-room-tips")}</span>
Expand Down
Loading

0 comments on commit 575d11e

Please sign in to comment.