From 9d8258efd830c78990f1bd59139c5b531d6331b9 Mon Sep 17 00:00:00 2001 From: Cheerego7 <48879533+Cheerego7@users.noreply.github.com> Date: Tue, 18 May 2021 10:16:36 +0800 Subject: [PATCH] feat(flat-component): add MoremMenu component to storybook (#637) --- .../components/PeriodicRoomPage/MoreMenu.tsx | 69 +++++++++++++++++++ .../PeriodicRoomPage/icons/more-menu.svg | 17 +++++ .../components/PeriodicRoomPage/index.less | 8 ++- .../src/components/PeriodicRoomPage/index.tsx | 46 +++++++++---- 4 files changed, 125 insertions(+), 15 deletions(-) create mode 100644 packages/flat-components/src/components/PeriodicRoomPage/MoreMenu.tsx create mode 100644 packages/flat-components/src/components/PeriodicRoomPage/icons/more-menu.svg diff --git a/packages/flat-components/src/components/PeriodicRoomPage/MoreMenu.tsx b/packages/flat-components/src/components/PeriodicRoomPage/MoreMenu.tsx new file mode 100644 index 00000000000..6a9e5c60bff --- /dev/null +++ b/packages/flat-components/src/components/PeriodicRoomPage/MoreMenu.tsx @@ -0,0 +1,69 @@ +import moreMenuSVG from "./icons/more-menu.svg"; + +import React, { useState } from "react"; +import { Dropdown, Menu } from "antd"; +import MenuItem from "antd/lib/menu/MenuItem"; +import { RoomInfo } from "../../types/room"; +import { InviteModal } from "../InviteModal"; +import { RemoveRoomModal } from "../RemoveRoomModal"; + +export interface MoreMenuProps { + room: RoomInfo; + userName: string; + isCreator: boolean; + onCopy: () => void; + onRemoveRoom: () => void; + jumpToRoomInfoPage: () => void; + jumpToModifyRoomPage: () => void; +} + +export const MoreMenu: React.FC = ({ + room, + userName, + isCreator, + onCopy, + onRemoveRoom, + jumpToRoomInfoPage, + jumpToModifyRoomPage, +}) => { + const [removeRoomVisible, setRemoveRoomVisible] = useState(false); + const [inviteRoomVisible, setInviteRoomVisible] = useState(false); + + return ( + { + return ( + + 房间详情 + {isCreator && ( + <> + 修改房间 + setRemoveRoomVisible(true)}> + 取消房间 + + + )} + setInviteRoomVisible(true)}>复制邀请 + setRemoveRoomVisible(false)} + onCancelRoom={onRemoveRoom} + isPeriodicDetailsPage={false} + /> + setInviteRoomVisible(false)} + /> + + ); + }} + trigger={["click"]} + > + 更多 + + ); +}; diff --git a/packages/flat-components/src/components/PeriodicRoomPage/icons/more-menu.svg b/packages/flat-components/src/components/PeriodicRoomPage/icons/more-menu.svg new file mode 100644 index 00000000000..bb96ca2beb1 --- /dev/null +++ b/packages/flat-components/src/components/PeriodicRoomPage/icons/more-menu.svg @@ -0,0 +1,17 @@ + + + 矩形备份 24 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/flat-components/src/components/PeriodicRoomPage/index.less b/packages/flat-components/src/components/PeriodicRoomPage/index.less index f7ba39604a4..aa136a3a41d 100644 --- a/packages/flat-components/src/components/PeriodicRoomPage/index.less +++ b/packages/flat-components/src/components/PeriodicRoomPage/index.less @@ -58,9 +58,11 @@ border-bottom: solid 1px #dbe1ea; } -.ant-table-tbody > tr > td { - color: #7a7b7c; - border-bottom: 1px solid transparent; +.periodic-room-panel-table-container { + .ant-table-tbody > tr > td { + color: #7a7b7c; + border-bottom: 1px solid transparent; + } } .periodic-room-panel-month-value { diff --git a/packages/flat-components/src/components/PeriodicRoomPage/index.tsx b/packages/flat-components/src/components/PeriodicRoomPage/index.tsx index 6affa0d108f..a8c05b14cb3 100644 --- a/packages/flat-components/src/components/PeriodicRoomPage/index.tsx +++ b/packages/flat-components/src/components/PeriodicRoomPage/index.tsx @@ -9,9 +9,11 @@ import { RoomInfo, RoomStatus, RoomType, Week } from "../../types/room"; import { getRoomTypeName, getWeekName, getWeekNames } from "../../utils/room"; import { RoomStatusElement } from "../RoomStatusElement"; import { RemoveRoomModal } from "../RemoveRoomModal"; +import { MoreMenu } from "./MoreMenu"; export interface PeriodicRoomPanelProps { rooms: RoomInfo[]; + userName: string; isCreator: boolean; periodicInfo: { weeks: Week[]; @@ -20,17 +22,24 @@ export interface PeriodicRoomPanelProps { roomCount: number; }; jumpToPeriodicModifyPage: () => void; + onCopy: () => void; onCancelRoom: () => void; + jumpToRoomInfoPage: () => void; + jumpToModifyRoomPage: () => void; } export const PeriodicRoomPanel: React.FC = ({ rooms, - periodicInfo, + userName, isCreator, + periodicInfo, jumpToPeriodicModifyPage, + onCopy, onCancelRoom, + jumpToRoomInfoPage, + jumpToModifyRoomPage, }) => { - const [cancelModalVisible, showCancelModal] = useState(false); + const [confirmRemovePeriodicRoomVisible, setConfirmRemovePeriodicRoomVisible] = useState(false); const yearMonthFormat = formatWithOptions({ locale: zhCN }, "yyyy/MM"); const dayFormat = formatWithOptions({ locale: zhCN }, "dd"); @@ -76,16 +85,19 @@ export const PeriodicRoomPanel: React.FC = ({ pagination={false} > dayFormat(room.beginTime || defaultDate) + "日" } /> getWeekName(getDay(room.beginTime || defaultDate)) } /> { return ( timeSuffixFormat(room.beginTime || defaultDate) + @@ -95,17 +107,27 @@ export const PeriodicRoomPanel: React.FC = ({ }} /> { return ; }} /> - {/* - // TODO: MoreMenu component { - return null; - }} - /> */} + align="right" + render={(_, room: RoomInfo) => { + return ( + + ); + }} + /> )); @@ -135,14 +157,14 @@ export const PeriodicRoomPanel: React.FC = ({ ) : ( - )} @@ -150,9 +172,9 @@ export const PeriodicRoomPanel: React.FC = ({ {renderPeriodicRoomTable()} showCancelModal(false)} + onCancel={() => setConfirmRemovePeriodicRoomVisible(false)} onCancelRoom={onCancelRoom} isPeriodicDetailsPage={true} />