From e595cc1135a177bc49d12c669730ead34b85cac4 Mon Sep 17 00:00:00 2001 From: Orion Reed Date: Mon, 25 Mar 2024 01:13:53 -0700 Subject: [PATCH] some fixes --- package.json | 6 +- src/App.tsx | 81 ++++----------- src/css/style.css | 8 ++ .../causal-islands-integration-domain.pdf | 0 src/ts/components/Contact.tsx | 13 ++- src/ts/components/Default.tsx | 10 +- src/ts/components/Toggle.tsx | 2 - src/ts/hooks/usePhysics.ts | 99 +++++++++++++++++++ src/ts/shapes/HTMLShapeUtil.tsx | 2 +- src/utils.tsx | 88 ++++++----------- 10 files changed, 173 insertions(+), 136 deletions(-) rename src/{artifacts => public/artifact}/causal-islands-integration-domain.pdf (100%) create mode 100644 src/ts/hooks/usePhysics.ts diff --git a/package.json b/package.json index 6852859..1c92dce 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "@dimforge/rapier2d": "latest", "@tldraw/tldraw": "2.0.2", "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "react-router-dom": "^6.22.3" }, "devDependencies": { "@biomejs/biome": "1.4.1", @@ -23,10 +24,9 @@ "@types/react": "^18.2.15", "@types/react-dom": "^18.2.7", "@vitejs/plugin-react": "^4.0.3", - "concurrently": "^8.2.0", "typescript": "^5.0.2", "vite": "^4.4.5", "vite-plugin-top-level-await": "^1.3.1", "vite-plugin-wasm": "^3.2.2" } -} \ No newline at end of file +} diff --git a/src/App.tsx b/src/App.tsx index f7d0bae..f7e80a4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,76 +7,35 @@ import { HTMLShape } from "./ts/shapes/HTMLShapeUtil"; import { Default } from "./ts/components/Default"; import { Canvas } from "./ts/components/Canvas"; import { Toggle } from "./ts/components/Toggle"; -import { gatherElementsInfo } from "./utils"; +import { usePhysics } from "./ts/hooks/usePhysics.ts" +import { createShapes } from "./utils"; +import { BrowserRouter, Route, Routes } from 'react-router-dom'; +import { Contact } from "./ts/components/Contact.tsx"; ReactDOM.createRoot(document.getElementById("root")!).render(); function App() { - const [isPhysicsEnabled, setIsPhysicsEnabled] = useState(false); - const [elementsInfo, setElementsInfo] = useState([]); - const [fadeClass, setFadeClass] = useState(''); // State to control the fade class - useEffect(() => { - const togglePhysics = async () => { - if (!isPhysicsEnabled) { - const info = await gatherElementsInfo(); - setElementsInfo(info); - setIsPhysicsEnabled(true); // Enable physics only after gathering info - setFadeClass('fade-out'); // Start fading out the Default component - // setTimeout(() => setFadeClass('fade-in'), 500); // Wait for fade-out to complete before fading in Canvas - } else { - setIsPhysicsEnabled(false); - setElementsInfo([]); // Reset elements info when disabling physics - setFadeClass(''); // Reset fade class to show Default component normally - } - }; - - window.addEventListener('togglePhysicsEvent', togglePhysics); - - return () => { - window.removeEventListener('togglePhysicsEvent', togglePhysics); - }; - }, [isPhysicsEnabled]); - - - - const shapes: HTMLShape[] = elementsInfo.map((element) => ({ - id: createShapeId(), - type: 'html', - x: element.x, - y: element.y, - props: { - w: element.w, - h: element.h, - html: element.html, - } - })) - - shapes.push({ - id: createShapeId(), - type: 'geo', - x: 0, - y: window.innerHeight, - props: { - w: window.innerWidth, - h: 50, - color: 'grey', - fill: 'solid' - }, - meta: { - fixed: true - } - }) return ( - -
- {} -
- {isPhysicsEnabled && elementsInfo.length > 0 ? : null} + + + } /> + } /> + +
); }; - +function Home() { + const { isPhysicsEnabled, elementsInfo, fadeClass } = usePhysics(); + const shapes = createShapes(elementsInfo) + return ( + <> +
+ {} +
+ {isPhysicsEnabled && elementsInfo.length > 0 ? : null}) +} \ No newline at end of file diff --git a/src/css/style.css b/src/css/style.css index 8bf3b75..c2f7b2a 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -64,6 +64,14 @@ p { font-size: 1.1em; font-variation-settings: "wght" 350; } + +a { + text-decoration: none; + &:hover { + text-decoration: underline; + } +} + .dinkus { display: block; text-align: center; diff --git a/src/artifacts/causal-islands-integration-domain.pdf b/src/public/artifact/causal-islands-integration-domain.pdf similarity index 100% rename from src/artifacts/causal-islands-integration-domain.pdf rename to src/public/artifact/causal-islands-integration-domain.pdf diff --git a/src/ts/components/Contact.tsx b/src/ts/components/Contact.tsx index 5838f93..f592cd2 100644 --- a/src/ts/components/Contact.tsx +++ b/src/ts/components/Contact.tsx @@ -1,14 +1,17 @@ -import React from "react"; - -function Contact() { +export function Contact() { return ( -
+
+
+ + Orion Reed + +

Contact

Twitter: @OrionReedOne

Mastodon: orion@hci.social

Email: me@orionreed.com

GitHub: OrionReed

-
+ ); } diff --git a/src/ts/components/Default.tsx b/src/ts/components/Default.tsx index f0f16c2..3fe1071 100644 --- a/src/ts/components/Default.tsx +++ b/src/ts/components/Default.tsx @@ -1,5 +1,3 @@ -import React from "react"; - export function Default() { return (
@@ -24,9 +22,9 @@ export function Default() {

My work

- Alongside my independent work I am a researcher at Block Science building - knowledge organisation infrastructure and at ECSA working on - computational media. I am also part of the nascent Liberatory Computing + Alongside my independent work I am a researcher at Block Science building{' '} + knowledge organisation infrastructure and at ECSA working on{' '} + computational media. I am also part of the nascent Liberatory Computing{' '} collective and a co-organiser of the OCWG.

@@ -42,7 +40,7 @@ export function Default() {

Talks