diff --git a/packages/frontend/src/components/views-tab/ViewsTab.tsx b/packages/frontend/src/components/views-tab/ViewsTab.tsx index b82cc923e..f75448890 100644 --- a/packages/frontend/src/components/views-tab/ViewsTab.tsx +++ b/packages/frontend/src/components/views-tab/ViewsTab.tsx @@ -5,8 +5,10 @@ import { twMerge, ViewTabButton, ShareViewDialog, + IconButton, } from "@alphaday/ui-kit"; import { useWindowSize } from "src/api/hooks"; +import useHeaderScroll from "src/api/hooks/useHeaderScroll"; import { ETutorialTipId, TCachedView, @@ -64,6 +66,9 @@ const ViewsTab: FC = memo(function ViewsTab({ const [showShareViewDialog, setShowShareViewDialog] = useState(false); + const { setHeaderRef, handleClickScroll, hideLeftPan, hideRightPan } = + useHeaderScroll(); + const isSelectedViewModified = selectedView && isViewModified(selectedView); const tabsCount = subscribedViews.length + (extraOptions?.length || 0); const { width } = useWindowSize(); @@ -132,69 +137,89 @@ const ViewsTab: FC = memo(function ViewsTab({ mobileOpen && "border-b-2 border-b-background" )} > -
- {subscribedViews.length !== 0 && isWalletBoardAllowed && ( - - currentTutorialTipId === - ETutorialTipId.WalletView && - ref && - setTutFocusElemRef(ref) - } - > - + {!hideLeftPan && ( + handleClickScroll()} + className="shrink-0 ml-1 h-8 !px-1 !rounded !bg-backgroundVariant100 hover:!bg-backgroundVariant200 active:!bg-backgroundVariant100" + /> + )} +
+ {subscribedViews.length !== 0 && isWalletBoardAllowed && ( + + currentTutorialTipId === + ETutorialTipId.WalletView && + ref && + setTutFocusElemRef(ref) } - walletViewName={walletView?.data.name} - options={[ - { - handler: - walletView && - walletViewState === - EWalletViewState.Ready - ? () => handleShareView(walletView) + > + + handleShareView( + walletView + ) + : undefined, + icon: "share", + title: "Share board", + key: "share-board", + }, + { + handler: walletView + ? () => + onRemoveView({ + id: walletView.data.id, + isReadOnly: + walletView.isReadOnly, + hash: walletView.data + .hash, + slug: walletView.data + .slug, + }) : undefined, - icon: "share", - title: "Share board", - key: "share-board", - }, - { - handler: walletView - ? () => - onRemoveView({ - id: walletView.data.id, - isReadOnly: - walletView.isReadOnly, - hash: walletView.data.hash, - slug: walletView.data.slug, - }) - : undefined, - icon: "trash", - title: "Remove board", - key: "remove-board", - }, - ]} - /> - - )} - {filteredSubscribedViews.map((view, index) => { - /** - * note: only including actions allowed for custom views for now - */ - const viewMenuOptions: TViewTabMenuOption[] | undefined = - view.data.is_system_view + icon: "trash", + title: "Remove board", + key: "remove-board", + }, + ]} + /> + + )} + {filteredSubscribedViews.map((view, index) => { + /** + * note: only including actions allowed for custom views for now + */ + const viewMenuOptions: + | TViewTabMenuOption[] + | undefined = view.data.is_system_view ? undefined : [ { @@ -220,70 +245,88 @@ const ViewsTab: FC = memo(function ViewsTab({ key: "remove-board", }, ]; - return ( - - index === - Math.floor(subscribedViews.length / 2) && // set the tut focus to the view in the middle - currentTutorialTipId === - ETutorialTipId.SwitchView && - ref && - setTutFocusElemRef(ref) - } - style={tabButtonWrapperStyle} - > - handleSelectTab(view)} - title={`Open ${view.data.name}`} - selected={ - selectedView?.data.hash === view.data.hash + return ( + + index === + Math.floor( + subscribedViews.length / 2 + ) && // set the tut focus to the view in the middle + currentTutorialTipId === + ETutorialTipId.SwitchView && + ref && + setTutFocusElemRef(ref) } - modified={isViewModified(view)} - options={viewMenuOptions} + style={tabButtonWrapperStyle} > - {view.data.name} - - - ); - })} - {extraOptions && - !mobileOpen && - extraOptions.map((option) => ( - - { - if (isSelectedViewModified) { - toast( - "Connect and verify your wallet to edit boards and enjoy more customizations", - { - type: EToastRole.Error, - } - ); - } - } - : option.handler - } - selected={false} - title="Save current board" - // disabled={option.disabled} + handleSelectTab(view)} + title={`Open ${view.data.name}`} + selected={ + selectedView?.data.hash === + view.data.hash + } + modified={isViewModified(view)} + options={viewMenuOptions} + > + + {view.data.name} + + + + ); + })} + {extraOptions && + !mobileOpen && + extraOptions.map((option) => ( + - {option.title} - - - ))} + { + if (isSelectedViewModified) { + toast( + "Connect and verify your wallet to edit boards and enjoy more customizations", + { + type: EToastRole.Error, + } + ); + } + } + : option.handler + } + selected={false} + title="Save current board" + // disabled={option.disabled} + > + {option.title} + + + ))} +
+ {!hideRightPan && ( + handleClickScroll(true)} + className="shrink-0 mr-1 h-8 !px-1 !rounded !bg-backgroundVariant100 hover:!bg-backgroundVariant200 active:!bg-backgroundVariant100" + /> + )}