a1cb228d00
Long translations (e.g. German "Gruppieren", "Löschen") pushed the 6-button action bar past the right edge on typical phones since the grid fallback only triggered below 350px. Switch to a 3x2 grid below sm: and clamp the container to the viewport width. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
119 lines
3.3 KiB
TypeScript
119 lines
3.3 KiB
TypeScript
import clsx from 'clsx';
|
|
import {
|
|
MdDelete,
|
|
MdOpenInNew,
|
|
MdOutlineCancel,
|
|
MdInfoOutline,
|
|
MdCheckCircleOutline,
|
|
} from 'react-icons/md';
|
|
import { LuFolderPlus } from 'react-icons/lu';
|
|
import { useKeyDownActions } from '@/hooks/useKeyDownActions';
|
|
import { useTranslation } from '@/hooks/useTranslation';
|
|
import { isMd5 } from '@/utils/md5';
|
|
|
|
interface SelectModeActionsProps {
|
|
selectedBooks: string[];
|
|
safeAreaBottom: number;
|
|
onOpen: () => void;
|
|
onGroup: () => void;
|
|
onDetails: () => void;
|
|
onStatus: () => void;
|
|
onDelete: () => void;
|
|
onCancel: () => void;
|
|
}
|
|
|
|
const SelectModeActions: React.FC<SelectModeActionsProps> = ({
|
|
selectedBooks,
|
|
safeAreaBottom,
|
|
onOpen,
|
|
onGroup,
|
|
onDetails,
|
|
onStatus,
|
|
onDelete,
|
|
onCancel,
|
|
}) => {
|
|
const _ = useTranslation();
|
|
|
|
const hasSelection = selectedBooks.length > 0;
|
|
const hasValidBooks = selectedBooks.every((id) => isMd5(id));
|
|
const hasSingleSelection = selectedBooks.length === 1;
|
|
const divRef = useKeyDownActions({ onCancel });
|
|
|
|
return (
|
|
<div
|
|
ref={divRef}
|
|
className='fixed bottom-0 left-0 right-0 z-40'
|
|
style={{
|
|
paddingBottom: `${safeAreaBottom + 16}px`,
|
|
}}
|
|
>
|
|
<div
|
|
className={clsx(
|
|
'text-base-content text-xs shadow-lg',
|
|
'not-eink:bg-base-300 eink:bg-base-100 eink:border eink:border-base-content',
|
|
'mx-auto w-fit max-w-[calc(100vw-1rem)] rounded-lg p-4',
|
|
'flex items-center justify-center gap-x-6',
|
|
'max-sm:grid max-sm:grid-cols-3 max-sm:gap-x-6 max-sm:gap-y-3',
|
|
)}
|
|
>
|
|
<button
|
|
onClick={onOpen}
|
|
className={clsx(
|
|
'flex flex-col items-center justify-center gap-1',
|
|
(!hasSelection || !hasValidBooks) && 'btn-disabled opacity-50',
|
|
)}
|
|
>
|
|
<MdOpenInNew />
|
|
<div>{_('Open')}</div>
|
|
</button>
|
|
<button
|
|
onClick={onGroup}
|
|
className={clsx(
|
|
'flex flex-col items-center justify-center gap-1',
|
|
!hasSelection && 'btn-disabled opacity-50',
|
|
)}
|
|
>
|
|
<LuFolderPlus />
|
|
<div>{_('Group')}</div>
|
|
</button>
|
|
<button
|
|
onClick={onStatus}
|
|
className={clsx(
|
|
'flex flex-col items-center justify-center gap-1',
|
|
(!hasSelection || !hasValidBooks) && 'btn-disabled opacity-50',
|
|
)}
|
|
>
|
|
<MdCheckCircleOutline />
|
|
<div>{_('Status')}</div>
|
|
</button>
|
|
<button
|
|
onClick={onDetails}
|
|
className={clsx(
|
|
'flex flex-col items-center justify-center gap-1',
|
|
(!hasSingleSelection || !hasValidBooks) && 'btn-disabled opacity-50',
|
|
)}
|
|
>
|
|
<MdInfoOutline />
|
|
<div>{_('Details')}</div>
|
|
</button>
|
|
<button
|
|
onClick={onDelete}
|
|
className={clsx(
|
|
'flex flex-col items-center justify-center gap-1',
|
|
!hasSelection && 'btn-disabled opacity-50',
|
|
)}
|
|
>
|
|
<MdDelete className='text-red-500' />
|
|
<div className='text-red-500'>{_('Delete')}</div>
|
|
</button>
|
|
<button onClick={onCancel} className='flex flex-col items-center justify-center gap-1'>
|
|
<MdOutlineCancel />
|
|
<div>{_('Cancel')}</div>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SelectModeActions;
|