bring hte ui back

This commit is contained in:
Michael Zhang 2024-07-26 20:50:57 -05:00
parent 94c3ca8773
commit ab8279db6e
63 changed files with 1580 additions and 2280 deletions

1
.envrc
View file

@ -1,2 +1 @@
export DATABASE_URL=sqlite://$(pwd)/test.db
use flake

2294
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
workspace.resolver = "2"
workspace.members = ["apps/*", "crates/*", "ui/src-tauri"]
workspace.members = ["ui/src-tauri"]
[profile.wasm-debug]
inherits = "dev"

BIN
bun.lockb Normal file → Executable file

Binary file not shown.

View file

@ -23,6 +23,14 @@ This app takes inspiration from many similar apps, such as Anytype, Logseq, Noti
- Multiuser
- Google docs like interface for docs / typst
## Development Principles
These are the goals for panorama development.
- **Local first.** Everything is first committed to a local database.
- **Keyboard friendly.**
- **Gradual adoption.**
## Custom Apps List
- File Backup

View file

@ -1,8 +1,13 @@
{
"name": "panorama",
"private": true,
"workspaces": [
"packages/*",
"apps/*"
]
"name": "panorama",
"private": true,
"workspaces": [
"packages/*",
"apps/*"
],
"trustedDependencies": [
"electron",
"esbuild",
"sqlite3"
]
}

View file

@ -6,6 +6,7 @@
"@biomejs/biome": "^1.8.3",
"@types/bun": "latest",
"@types/koa-json": "^2.0.23",
"@types/koa__cors": "^5.0.0",
"@types/koa__router": "^12.0.4"
},
"peerDependencies": {
@ -13,6 +14,7 @@
},
"dependencies": {
"@koa/bodyparser": "^5.1.1",
"@koa/cors": "^5.0.0",
"@koa/router": "^12.0.1",
"koa": "^2.15.3",
"koa-json": "^2.0.2",

View file

@ -1,4 +1,5 @@
import Koa, { type Context } from "koa";
import cors from "@koa/cors";
import json from "koa-json";
import Router from "@koa/router";
import { dataSource } from "./db";
@ -10,11 +11,17 @@ import { bodyParser } from "@koa/bodyparser";
const app = new Koa();
const router = new Router();
app.use(cors());
app.use(json());
app.use(bodyParser());
app.use(async (ctx, next) => {
console.log("Got a request from %s for %s", ctx.request.ip, ctx.method, ctx.path);
console.log(
"Got a request from %s for %s",
ctx.request.ip,
ctx.method,
ctx.path,
);
return next();
});

24
ui/.gitignore vendored Normal file
View file

@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

3
ui/.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}

7
ui/README.md Normal file
View file

@ -0,0 +1,7 @@
# Tauri + React + Typescript
This template should help get you started developing with Tauri, React and Typescript in Vite.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)

BIN
ui/bun.lockb Executable file

Binary file not shown.

14
ui/index.html Normal file
View file

@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + React + Typescript</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

59
ui/package.json Normal file
View file

@ -0,0 +1,59 @@
{
"name": "panorama",
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@floating-ui/react": "^0.26.16",
"@fontsource/inter": "^5.0.18",
"@mui/icons-material": "^5.15.18",
"@mui/material": "^5.15.18",
"@react-spring/web": "^9.7.3",
"@remark-embedder/core": "^3.0.3",
"@tanstack/react-query": "^5.37.1",
"@tauri-apps/api": "^1",
"@tauri-apps/plugin-window-state": "2.0.0-beta.6",
"@uidotdev/usehooks": "^2.4.1",
"@uiw/react-md-editor": "^4.0.4",
"classnames": "^2.5.1",
"date-fns": "^3.6.0",
"formik": "^2.4.6",
"hast-util-to-jsx-runtime": "^2.3.0",
"hast-util-to-mdast": "^10.1.0",
"immutable": "^4.3.6",
"javascript-time-ago": "^2.5.10",
"jotai": "^2.8.1",
"katex": "^0.16.10",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-to-markdown": "^2.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^9.0.1",
"react-time-ago": "^7.3.3",
"rehype-katex": "^7.0.0",
"remark": "^15.0.1",
"remark-math": "^6.0.0",
"remark-rehype": "^11.1.0",
"use-debounce": "^10.0.1",
"uuidv7": "^1.0.0",
"vfile": "^6.0.1"
},
"devDependencies": {
"@tauri-apps/cli": "2.0.0-beta.20",
"@types/mdast": "^4.0.4",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.2.1",
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.77.2",
"typescript": "^5.0.2",
"vite": "^5.0.0"
}
}

6
ui/public/tauri.svg Normal file
View file

