mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
some tweaks
This commit is contained in:
@@ -47,14 +47,6 @@ const RoutedTabs = ({ tabs, defaultActiveTab }: Props) => {
|
||||
setActiveTab(index);
|
||||
}, [ tabs, router ]);
|
||||
|
||||
const handleItemInMenuClick = React.useCallback((event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
const tabIndex = (event.target as HTMLButtonElement).getAttribute('data-index');
|
||||
|
||||
if (tabIndex) {
|
||||
handleTabChange(tabsCut + Number(tabIndex));
|
||||
}
|
||||
}, [ handleTabChange, tabsCut ]);
|
||||
|
||||
return (
|
||||
<Tabs variant="soft-rounded" colorScheme="blue" isLazy onChange={ handleTabChange } index={ activeTab }>
|
||||
<TabList marginBottom={{ base: 6, lg: 8 }} flexWrap="nowrap" whiteSpace="nowrap" ref={ listRef }>
|
||||
@@ -74,7 +66,7 @@ const RoutedTabs = ({ tabs, defaultActiveTab }: Props) => {
|
||||
{ opacity: tabsCut === 0 ? 0 : 1 } :
|
||||
hiddenItemStyles
|
||||
}
|
||||
onItemClick={ handleItemInMenuClick }
|
||||
onItemClick={ handleTabChange }
|
||||
buttonRef={ tabsRefs[index] }
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -18,12 +18,20 @@ interface Props {
|
||||
tabsCut: number;
|
||||
isActive: boolean;
|
||||
styles?: StyleProps;
|
||||
onItemClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
||||
onItemClick: (index: number) => void;
|
||||
buttonRef: React.RefObject<HTMLButtonElement>;
|
||||
}
|
||||
|
||||
const RoutedTabsMenu = ({ tabs, tabsCut, isActive, styles, onItemClick, buttonRef, activeTab }: Props) => {
|
||||
const { isOpen, onToggle } = useDisclosure();
|
||||
const { isOpen, onToggle, onClose } = useDisclosure();
|
||||
|
||||
const handleItemClick = React.useCallback((event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
onClose();
|
||||
const tabIndex = (event.target as HTMLButtonElement).getAttribute('data-index');
|
||||
if (tabIndex) {
|
||||
onItemClick(tabsCut + Number(tabIndex));
|
||||
}
|
||||
}, [ onClose, onItemClick, tabsCut ]);
|
||||
|
||||
return (
|
||||
<Popover isLazy placement="bottom-end" key="more">
|
||||
@@ -44,7 +52,7 @@ const RoutedTabsMenu = ({ tabs, tabsCut, isActive, styles, onItemClick, buttonRe
|
||||
<Button
|
||||
key={ tab.routeName }
|
||||
variant="subtle"
|
||||
onClick={ onItemClick }
|
||||
onClick={ handleItemClick }
|
||||
isActive={ activeTab.routeName === tab.routeName }
|
||||
justifyContent="left"
|
||||
data-index={ index }
|
||||
|
||||
Reference in New Issue
Block a user