Skip to content

Commit 2a36222

Browse files
feat: support mobile view for copy modal (#549)
1 parent b70d55b commit 2a36222

File tree

1 file changed

+74
-21
lines changed

1 file changed

+74
-21
lines changed

src/components/FileManager/components/DestinationFolderPopup/DestinationFolderPopup.tsx

Lines changed: 74 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import {
88
DialPrimaryButton,
99
DialNeutralButton,
1010
} from '@/components/Button/ButtonWrappers';
11+
import { DialButton } from '@/components/Button/Button';
1112
import { ButtonAppearance } from '@/types/button';
12-
import { IconFolderPlus } from '@tabler/icons-react';
13+
import { IconFolderPlus, IconDotsVertical, IconEye } from '@tabler/icons-react';
1314
import { BASE_ICON_PROPS } from '@/constants/icon';
1415
import { DialSwitch } from '@/components/Switch/Switch';
1516
import {
@@ -25,6 +26,9 @@ import type { DialFileManagerActionsRef } from '@/models/file-manager';
2526
import { DialTooltip } from '@/components/Tooltip/Tooltip';
2627
import { mergeClasses } from '@/utils/merge-classes';
2728
import { DialAlert, type DialAlertProps } from '@/components/Alert/Alert';
29+
import { DialDropdown } from '@/components/Dropdown/Dropdown';
30+
import { useIsMobileScreen } from '@/hooks/use-is-mobile-screen';
31+
import type { DropdownItem } from '@/models/dropdown';
2832

2933
export interface DestinationFolderPopupProps extends DialFileManagerProps {
3034
onClose: () => void;
@@ -107,12 +111,40 @@ export const DialDestinationFolderPopup: FC<DestinationFolderPopupProps> = ({
107111
...restProps
108112
}: DestinationFolderPopupProps) => {
109113
const [showHiddenFiles, setShowHiddenFiles] = useState(false);
114+
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
110115
const fileManagerActionRef = useRef<DialFileManagerActionsRef>(null);
116+
const isMobile = useIsMobileScreen();
111117

112118
const handleShowHiddenFilesChange = useCallback((value: boolean) => {
113119
setShowHiddenFiles(value);
114120
}, []);
115121

122+
const mobileFooterDropdownItems = useMemo<DropdownItem[]>(
123+
() => [
124+
{
125+
key: 'add-folder',
126+
label: addFolderLabel,
127+
icon: (
128+
<IconFolderPlus {...BASE_ICON_PROPS} className="text-secondary" />
129+
),
130+
onClick: () => {
131+
fileManagerActionRef.current?.createFolder();
132+
setMobileMenuOpen(false);
133+
},
134+
},
135+
{
136+
key: 'show-hidden-files',
137+
label: hiddenFilesSwitcherLabel,
138+
icon: <IconEye {...BASE_ICON_PROPS} className="text-secondary" />,
139+
onClick: () => {
140+
setShowHiddenFiles((prev) => !prev);
141+
setMobileMenuOpen(false);
142+
},
143+
},
144+
],
145+
[addFolderLabel, hiddenFilesSwitcherLabel],
146+
);
147+
116148
const handleOnPathChange = useCallback(
117149
(nextPath?: string) => {
118150
if (nextPath) {
@@ -143,27 +175,48 @@ export const DialDestinationFolderPopup: FC<DestinationFolderPopupProps> = ({
143175
size={PopupSize.Lg}
144176
className="md:!h-[800px] !bg-layer-2"
145177
footer={
146-
<div className="flex justify-between space-x-2 py-4 px-6">
147-
<div className="flex space-x-4">
148-
<DialPrimaryButton
149-
label={addFolderLabel}
150-
appearance={ButtonAppearance.Ghost}
151-
iconBefore={<IconFolderPlus {...BASE_ICON_PROPS} />}
152-
onClick={() => {
153-
fileManagerActionRef.current?.createFolder();
154-
}}
155-
/>
156-
<div className="border border-l border-primary my-2" />
157-
<div className="inline-flex items-center cursor-pointer">
158-
<DialSwitch
159-
label={hiddenFilesSwitcherLabel}
160-
isOn={showHiddenFiles}
161-
onChange={handleShowHiddenFilesChange}
162-
switchId="hidden-files-switch"
163-
/>
164-
</div>
178+
<div className="flex justify-between items-center gap-2 py-4 px-4 md:px-6">
179+
<div className="flex items-center gap-4 min-w-0">
180+
{isMobile ? (
181+
<DialDropdown
182+
menu={{ items: mobileFooterDropdownItems }}
183+
open={mobileMenuOpen}
184+
onOpenChange={setMobileMenuOpen}
185+
>
186+
<DialButton
187+
className="h-9 w-9 shrink-0"
188+
aria-label="More options"
189+
iconBefore={
190+
<IconDotsVertical
191+
{...BASE_ICON_PROPS}
192+
className="text-secondary"
193+
/>
194+
}
195+
/>
196+
</DialDropdown>
197+
) : (
198+
<>
199+
<DialPrimaryButton
200+
label={addFolderLabel}
201+
appearance={ButtonAppearance.Ghost}
202+
iconBefore={<IconFolderPlus {...BASE_ICON_PROPS} />}
203+
onClick={() => {
204+
fileManagerActionRef.current?.createFolder();
205+
}}
206+
/>
207+
<div className="w-px h-[26px] bg-controls-disable-accent my-2" />
208+
<div className="inline-flex items-center cursor-pointer">
209+
<DialSwitch
210+
label={hiddenFilesSwitcherLabel}
211+
isOn={showHiddenFiles}
212+
onChange={handleShowHiddenFilesChange}
213+
switchId="hidden-files-switch"
214+
/>
215+
</div>
216+
</>
217+
)}
165218
</div>
166-
<div className="flex space-x-4">
219+
<div className="flex space-x-4 items-center">
167220
<DialNeutralButton onClick={onClose} label="Cancel" />
168221
{isDestinationDisabled ? (
169222
<DialTooltip tooltip={disabledPathTooltip}>

0 commit comments

Comments
 (0)