@ -0,0 +1,6 @@
<svg width="206" height="231" viewBox="0 0 206 231" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M143.143 84C143.143 96.1503 133.293 106 121.143 106C108.992 106 99.1426 96.1503 99.1426 84C99.1426 71.8497 108.992 62 121.143 62C133.293 62 143.143 71.8497 143.143 84Z" fill="#FFC131"/>
<ellipse cx="84.1426" cy="147" rx="22" ry="22" transform="rotate(180 84.1426 147)" fill="#24C8DB"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M166.738 154.548C157.86 160.286 148.023 164.269 137.757 166.341C139.858 160.282 141 153.774 141 147C141 144.543 140.85 142.121 140.558 139.743C144.975 138.204 149.215 136.139 153.183 133.575C162.73 127.404 170.292 118.608 174.961 108.244C179.63 97.8797 181.207 86.3876 179.502 75.1487C177.798 63.9098 172.884 53.4021 165.352 44.8883C157.82 36.3744 147.99 30.2165 137.042 27.1546C126.095 24.0926 114.496 24.2568 103.64 27.6274C92.7839 30.998 83.1319 37.4317 75.8437 46.1553C74.9102 47.2727 74.0206 48.4216 73.176 49.5993C61.9292 50.8488 51.0363 54.0318 40.9629 58.9556C44.2417 48.4586 49.5653 38.6591 56.679 30.1442C67.0505 17.7298 80.7861 8.57426 96.2354 3.77762C111.685 -1.01901 128.19 -1.25267 143.769 3.10474C159.348 7.46215 173.337 16.2252 184.056 28.3411C194.775 40.457 201.767 55.4101 204.193 71.404C206.619 87.3978 204.374 103.752 197.73 118.501C191.086 133.25 180.324 145.767 166.738 154.548ZM41.9631 74.275L62.5557 76.8042C63.0459 72.813 63.9401 68.9018 65.2138 65.1274C57.0465 67.0016 49.2088 70.087 41.9631 74.275Z" fill="#FFC131"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.4045 76.4519C47.3493 70.6709 57.2677 66.6712 67.6171 64.6132C65.2774 70.9669 64 77.8343 64 85.0001C64 87.1434 64.1143 89.26 64.3371 91.3442C60.0093 92.8732 55.8533 94.9092 51.9599 97.4256C42.4128 103.596 34.8505 112.392 30.1816 122.756C25.5126 133.12 23.9357 144.612 25.6403 155.851C27.3449 167.09 32.2584 177.598 39.7906 186.112C47.3227 194.626 57.153 200.784 68.1003 203.846C79.0476 206.907 90.6462 206.743 101.502 203.373C112.359 200.002 122.011 193.568 129.299 184.845C130.237 183.722 131.131 182.567 131.979 181.383C143.235 180.114 154.132 176.91 164.205 171.962C160.929 182.49 155.596 192.319 148.464 200.856C138.092 213.27 124.357 222.426 108.907 227.222C93.458 232.019 76.9524 232.253 61.3736 227.895C45.7948 223.538 31.8055 214.775 21.0867 202.659C10.3679 190.543 3.37557 175.59 0.949823 159.596C-1.47592 143.602 0.768139 127.248 7.41237 112.499C14.0566 97.7497 24.8183 85.2327 38.4045 76.4519ZM163.062 156.711L163.062 156.711C162.954 156.773 162.846 156.835 162.738 156.897C162.846 156.835 162.954 156.773 163.062 156.711Z" fill="#24C8DB"/>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

1
ui/public/vite.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

7
ui/src-tauri/.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas

35
ui/src-tauri/Cargo.toml Normal file
View file

@ -0,0 +1,35 @@
[package]
name = "panorama"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
[lib]
name = "app_lib"
crate-type = [
"staticlib",
"cdylib",
# "rlib",
"lib",
]
[build-dependencies]
tauri-build = { version = "2.0.0-beta", features = [] }
[dependencies]
clap = { version = "4.5.7", features = ["derive"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri = { version = "2.0.0-beta", features = [] }
tauri-build = { version = "2.0.0-beta.17", features = ["config-toml"] }
tauri-plugin-http = "2.0.0-beta.9"
tauri-plugin-shell = "2.0.0-beta.7"
tauri-plugin-single-instance = "2.0.0-beta.9"
tauri-plugin-window-state = "2.0.0-beta"
tokio = { version = "1.38.0", features = ["full"] }
tracing-subscriber = "0.3.18"
[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]

3
ui/src-tauri/build.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

View file

@ -0,0 +1,31 @@
{
"identifier": "migrated",
"description": "permissions that were migrated from v1",
"local": true,
"windows": ["main"],
"permissions": [
"path:default",
"event:default",
"window:default",
"app:default",
"resources:default",
"menu:default",
"tray:default",
"shell:allow-open",
{
"identifier": "http:default",
"allow": [
{
"url": "http://localhost:5195/*"
},
{
"url": "http://localhost:3000/*"
}
]
},
"app:allow-app-show",
"app:allow-app-hide",
"shell:default",
"http:default"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 965 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

BIN
ui/src-tauri/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
ui/src-tauri/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

30
ui/src-tauri/src/lib.rs Normal file
View file

@ -0,0 +1,30 @@
use tauri::Manager;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[derive(Clone, serde::Serialize)]
struct Payload {
args: Vec<String>,
cwd: String,
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
println!("{}, {argv:?}, {cwd}", app.package_info().name);
app
.emit("single-instance", Payload { args: argv, cwd })
.unwrap();
}))
.plugin(tauri_plugin_window_state::Builder::default().build())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

25
ui/src-tauri/src/main.rs Normal file
View file

@ -0,0 +1,25 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
struct Opt {
#[clap(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand, Debug)]
enum Command {}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let opt = Opt::parse();
match opt.command {
Some(_) => {}
None => {
app_lib::run();
}
}
}

View file

@ -0,0 +1,33 @@
{
"build": {
"beforeDevCommand": "pnpm dev",
"beforeBuildCommand": "pnpm build",
"frontendDist": "../dist",
"devUrl": "http://localhost:1420"
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
},
"identifier": "io.mzhang.panorama",
"plugins": {},
"app": {
"security": {
"csp": null
},
"windows": [
{
"title": "panorama",
"width": 800,
"height": 600
}
]
}
}

33
ui/src/App.module.scss Normal file
View file

@ -0,0 +1,33 @@
.container {
display: flex;
flex-direction: column;
min-height: 0;
width: 100%;
height: 100%;
}
.main {
flex-grow: 1;
display: flex;
}
.nodeContainer {
display: flex;
justify-items: stretch;
padding: 12px;
gap: 12px;
min-width: 0;
flex-grow: 1;
flex-basis: auto;
overflow-x: scroll;
// Cribbed from https://www.magicpattern.design/tools/css-backgrounds
background-color: #e5e5f7;
opacity: 0.8;
background-image: radial-gradient(#444cf7 0.5px, #e5e5f7 0.5px);
background-size: 10px 10px;
}

79
ui/src/App.tsx Normal file
View file

@ -0,0 +1,79 @@
import Header from "./components/Header";
import styles from "./App.module.scss";
import "@fontsource/inter";
import "@fontsource/inter/700.css";
import "./global.scss";
import "katex/dist/katex.min.css";
import { useEffect } from "react";
import NodeDisplay from "./components/NodeDisplay";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import TimeAgo from "javascript-time-ago";
import en from "javascript-time-ago/locale/en";
import Sidebar from "./components/Sidebar";
import { atom, useAtom, useAtomValue } from "jotai";
import { OrderedSet } from "immutable";
import { PANORAMA_DAEMON_URL } from "./lib/constants";
const queryClient = new QueryClient();
TimeAgo.addDefaultLocale(en);
export const nodesOpenedAtom = atom<OrderedSet<string>>(OrderedSet<string>());
function App() {
const nodesOpened = useAtomValue(nodesOpenedAtom);
const { openNode } = useNodeControls();
// Open today's journal entry if it's not already opened
useEffect(() => {
(async () => {
console.log("ndoes", nodesOpened);
if (nodesOpened.size === 0) {
console.log("Opening today's entry.");
const resp = await fetch(
`${PANORAMA_DAEMON_URL}/journal/get_todays_journal_id`,
);
const data = await resp.json();
console.log("resp", data);
openNode(data.node_id);
}
})();
}, [nodesOpened, openNode]);
const nodes = [...nodesOpened.reverse().values()].map((nodeId, idx) => (
<NodeDisplay idx={idx} key={nodeId} id={nodeId} />
));
return (
<QueryClientProvider client={queryClient}>
<div className={styles.container}>
<Header />
<div className={styles.main}>
<Sidebar />
<div className={styles.nodeContainer}>{nodes}</div>
</div>
</div>
</QueryClientProvider>
);
}
export default App;
export function useNodeControls() {
const [nodesOpened, setNodesOpened] = useAtom(nodesOpenedAtom);
return {
isOpen: (node_id: string) => nodesOpened.has(node_id),
toggleNode: (node_id: string) => {
if (nodesOpened.has(node_id)) setNodesOpened(nodesOpened.remove(node_id));
else setNodesOpened(nodesOpened.remove(node_id).add(node_id));
},
openNode: (node_id: string) => {
setNodesOpened(nodesOpened.remove(node_id).add(node_id));
},
closeNode: (node_id: string) => {
setNodesOpened(nodesOpened.remove(node_id));
},
};
}

1
ui/src/assets/react.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -0,0 +1,60 @@
.Header {
display: flex;
align-items: center;
padding: 2px 12px;
gap: 12px;
background: rgb(204, 201, 255);
background: linear-gradient(90deg, rgba(204, 201, 255, 1) 0%, rgba(255, 255, 255, 1) 100%);
}
.headerBorder {
height: 1px;
background: rgb(170, 166, 255);
background: linear-gradient(90deg, rgba(170, 166, 255, 1) 0%, rgba(255, 255, 255, 1) 100%);
}
.brand {
display: flex;
flex-direction: column;
text-align: right;
.title {
font-size: 1.2em;
margin: 0;
}
.version {
font-size: .6em;
color: rgb(0, 0, 0, 0.5);
margin: 0;
}
}
.newNodeMenu {
background-color: rgba(255, 255, 255, 0.5);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(10px);
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.25);
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
ul {
display: flex;
flex-direction: column;
padding: 0;
list-style-type: none;
li {
display: flex;
flex-direction: column;
align-items: stretch;
button {
cursor: pointer;
display: flex;
}
}
}
}

View file

@ -0,0 +1,134 @@
import styles from "./Header.module.scss";
import NoteAddIcon from "@mui/icons-material/NoteAdd";
import SearchBar from "./SearchBar";
import ListIcon from "@mui/icons-material/List";
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
import { useSetAtom } from "jotai";
import { sidebarExpandedAtom } from "./Sidebar";
import { useNodeControls } from "../App";
import { useCallback, useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { getVersion } from "@tauri-apps/api/app";
import {
FloatingOverlay,
FloatingPortal,
autoUpdate,
useDismiss,
useFloating,
useFocus,
useInteractions,
} from "@floating-ui/react";
import { PANORAMA_DAEMON_URL } from "../lib/constants";
export default function Header() {
const { openNode } = useNodeControls();
const setSidebarExpanded = useSetAtom(sidebarExpandedAtom);
const versionData = useQuery({
queryKey: ["appVersion"],
queryFn: getVersion,
});
const { data: version } = versionData;
console.log("version", version);
const createNewJournalPage = useCallback(() => {
(async () => {
const resp = await fetch(`${PANORAMA_DAEMON_URL}/node`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "panorama/journal/page",
extra_data: {
"panorama/journal/page/content": "",
},
}),
});
const data = await resp.json();
openNode(data.node_id);
})();
}, [openNode]);
return (
<>
<div className={styles.Header}>
<button
type="button"
onClick={() => setSidebarExpanded((prev) => !prev)}
>
<ListIcon fontSize="inherit" />
</button>
<SearchBar />
<div>
<button type="button" onClick={createNewJournalPage}>
<NoteAddIcon fontSize="inherit" />
</button>
<NewNodeButton />
</div>
<div className="spacer" />
<div className={styles.brand}>
<span className={styles.title}>Panorama</span>
<span className={styles.version}>v{version}</span>
</div>
</div>
<div className={styles.headerBorder} />
</>
);
}
function NewNodeButton() {
const [showMenu, setShowMenu] = useState(false);
const { refs, context, floatingStyles } = useFloating({
placement: "bottom-start",
open: showMenu,
onOpenChange: setShowMenu,
whileElementsMounted: autoUpdate,
// middleware: [offset(10)],
});
const focus = useFocus(context);
const { getReferenceProps, getFloatingProps } = useInteractions([
focus,
useDismiss(context),
]);
return (
<>
<button
type="button"
onClick={() => setShowMenu((p) => !p)}
ref={refs.setReference}
>
<ArrowDropDownIcon fontSize="inherit" />
</button>
{showMenu && (
<FloatingPortal>
<FloatingOverlay>
<div
ref={refs.setFloating}
style={{ ...floatingStyles }}
{...getFloatingProps()}
>
<NewNodeMenu />
</div>
</FloatingOverlay>
</FloatingPortal>
)}
</>
);
}
function NewNodeMenu() {
return (
<div className={styles.newNodeMenu}>
<ul>
<li>
<button type="button">Journal Page</button>
</li>
<li>
<button type="button">Media resource</button>
</li>
</ul>
</div>
);
}

