Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organize source files into subdirs #58

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/main.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from "vitest";

import Scene from "../src/scene";
import Scene from "@/components/scene";
import React from "react";
import { render } from "@testing-library/react";

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="module" src="/src/components/main.tsx"></script>
</body>
</html>
1 change: 0 additions & 1 deletion src/assets/preact.svg

This file was deleted.

4 changes: 2 additions & 2 deletions src/app.tsx → src/components/app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import "./app.css";
import Scene from "./scene.tsx";
import "@/css/app.css";
import Scene from "@/components/scene.tsx";

const aspectRatio = 4 / 3;

Expand Down
4 changes: 2 additions & 2 deletions src/main.tsx → src/components/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
import { defaultTheme } from "@czi-sds/components";

import App from "./app.tsx";
import "./index.css";
import App from "@/components/app.tsx";
import "@/css/index.css";

const domNode = document.getElementById("app")!;
const root = createRoot(domNode);
Expand Down
10 changes: 5 additions & 5 deletions src/scene.tsx → src/components/scene.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useRef, useState } from "react";
import { Button, InputSlider, InputText, InputToggle, LoadingIndicator } from "@czi-sds/components";
import { PointCanvas } from "./PointCanvas";
import { TrackManager, loadTrackManager } from "./TrackManager";

import useSelectionBox from "./hooks/useSelectionBox";
import { PointCanvas } from "@/lib/PointCanvas";
import { TrackManager, loadTrackManager } from "@/lib/TrackManager";
import { ViewerState, clearUrlHash } from "@/lib/ViewerState";

import { ViewerState, clearUrlHash } from "./ViewerState";
import useSelectionBox from "@/hooks/useSelectionBox";

interface SceneProps {
renderWidth?: number;
Expand Down Expand Up @@ -113,7 +113,7 @@ export default function Scene(props: SceneProps) {
canvas.current?.highlightPoints(selected);

const maxPointsPerTimepoint = trackManager?.maxPointsPerTimepoint || 0;
Promise.all(selected.map((p) => curTime * maxPointsPerTimepoint + p).map(fetchAndAddTrack));
Promise.all(selected.map((p: number) => curTime * maxPointsPerTimepoint + p).map(fetchAndAddTrack));
// TODO: cancel the fetch if the selection changes?
}, [selectedPoints]);

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/hooks/useSelectionBox.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SelectionHelper } from "three/addons/interactive/SelectionHelper.js";
import { useEffect, useRef, useState } from "react";

import { PointSelectionBox, PointsCollection } from "../PointSelectionBox";
import { PointCanvas } from "../PointCanvas";
import { PointSelectionBox, PointsCollection } from "@/lib/PointSelectionBox";
import { PointCanvas } from "@/lib/PointCanvas";

export default function useSelectionBox(canvas: PointCanvas | undefined) {
const [selecting, setSelecting] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion src/PointCanvas.ts → src/lib/PointCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { RenderPass } from "three/addons/postprocessing/RenderPass.js";
import { OutputPass } from "three/addons/postprocessing/OutputPass.js";
import { UnrealBloomPass } from "three/addons/postprocessing/UnrealBloomPass.js";

import { Track } from "./lib/three/Track";
import { Track } from "@/lib/three/Track";

type Tracks = Map<number, Track>;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,

/* Paths */
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import react from "@vitejs/plugin-react";

export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": "/src",
},
},
test: {
environment: "jsdom",
browser: {
Expand Down
Loading