Skip to content

Commit

Permalink
feat: file path redesign for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
tomicvladan committed Sep 13, 2023
1 parent 4d320be commit 99498ae
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/api/directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export async function createDirectory(
directory = '';
}

await fdp.directory.create(podName, combine(directory, directoryName));
await fdp.directory.create(
podName,
combine(...directory.split('/'), directoryName)
);
const time = getUnixTimestamp();
return {
name: directoryName,
Expand Down
4 changes: 3 additions & 1 deletion src/components/DirectoryPath/DirectoryPath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface DirectoryPathProps {
directory: string;
onDirectorySelect: (newDirectory: string) => void;
onBackToDrive: () => void;
className?: string;
}

const MAX_FOLDERS = 3;
Expand All @@ -21,6 +22,7 @@ const DirectoryPath = ({
directory,
onDirectorySelect,
onBackToDrive,
className,
}: DirectoryPathProps) => {
const { theme } = useContext(ThemeContext);
const [folders, displayedFolders] = useMemo(() => {
Expand All @@ -35,7 +37,7 @@ const DirectoryPath = ({
};

return (
<div className="md:ml-0 ml-2 flex items-center">
<div className={`flex items-center overflow-hidden ${className}`}>
{podName && (
<Button
variant="tertiary"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dropdowns/PodDropdown/PodDropdownToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const PodDropdownToggele = () => {
/>
)}
<Menu.Button className="flex items-center w-full cursor-pointer">
<div className="py-2 px-4 ">
<div className="py-2 px-4 hidden sm:block">
{theme === 'light' ? (
<DropdownMenuIconLight />
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
import DirectoryPath from '@components/DirectoryPath/DirectoryPath';
import PodDropdown from '@components/Dropdowns/PodDropdown/PodDropdown';

const DriveActionHeaderMobile = () => {
return <PodDropdown />;
interface DriveActionHeaderMobileProps {
podName: string;
directory: string;
onDirectorySelect: (newDirectory: string) => void;
onBackToDrive: () => void;
}

const DriveActionHeaderMobile = ({
podName,
directory,
onDirectorySelect,
onBackToDrive,
}: DriveActionHeaderMobileProps) => {
return (
<>
<PodDropdown />
<DirectoryPath
className="flex sm:hidden"
podName={podName}
directory={directory}
onDirectorySelect={onDirectorySelect}
onBackToDrive={onBackToDrive}
/>
</>
);
};

export default DriveActionHeaderMobile;
11 changes: 8 additions & 3 deletions src/pages/drive/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import SearchResultsDarkIcon from '@media/UI/search-results-dark.svg';
import Spinner from '@components/Spinner/Spinner';
import DriveActionHeaderMobile from '@components/NavigationBars/DriveActionBar/DriveActionHeaderMobile';
import { DirectoryItem, FileItem } from '@fairdatasociety/fdp-storage';
import SelectPodCard from '@components/Cards/SelectPodCard/SelectPodCard';
import {
CacheType,
getCache,
Expand Down Expand Up @@ -227,12 +226,18 @@ const Drive: FC = () => {
return (
<MainLayout updateDrive={handleUpdateDrive} refreshPods={handleFetchPods}>
<div className="flex flex-col">
<div className="block md:hidden">
<DriveActionHeaderMobile />
<div className="flex md:hidden">
<DriveActionHeaderMobile
podName={activePod}
directory={directoryName}
onDirectorySelect={handleDirectoryPathChange}
onBackToDrive={onBackToDrive}
/>
</div>
<MainHeader
title={
<DirectoryPath
className="hidden sm:flex"
podName={activePod}
directory={directoryName}
onDirectorySelect={handleDirectoryPathChange}
Expand Down

0 comments on commit 99498ae

Please sign in to comment.