View file

@ -0,0 +1,74 @@
.container {
flex-shrink: 0;
width: 500px;
overflow-wrap: break-word;
overflow-y: auto;
border: 1px solid lightgray;
border-radius: 4px;
display: flex;
align-items: stretch;
flex-direction: column;
resize: horizontal;
background-color: rgba(255, 255, 255, 0.5);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.header {
color: rgb(106, 103, 160);
background: rgb(204, 201, 255);
background: linear-gradient(90deg, rgba(204, 201, 255, 1) 0%, rgba(255, 255, 255, 1) 100%);
font-size: 0.6rem;
display: flex;
align-items: stretch;
padding: 0 6px;
button {
background-color: transparent;
border: none;
display: flex;
justify-content: center;
cursor: pointer;
align-items: center;
&:hover {
background-color: rgba(0, 0, 0, 0.25);
}
&.closeButton:hover {
background-color: red;
color: white;
}
}
span {
padding: 6px;
}
}
.footer {
padding: 2px 12px;
font-size: 0.6rem;
align-self: flex-start;
// For the resize handle
// TODO: Make the entire right side resize and then remove this
width: calc(100% - 20px);
// border: 1px solid red;
// box-sizing: border-box;
}
.body {
flex-grow: 1;
// padding: 12px;
display: flex;
flex-direction: column;
}

View file

@ -0,0 +1,89 @@
import { useQuery } from "@tanstack/react-query";
import styles from "./NodeDisplay.module.scss";
import ReactTimeAgo from "react-time-ago";
import { getNode } from "../lib/getNode";
import FirstPageIcon from "@mui/icons-material/FirstPage";
import MoreVertIcon from "@mui/icons-material/MoreVert";
import CloseIcon from "@mui/icons-material/Close";
import { useNodeControls } from "../App";
export interface NodeDisplayProps {
id: string;
idx?: number | undefined;
}
export default function NodeDisplay({ id, idx }: NodeDisplayProps) {
const query = useQuery({
queryKey: ["fetchNode", id],
queryFn: getNode,
});
const { isSuccess, status, data: nodeDescriptor } = query;
let Component = undefined;
let data = undefined;
if (isSuccess) {
Component = nodeDescriptor.render;
data = nodeDescriptor.data;
}
return (
<div className={styles.container}>
<div className={styles.header}>
{isSuccess ? (
<NodeDisplayHeaderLoaded idx={idx} id={id} data={data} />
) : (
<>
ID {id} ({status})
</>
)}
</div>
<div className={styles.body}>
{Component && <Component id={id} data={data} />}
</div>
<div className={styles.footer}>{id}</div>
</div>
);
}
function NodeDisplayHeaderLoaded({ idx, id, data }) {
const { openNode, closeNode } = useNodeControls();
const updatedAt = data.updated_at && Date.parse(data.updated_at);
return (
<>
{idx === 0 || (
<button
type="button"
onClick={() => openNode(id)}
title="Move node to the left"
>
<FirstPageIcon fontSize="inherit" />
</button>
)}
<span>
Type {data.type}{" "}
{updatedAt && (
<>
&middot; Last updated <ReactTimeAgo date={updatedAt} />
</>
)}
</span>
<div className="spacer" />
<button type="button">
<MoreVertIcon fontSize="inherit" />
</button>
<button
type="button"
className={styles.closeButton}
onClick={() => closeNode(id)}
>
<CloseIcon fontSize="inherit" />
</button>
</>
);
}

View file

@ -0,0 +1,54 @@
.menu {
background-color: rgba(255, 255, 255, 0.5);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(10px);
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.25);
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
width: 500px;
min-height: 200px;
padding: 6px;
text-wrap: wrap;
white-space: pre-wrap;
word-wrap: break-word;
overflow-wrap: break-word;
}
.entry {
padding: 2px 6px;
font-size: 14pt;
border-radius: 4px;
border: none;
outline: none;
}
.searchResults {
display: flex;
flex-direction: column;
align-items: stretch;
}
.searchResult {
padding: 12px;
cursor: pointer;
border-radius: 4px;
text-align: left;
background-color: unset;
border: none;
&:hover {
background-color: rgba(0, 0, 0, 0.05);
}
.title {
font-size: 1rem;
}
.subtitle {
font-size: .75rem;
color: rgba(0, 0, 0, 0.8);
}
}

