diff --git a/package.json b/package.json index a3d76e1..3faa08e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", + "spectre.css": "^0.5.9", "typescript": "^4.1.2", "web-vitals": "^1.0.1" }, @@ -57,5 +58,6 @@ "apollo": "^2.33.4", "eslint": "^7.31.0", "eslint-plugin-react": "^7.24.0" - } + }, + "proxy": "http://localhost:8080" } diff --git a/src/App.tsx b/src/App.tsx index 974e8a7..c0f4825 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,8 +4,8 @@ import FileBrowser from "./components/FileBrowser" const App: React.FC = () => { return ( -
- +
+
) } diff --git a/src/components/Breadcrum.tsx b/src/components/Breadcrum.tsx new file mode 100644 index 0000000..3c76dbc --- /dev/null +++ b/src/components/Breadcrum.tsx @@ -0,0 +1,36 @@ +import React from "react" +import PropTypes from "prop-types" + +interface Props{ + path: string + onDirClick?: (path: string) => void +} + +const Breadcrum: React.FC = (props) => { + const parts = props.path.split("/").filter(e=>e.length > 0) + + return ( + + ) +} + +Breadcrum.propTypes = { + path: PropTypes.string.isRequired, + onDirClick: PropTypes.func +} + +export default Breadcrum diff --git a/src/components/DirectoryElement.tsx b/src/components/DirectoryElement.tsx index 9a701d4..4b5c246 100644 --- a/src/components/DirectoryElement.tsx +++ b/src/components/DirectoryElement.tsx @@ -8,9 +8,14 @@ interface Props { const DirectoryElement: React.FC = (props) => { return ( -
- 📂 {props.dir.name} -
+ <> + + 📂 + + + {props.dir.name} + + ) } diff --git a/src/components/FileBrowser.tsx b/src/components/FileBrowser.tsx index 670041d..04dc549 100644 --- a/src/components/FileBrowser.tsx +++ b/src/components/FileBrowser.tsx @@ -1,17 +1,9 @@ import React from "react" import { useState } from "react" import { useOpenDirQuery } from "../generated/graphql" +import Breadcrum from "./Breadcrum" import FileBrowserElement from "./FileBrowserElement" -function parentDir(path:string): string { - if(path.endsWith("/")){ - path = path.substr(0,path.length - 1) - } - const paths = path.split("/") - paths.pop() - return paths.join("/") -} - const FileBrowser: React.FC = () => { const [path,setPath] = useState("/") @@ -23,24 +15,34 @@ const FileBrowser: React.FC = () => { return (
-
{ - setPath(parentDir(path)) - }}> - .. -
+ { + console.debug(newPath) + setPath(newPath) + }}/>
- { data?.files.map(v => ())} + + + + + + + + - { data?.directorys.map(v => ({ - setPath(data.id) - }} - />))} + { data?.directorys.map(v => ({ + setPath(data.id) + }} + />))} + + { data?.files.map(v => ())} + +
IconName
) diff --git a/src/components/FileBrowserElement.tsx b/src/components/FileBrowserElement.tsx index c5d9694..711ff67 100644 --- a/src/components/FileBrowserElement.tsx +++ b/src/components/FileBrowserElement.tsx @@ -12,7 +12,7 @@ interface Props { const FileBrowserElement: React.FC = (props) => { return ( -
{ + { if(props.file){ props.onClick?.(props.file) }else if(props.dir){ @@ -20,7 +20,7 @@ const FileBrowserElement: React.FC = (props) => { } }}> {(props.file) ? :(props.dir)?:<>} -
+ ) } diff --git a/src/components/FileElement.tsx b/src/components/FileElement.tsx index 9d5c985..229a374 100644 --- a/src/components/FileElement.tsx +++ b/src/components/FileElement.tsx @@ -8,9 +8,14 @@ interface Props { const FileElement: React.FC = (props) => { return ( -
- 📄 {props.file.name} -
+ <> + + 📄 + + + {props.file.name} + + ) } diff --git a/src/index.tsx b/src/index.tsx index ece3902..318f99e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,9 +3,10 @@ import ReactDOM from "react-dom" import "./index.scss" import App from "./App" import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client" +import "spectre.css" const client = new ApolloClient({ - uri: "http://localhost:8080/graphql", + uri: "/graphql", cache: new InMemoryCache() }) diff --git a/yarn.lock b/yarn.lock index 5ad587f..ffefd15 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12959,6 +12959,11 @@ spdy@^4.0.2: select-hose "^2.0.0" spdy-transport "^3.0.0" +spectre.css@^0.5.9: + version "0.5.9" + resolved "https://registry.yarnpkg.com/spectre.css/-/spectre.css-0.5.9.tgz#86c732d093036d9fdc0a2ba570f005e4023ae6ca" + integrity sha512-9jUqwZmCnvflrxFGcK+ize43TvjwDjqMwZPVubEtSIHzvinH0TBUESm1LcOJx3Ur7bdPaeOHQIjOqBl1Y5kLFw== + split-on-first@^1.0.0: version "1.1.0" resolved "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz"