From 470ceaffae6cfaf2689d7a811ed17e282dfd3423 Mon Sep 17 00:00:00 2001 From: Jamie Pine Date: Mon, 18 Apr 2022 16:06:33 -0700 Subject: [PATCH] interface has solo dev mode + made a lot of stuff work --- .vscode/settings.json | 2 + apps/desktop/src-tauri/tauri.conf.json | 2 +- apps/desktop/src/index.tsx | 42 +++++++++++---- apps/desktop/vite.config.ts | 12 ++--- apps/web/components/Layout.tsx | 22 +++----- apps/web/components/global.scss | 8 +++ apps/web/interfaces/index.ts | 10 ---- apps/web/package.json | 7 ++- apps/web/pages/_app.tsx | 7 +++ apps/web/pages/index.tsx | 15 +++--- apps/web/postcss.config.js | 6 +++ apps/web/tailwind.config.js | 7 +++ apps/web/utils/sample-data.ts | 9 ---- apps/webapp/README.md | 1 + apps/webapp/index.html | 11 ++++ apps/webapp/package.json | 50 ++++++++++++++++++ apps/webapp/public/manifest.json | 25 +++++++++ apps/webapp/public/robots.txt | 3 ++ apps/webapp/src/App.tsx | 40 ++++++++++++++ apps/webapp/src/index.css | 6 +++ apps/webapp/src/index.tsx | 11 ++++ apps/webapp/tsconfig.json | 26 +++++++++ apps/webapp/vite.config.ts | 19 +++++++ package.json | 1 + packages/interface/package.json | 5 +- packages/interface/src/App.tsx | 13 ++++- .../src/components/file/FileItem.tsx | 7 ++- packages/interface/src/dev.tsx | 33 ++++++++++++ packages/interface/src/index.html | 11 ++++ packages/interface/src/index.ts | 3 ++ packages/interface/tsconfig.json | 1 + packages/interface/vite.config.ts | 8 ++- pnpm-lock.yaml | Bin 144096 -> 416092 bytes 33 files changed, 353 insertions(+), 70 deletions(-) create mode 100644 apps/web/components/global.scss delete mode 100644 apps/web/interfaces/index.ts create mode 100644 apps/web/pages/_app.tsx create mode 100644 apps/web/postcss.config.js create mode 100644 apps/web/tailwind.config.js delete mode 100644 apps/web/utils/sample-data.ts create mode 100644 apps/webapp/README.md create mode 100644 apps/webapp/index.html create mode 100644 apps/webapp/package.json create mode 100644 apps/webapp/public/manifest.json create mode 100644 apps/webapp/public/robots.txt create mode 100644 apps/webapp/src/App.tsx create mode 100644 apps/webapp/src/index.css create mode 100644 apps/webapp/src/index.tsx create mode 100644 apps/webapp/tsconfig.json create mode 100644 apps/webapp/vite.config.ts create mode 100644 packages/interface/src/dev.tsx create mode 100644 packages/interface/src/index.html diff --git a/.vscode/settings.json b/.vscode/settings.json index 838c51cb2..f42f50772 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,12 +2,14 @@ "cSpell.words": [ "bpfrpt", "creationdate", + "honkhonk", "ipfs", "Keepsafe", "pathctx", "proptype", "quicktime", "repr", + "svgr", "tailwindcss" ], "rust-analyzer.procMacro.enable": true, diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index d28b31fc1..b7e7a7596 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -5,7 +5,7 @@ }, "build": { "distDir": "../dist", - "devPath": "http://localhost:8085", + "devPath": "http://localhost:8001", "beforeDevCommand": "", "beforeBuildCommand": "" }, diff --git a/apps/desktop/src/index.tsx b/apps/desktop/src/index.tsx index bcb8d29de..f2eb22db7 100644 --- a/apps/desktop/src/index.tsx +++ b/apps/desktop/src/index.tsx @@ -1,14 +1,14 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { createRoot } from 'react-dom/client'; // import Spacedrive interface -import SpacedriveInterface from '@sd/interface'; +import SpacedriveInterface, { Platform } from '@sd/interface'; import '@sd/interface/dist/style.css'; // import types from Spacedrive core (TODO: re-export from client would be cleaner) import { ClientCommand, ClientQuery, CoreEvent } from '@sd/core'; // import Spacedrive JS client -import { BaseTransport, setTransport } from '@sd/client'; +import { BaseTransport } from '@sd/client'; // import tauri apis import { invoke, os } from '@tauri-apps/api'; @@ -21,18 +21,34 @@ class Transport extends BaseTransport { return await invoke('client_command_transport', { data: query }); } } -setTransport(new Transport()); -const root = createRoot(document.getElementById('root')!); +function App() { + function getPlatform(platform: string): Platform { + switch (platform) { + case 'darwin': + return 'macOS'; + case 'win32': + return 'windows'; + case 'linux': + return 'linux'; + default: + return 'browser'; + } + } -root.render( - + const [platform, setPlatform] = useState('macOS'); + + useEffect(() => { + os.platform().then((platform) => setPlatform(getPlatform(platform))); + }, []); + + return ( + ); +} + +const root = createRoot(document.getElementById('root')!); + +root.render( + + ); diff --git a/apps/desktop/vite.config.ts b/apps/desktop/vite.config.ts index 3270f519e..6b2fb9fd9 100644 --- a/apps/desktop/vite.config.ts +++ b/apps/desktop/vite.config.ts @@ -5,23 +5,17 @@ import react from '@vitejs/plugin-react'; // https://vitejs.dev/config/ export default defineConfig({ server: { - port: 8085 + port: 8001 }, plugins: [ react({ jsxRuntime: 'classic' }) ], - esbuild: { - jsxInject: 'import {jsx as _jsx} from "react/jsx-runtime"' - }, - root: 'src', - publicDir: '@sd/interface/src/assets', + publicDir: '../../packages/interface/src/assets', build: { outDir: '../dist', - emptyOutDir: false, assetsDir: '.' - }, - base: '' + } }); diff --git a/apps/web/components/Layout.tsx b/apps/web/components/Layout.tsx index 546511c06..cb35cf876 100644 --- a/apps/web/components/Layout.tsx +++ b/apps/web/components/Layout.tsx @@ -15,26 +15,16 @@ const Layout = ({ children, title = 'This is the default title' }: Props) => (
- */}
- {children} -
-
- I'm here to stay (Footer) -
+
{children as any}
+ {/*
+ Version 0.1.0 +
*/} ); diff --git a/apps/web/components/global.scss b/apps/web/components/global.scss new file mode 100644 index 000000000..deb636ec1 --- /dev/null +++ b/apps/web/components/global.scss @@ -0,0 +1,8 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + + +html { + // background-color: black; +} \ No newline at end of file diff --git a/apps/web/interfaces/index.ts b/apps/web/interfaces/index.ts deleted file mode 100644 index 68528c551..000000000 --- a/apps/web/interfaces/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -// You can include shared interfaces/types in a separate file -// and then use them in any component by importing them. For -// example, to import the interface below do: -// -// import { User } from 'path/to/interfaces'; - -export type User = { - id: number - name: string -} diff --git a/apps/web/package.json b/apps/web/package.json index 6e4fbc63c..153b76e08 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -8,9 +8,14 @@ "type-check": "tsc" }, "dependencies": { + "@sd/interface": "*", + "autoprefixer": "^10.4.4", "next": "latest", + "postcss": "^8.4.12", "react": "^17.0.2", - "react-dom": "^17.0.2" + "react-dom": "^17.0.2", + "sass": "^1.50.0", + "tailwindcss": "^3.0.23" }, "devDependencies": { "@types/node": "^12.12.21", diff --git a/apps/web/pages/_app.tsx b/apps/web/pages/_app.tsx new file mode 100644 index 000000000..fa9af6e2a --- /dev/null +++ b/apps/web/pages/_app.tsx @@ -0,0 +1,7 @@ +import '../components/global.scss'; + +function MyApp({ Component, pageProps }) { + return ; +} + +export default MyApp; diff --git a/apps/web/pages/index.tsx b/apps/web/pages/index.tsx index 0e53394ab..cc241ad49 100644 --- a/apps/web/pages/index.tsx +++ b/apps/web/pages/index.tsx @@ -1,14 +1,17 @@ import Link from 'next/link'; import Layout from '../components/Layout'; +// import Spacedrive interface + const IndexPage = () => ( -

A file explorer from the future

-

- - About - -

+

A file explorer from the future

+