View file

@ -0,0 +1,116 @@
import styles from "./SearchBar.module.scss";
import {
FloatingOverlay,
FloatingPortal,
autoUpdate,
offset,
useDismiss,
useFloating,
useFocus,
useInteractions,
} from "@floating-ui/react";
import { useCallback, useEffect, useState } from "react";
import { atom, useAtom, useSetAtom } from "jotai";
import { useNodeControls } from "../App";
import { useDebounce, useDebouncedCallback } from "use-debounce";
const searchQueryAtom = atom("");
const showMenuAtom = atom(false);
export default function SearchBar() {
const [showMenu, setShowMenu] = useAtom(showMenuAtom);
const [searchQuery, setSearchQuery] = useAtom(searchQueryAtom);
const [searchResults, setSearchResults] = useState([]);
const { refs, context, floatingStyles } = useFloating({
placement: "bottom-start",
open: showMenu,
onOpenChange: setShowMenu,
whileElementsMounted: autoUpdate,
middleware: [offset(10)],
});
const focus = useFocus(context);
const { getReferenceProps, getFloatingProps } = useInteractions([
focus,
useDismiss(context),
]);
const performSearch = useCallback(() => {
const trimmed = searchQuery.trim();
if (trimmed === "") return;
(async () => {
const params = new URLSearchParams();
params.set("query", trimmed);
const resp = await fetch(
`http://localhost:5195/node/search?${params.toString()}`,
);
const data = await resp.json();
setSearchResults(data.results);
})();
}, [searchQuery]);
return (
<>
<div>
<input
className={styles.entry}
type="text"
placeholder="Search..."
onFocus={() => setShowMenu(true)}
ref={refs.setReference}
value={searchQuery}
onChange={(evt) => {
setSearchQuery(evt.target.value);
if (evt.target.value) performSearch();
else setSearchResults([]);
}}
{...getReferenceProps()}
/>
</div>
{showMenu && (
<FloatingPortal>
<FloatingOverlay>
<div
ref={refs.setFloating}
className={styles.menu}
style={{ ...floatingStyles }}
{...getFloatingProps()}
>
<SearchMenu results={searchResults} />
</div>
</FloatingOverlay>
</FloatingPortal>
)}
</>
);
}
function SearchMenu({ results }) {
const setSearchQuery = useSetAtom(searchQueryAtom);
const setShowMenu = useSetAtom(showMenuAtom);
const { openNode } = useNodeControls();
return (
<div className={styles.searchResults}>
{results.map((result) => {
return (
<button
type="button"
key={result.node_id}
className={styles.searchResult}
onClick={() => {
setSearchQuery("");
setShowMenu(false);
openNode(result.node_id);
}}
>
{/* <div className={styles.title}>{result.title}</div> */}
<div className={styles.subtitle}>{JSON.stringify(result)}</div>
</button>
);
})}
</div>
);
}

