From 7c1c1d82a1b431e5568e71271690e0d977b82c7a Mon Sep 17 00:00:00 2001 From: Kafigoto Date: Fri, 7 Jul 2023 17:13:04 -0300 Subject: [PATCH] Implements #67 suggestion --- src/App.tsx | 28 +++++++----- src/components/TopBar/FilePathBar.tsx | 51 ++++++++++++++++++++++ src/components/TopBar/FolderNavigation.tsx | 5 +-- src/components/TopBar/SearchBar.tsx | 4 +- 4 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 src/components/TopBar/FilePathBar.tsx diff --git a/src/App.tsx b/src/App.tsx index 610f2f3..f158902 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -16,6 +16,7 @@ import { updateDirectoryContents } from "./state/slices/currentDirectorySlice"; import {DIRECTORY_ENTITY_ID} from "./components/MainBody/DirectoryEntity"; +import FilePathBar from "./components/TopBar/FilePathBar"; function App() { const [volumes, setVolumes] = useState([]); @@ -104,7 +105,7 @@ function App() { }} onContextMenu={handleMainContextMenu}> -
+
-
- + + + +
-
+ +
{pathHistory[historyPlace] === "" && searchResults.length === 0 ? ( ) : ( @@ -131,11 +138,8 @@ function App() { /> )}
-
- -
); } -export default App; +export default App; \ No newline at end of file diff --git a/src/components/TopBar/FilePathBar.tsx b/src/components/TopBar/FilePathBar.tsx new file mode 100644 index 0000000..cf546e6 --- /dev/null +++ b/src/components/TopBar/FilePathBar.tsx @@ -0,0 +1,51 @@ +import { faHome, faPlay, faPlayCircle } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + +interface Props { + currentDirectoryPath: string; + onDirectoryClick: Function; +} + +export default function FilePathBar({ + currentDirectoryPath, + onDirectoryClick, +}:Props){ + async function onBarSectionClick(clickedDirectory:string){ + if (clickedDirectory === '') { + onDirectoryClick(clickedDirectory); + } + + const clickedSubstringStartIndex = currentDirectoryPath.indexOf(clickedDirectory); + const fullDirectoryEndIndex = clickedSubstringStartIndex + clickedDirectory.length; + + const clickedDirectoryFullPath = currentDirectoryPath.slice(0, fullDirectoryEndIndex); + onDirectoryClick(clickedDirectoryFullPath); + } + + return ( +
+ + { + currentDirectoryPath.split("\\").map((subString)=>{ + if (subString === "") return; + + return ( +
+
+ +
+ +
+ ) + })} +
+ ); +} \ No newline at end of file diff --git a/src/components/TopBar/FolderNavigation.tsx b/src/components/TopBar/FolderNavigation.tsx index a44ba6e..a433b48 100644 --- a/src/components/TopBar/FolderNavigation.tsx +++ b/src/components/TopBar/FolderNavigation.tsx @@ -9,7 +9,7 @@ export interface Props { } export default function FolderNavigation({ onBackArrowClick, canGoBackward, onForwardArrowClick, canGoForward }: Props) { - return
+ return
-
; -} +} \ No newline at end of file diff --git a/src/components/TopBar/SearchBar.tsx b/src/components/TopBar/SearchBar.tsx index b1407cf..4f5521a 100644 --- a/src/components/TopBar/SearchBar.tsx +++ b/src/components/TopBar/SearchBar.tsx @@ -54,7 +54,7 @@ export default function SearchBar({ } return ( -
+
); -} +} \ No newline at end of file