Files
readest/apps/readest-app/src/app/reader/components/SidebarToggler.tsx
T
Huang Xin ccc04825b7 feat(ux): improve pull-down interaction for mobile modal (#440)
* Adjusts overlay background opacity dynamically based on drag position
* Ensures smooth transition as the modal is pulled down
* Enhances UX for mobile users by making dismissal more intuitive
2025-02-24 01:05:13 +01:00

43 lines
1.2 KiB
TypeScript

import React from 'react';
import { TbLayoutSidebar, TbLayoutSidebarFilled } from 'react-icons/tb';
import { useReaderStore } from '@/store/readerStore';
import { useSidebarStore } from '@/store/sidebarStore';
import { useTranslation } from '@/hooks/useTranslation';
import Button from '@/components/Button';
interface SidebarTogglerProps {
bookKey: string;
}
const SidebarToggler: React.FC<SidebarTogglerProps> = ({ bookKey }) => {
const _ = useTranslation();
const { sideBarBookKey, isSideBarVisible, setSideBarBookKey, toggleSideBar } = useSidebarStore();
const { setHoveredBookKey } = useReaderStore();
const handleToggleSidebar = () => {
if (sideBarBookKey === bookKey) {
toggleSideBar();
} else {
setSideBarBookKey(bookKey);
if (!isSideBarVisible) toggleSideBar();
}
setHoveredBookKey('');
};
return (
<Button
icon={
sideBarBookKey === bookKey && isSideBarVisible ? (
<TbLayoutSidebarFilled className='text-base-content' />
) : (
<TbLayoutSidebar className='text-base-content' />
)
}
onClick={handleToggleSidebar}
tooltip={_('Sidebar')}
tooltipDirection='bottom'
/>
);
};
export default SidebarToggler;