View file

@ -0,0 +1,39 @@
.sidebar {
display: flex;
flex-direction: column;
gap: 6px;
background-color: rgba(204, 201, 255);
padding: 12px 6px;
&.expanded {
padding: 12px;
}
.item {
display: flex;
align-items: center;
padding: 6px;
font-size: 0.95em;
border-radius: 4px;
border: none;
background-color: unset;
&:hover {
background-color: rgba(255, 255, 255, 0.2);
cursor: pointer;
}
&.active {
background-color: rgba(255, 255, 255, 0.75);
}
}
&.expanded .item {
gap: 6px;
}
&.collapsed .item .label {
display: none;
}
}

View file

@ -0,0 +1,41 @@
import { atom, useAtomValue } from "jotai";
import styles from "./Sidebar.module.scss";
import classNames from "classnames";
import EmailIcon from "@mui/icons-material/Email";
import SettingsIcon from "@mui/icons-material/Settings";
import { useNodeControls } from "../App";
export const sidebarExpandedAtom = atom(false);
export default function Sidebar() {
const sidebarExpanded = useAtomValue(sidebarExpandedAtom);
const { toggleNode, isOpen } = useNodeControls();
return (
<div
className={classNames(
styles.sidebar,
sidebarExpanded ? styles.expanded : styles.collapsed,
)}
>
<button
type="button"
className={classNames(
styles.item,
isOpen("panorama/mail") && styles.active,
)}
onClick={() => toggleNode("panorama/mail")}
>
<EmailIcon />
<span className={styles.label}>Email</span>
</button>
<div className="spacer" />
<div className={styles.item}>
<SettingsIcon />
<span className={styles.label}>Settings</span>
</div>
</div>
);
}

View file

