From aa320a174ba55bcffca71190800cc1e1cf15b9d8 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Mon, 25 Jul 2022 18:41:50 +0800 Subject: [PATCH] feat(view): view support group menu --- .../src/blocks/group/GroupMenu.tsx | 75 ++++++++++++++----- 1 file changed, 56 insertions(+), 19 deletions(-) diff --git a/libs/components/editor-blocks/src/blocks/group/GroupMenu.tsx b/libs/components/editor-blocks/src/blocks/group/GroupMenu.tsx index 967b9b3afc..1d79daba9f 100644 --- a/libs/components/editor-blocks/src/blocks/group/GroupMenu.tsx +++ b/libs/components/editor-blocks/src/blocks/group/GroupMenu.tsx @@ -1,35 +1,61 @@ -import { useState } from 'react'; -import type { ReactNode } from 'react'; +import { CommingSoon } from '@toeverything/components/common'; import { mergeToPreviousGroup, RecastScene, + RecastView, useRecastBlockScene, useRecastKanbanGroupBy, + useRecastView, } from '@toeverything/components/editor-core'; -import { Popover, useTheme, Tooltip } from '@toeverything/components/ui'; +import { + AddViewIcon, + FilterIcon, + FullScreenIcon, + GroupByIcon, + GroupIcon, + KanBanIcon, + SortIcon, + TableIcon, + TodoListIcon, +} from '@toeverything/components/icons'; +import { Popover, useTheme } from '@toeverything/components/ui'; +import { useFlag } from '@toeverything/datasource/feature-flags'; import type { AsyncBlock, BlockEditor } from '@toeverything/framework/virgo'; +import type { ReactElement, ReactNode } from 'react'; +import { useState } from 'react'; import { Filter } from './components/filter'; -import { Sorter } from './components/sorter'; +import { GroupBy } from './components/group-by/GroupBy'; import { GroupPanel } from './components/group-panel/GroupPanel'; import { IconButton } from './components/IconButton'; import { Line } from './components/Line'; -import { - TodoListIcon, - KanBanIcon, - TableIcon, - FilterIcon, - SortIcon, - FullScreenIcon, - GroupIcon, - GroupByIcon, -} from '@toeverything/components/icons'; +import { Sorter } from './components/sorter'; import { PANEL_CONFIG, SCENE_CONFIG } from './config'; - import type { ActivePanel } from './types'; -import { useFlag } from '@toeverything/datasource/feature-flags'; -import { GroupBy } from './components/group-by/GroupBy'; -import { CommingSoon } from '@toeverything/components/common'; +const VIEW_ICON_MAP: Record = { + page: , + kanban: , + table: , +}; + +const ViewsMenu = () => { + const { currentView, recastViews, changeView } = useRecastView(); + return ( + <> + {recastViews.map(view => ( + changeView(view)} + > + {VIEW_ICON_MAP[view.type]} + {view.name} + + ))} + + ); +}; + const GroupMenuWrapper = ({ block, editor, @@ -59,7 +85,6 @@ const GroupMenuWrapper = ({ if (!groupBy?.id) { setActivePanel(null); } - setOpenPanel(null); }; @@ -97,6 +122,18 @@ const GroupMenuWrapper = ({ Kanban + + + + setActivePanel(PANEL_CONFIG.ADD_VIEW as ActivePanel) + } + > + + Add View + + { // // Closed beta period temporarily // filterSorterFlag && (