@ -0,0 +1,61 @@
.container {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.titleContainer,
.titleEditorForm {
display: flex;
}
.title,
.titleEditor {
flex-grow: 1;
padding: 12px;
border: none;
border-bottom: 1px solid lightgray;
outline: none;
font-size: 1.2em;
}
.untitled {
color: gray;
}
.mdContent {
flex-grow: 1;
display: flex;
flex-direction: column;
}
.mdEditor {
flex-grow: 1;
border-radius: 0;
}
.dayIndicator {
background-color: lavender;
padding: 2px 12px;
font-size: 0.8em;
}
.block {
padding: 12px;
&:not(.isEditing) {
user-select: none;
-webkit-user-select: none;
}
&.isEditing {
background-color: rgb(235, 243, 246);
outline: 2px solid skyblue;
}
&:hover {
background-color: rgb(235, 243, 246);
cursor: text;
}
}

View file

@ -0,0 +1,132 @@
import { useCallback, useEffect, useRef, useState } from "react";
import MDEditor, { PreviewType } from "@uiw/react-md-editor";
import { usePrevious } from "@uidotdev/usehooks";
import { useQueryClient } from "@tanstack/react-query";
import styles from "./JournalPage.module.scss";
import remarkMath from "remark-math";
import rehypeKatex from "rehype-katex";
import { parse as parseDate, format as formatDate } from "date-fns";
import { useDebounce } from "use-debounce";
import {
JOURNAL_PAGE_CONTENT_FIELD_NAME,
JOURNAL_PAGE_TITLE_FIELD_NAME,
NodeInfo,
} from "../../lib/data";
export interface JournalPageProps {
id: string;
data: NodeInfo;
}
export default function JournalPage({ id, data }: JournalPageProps) {
const { day } = data;
const queryClient = useQueryClient();
const [value, setValue] = useState(
() => data?.fields?.[JOURNAL_PAGE_CONTENT_FIELD_NAME],
);
const [valueToSave] = useDebounce(value, 1000, {
leading: true,
trailing: true,
});
const previous = usePrevious(valueToSave);
const changed = valueToSave !== previous;
const [mode, setMode] = useState<PreviewType>("preview");
const [title, setTitle] = useState(
() => data?.fields?.[JOURNAL_PAGE_TITLE_FIELD_NAME],
);
const [isEditingTitle, setIsEditingTitle] = useState(false);
const saveData = useCallback(async () => {
const extra_data = {
[JOURNAL_PAGE_TITLE_FIELD_NAME]: title,
[JOURNAL_PAGE_CONTENT_FIELD_NAME]: valueToSave,
};
console.log("extra Data", extra_data);
const resp = await fetch(`http://localhost:5195/node/${id}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ extra_data }),
});
const data = await resp.text();
console.log("result", data);
}, [title, valueToSave, id]);
useEffect(() => {
if (changed) {
(async () => {
await saveData();
queryClient.invalidateQueries({ queryKey: ["fetchNode", id] });
})();
}
}, [changed, queryClient, saveData]);
const saveChangedTitle = useCallback(() => {
(async () => {
await saveData();
setIsEditingTitle(false);
})();
}, [saveData]);
return (
<>
{isEditingTitle ? (
<form
className={styles.titleEditorForm}
onSubmit={(evt) => {
evt.preventDefault();
saveChangedTitle();
}}
>
<input
className={styles.titleEditor}
type="text"
value={title}
onChange={(evt) => {
let newTitle = evt.target.value;
if (newTitle.trim().length === 0) newTitle = null;
setTitle(newTitle);
}}
onBlur={() => saveChangedTitle()}
// biome-ignore lint/a11y/noAutofocus: <explanation>
autoFocus
/>
</form>
) : (
<div className={styles.titleContainer}>
<div
className={styles.title}
onDoubleClick={() => setIsEditingTitle(true)}
>
{title ?? <span className={styles.untitled}>(untitled)</span>}
</div>
</div>
)}
<div data-color-mode="light" className={styles.container}>
{day && <DayIndicator day={day} />}
<MDEditor
value={value}
className={styles.mdEditor}
onChange={(newValue) => newValue !== undefined && setValue(newValue)}
preview={mode}
visibleDragbar={false}
onDoubleClick={() => setMode("live")}
previewOptions={{
remarkPlugins: [remarkMath],
rehypePlugins: [rehypeKatex],
}}
/>
</div>
</>
);
}
function DayIndicator({ day }) {
const parsedDate = parseDate(day, "yyyy-MM-dd", new Date());
const formattedDate = formatDate(parsedDate, "PPPP");
return (
<div className={styles.dayIndicator}>
Journal entry for <b>{formattedDate}</b>
</div>
);
}

View file

@ -0,0 +1,25 @@
.container {
display: flex;
flex-direction: column;
}
.header {
display: flex;
align-items: center;
padding: 2px 12px;
.title {
font-size: 1rem;
}
}
.settings {
h2 {
margin: 0;
}
}
.mailList {
flex-grow: 1;
border-top: 1px solid lightgray;
}

View file

@ -0,0 +1,168 @@
import { useCallback, useState } from "react";
import styles from "./Mail.module.scss";
import { Formik } from "formik";
import SettingsIcon from "@mui/icons-material/Settings";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import ReactTimeAgo from "react-time-ago";
import { parseISO } from "date-fns";
export default function Mail() {
const [showSettings, setShowSettings] = useState(false);
const fetchedMail = useQuery({
queryKey: ["mail"],
queryFn: fetchMail,
staleTime: 10000,
});
const { isSuccess, data } = fetchedMail;
return (
<div className={styles.container}>
<div className={styles.header}>
<div className={styles.title}>
{showSettings ? <>Settings</> : <>Mail</>}
</div>
<div className="spacer" />
<button type="button" onClick={() => setShowSettings((prev) => !prev)}>
<SettingsIcon />
</button>
</div>
{showSettings && (
<div className={styles.settings}>
<MailConfig />
</div>
)}
<div className={styles.mailList}>
{isSuccess && (
<ul>
{data.messages.map((message) => {
const date = parseISO(message.internal_date);
return (
<li key={message.node_id}>
<details>
<summary>
{message.subject} (<ReactTimeAgo date={date} />)
</summary>
<small>{message.body}</small>
</details>
</li>
);
})}
</ul>
)}
</div>
</div>
);
}
function MailConfig() {
const queryClient = useQueryClient();
const config = useQuery({
queryKey: ["mailConfigs"],
queryFn: fetchMailConfig,
});
const { isSuccess, data } = config;
return (
<>
<div>
Add a new config
<Formik
onSubmit={(values) => {
(async () => {
const resp = await fetch("http://localhost:5195/node", {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "panorama/mail/config",
extra_data: {
"panorama/mail/config/imap_hostname": values.imapHostname,
"panorama/mail/config/imap_port": values.imapPort,
"panorama/mail/config/imap_username": values.imapUsername,
"panorama/mail/config/imap_password": values.imapPassword,
},
}),
});
const data = await resp.json();
console.log("result", data);
queryClient.invalidateQueries({ queryKey: ["mailConfigs"] });
})();
}}
initialValues={{
imapHostname: "",
imapPort: 993,
imapUsername: "",
imapPassword: "",
}}
>
{({ values, handleSubmit, handleChange, handleBlur }) => (
<form onSubmit={handleSubmit}>
<input
type="text"
name="imapHostname"
placeholder="IMAP Hostname"
onChange={handleChange}
onBlur={handleBlur}
value={values.imapHostname}
/>
<input
type="number"
name="imapPort"
placeholder="IMAP Port"
onChange={handleChange}
onBlur={handleBlur}
value={values.imapPort}
/>
<br />
<input
type="text"
name="imapUsername"
placeholder="IMAP Username"
onChange={handleChange}
onBlur={handleBlur}
value={values.imapUsername}
/>
<input
type="password"
name="imapPassword"
placeholder="IMAP Password"
onChange={handleChange}
onBlur={handleBlur}
value={values.imapPassword}
/>
<button type="submit">Add</button>
</form>
)}
</Formik>
</div>
<div>
{isSuccess && (
<ul>
{data.map((config) => (
<li>{JSON.stringify(config)}</li>
))}
</ul>
)}
</div>
</>
);
}
async function fetchMailConfig() {
const resp = await fetch("http://localhost:5195/mail/config");
const data = await resp.json();
return data.configs;
}
async function fetchMail() {
const resp = await fetch("http://localhost:5195/mail");
const data = await resp.json();
return data;
}

23
ui/src/global.scss Normal file
View file

@ -0,0 +1,23 @@
body,
html {
padding: 0;
margin: 0;
overscroll-behavior: none;
font-family: "Inter";
}
body,
html,
#root {
width: 100%;
height: 100%;
}
.spacer {
flex-grow: 1;
}
* {
box-sizing: border-box;
}

1
ui/src/lib/constants.ts Normal file
View file

@ -0,0 +1 @@
export const PANORAMA_DAEMON_URL = "http://localhost:3000";

11
ui/src/lib/data.ts Normal file
View file

@ -0,0 +1,11 @@
export interface NodeInfo {
fields: Partial<NodeFields>;
}
export const JOURNAL_PAGE_CONTENT_FIELD_NAME = "panorama/journal/page/content";
export const JOURNAL_PAGE_TITLE_FIELD_NAME = "panorama/journal/page/title";
export interface NodeFields {
[JOURNAL_PAGE_CONTENT_FIELD_NAME]: string;
[JOURNAL_PAGE_TITLE_FIELD_NAME]: string;
}

35
ui/src/lib/getNode.ts Normal file
View file

@ -0,0 +1,35 @@
import { Component, type FC } from "react";
import JournalPage from "../components/nodes/JournalPage";
import Mail from "../components/nodes/Mail";
import type { QueryFunctionContext } from "@tanstack/react-query";
import { PANORAMA_DAEMON_URL } from "./constants";
export interface RenderProps<D> {
id: string;
data: D;
}
export interface NodeDescriptor<D> {
render: FC<RenderProps<D>>;
data: {
type: string;
} & D;
}
export async function getNode({
queryKey,
}: QueryFunctionContext): Promise<NodeDescriptor<unknown>> {
const [, node_id] = queryKey;
switch (node_id) {
case "panorama/mail":
return { data: { type: "panorama/mail" }, render: Mail };
default: {
const resp = await fetch(`${PANORAMA_DAEMON_URL}/node/${node_id}`);
const data = await resp.json();
return {
data: { ...data, type: "panorama/journal/page" },
render: JournalPage,
};
}
}
}

9
ui/src/main.tsx Normal file
View file

@ -0,0 +1,9 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);

1
ui/src/vite-env.d.ts vendored Normal file
View file

@ -0,0 +1 @@
/// <reference types="vite/client" />

25
ui/tsconfig.json Normal file
View file

@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}

10
ui/tsconfig.node.json Normal file
View file

@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

28
ui/vite.config.ts Normal file
View file

@ -0,0 +1,28 @@
import { defineConfig, type PluginOption } from "vite";
import react from "@vitejs/plugin-react";
import { visualizer } from "rollup-plugin-visualizer";
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [
react(),
visualizer({
emitFile: true,
filename: "stats.html",
}) as PluginOption,
],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
}));