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

Json editor #86

Merged
merged 6 commits into from
Jan 15, 2025
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
103 changes: 102 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"dependencies": {
"@ant-design/icons": "^5.3.0",
"@monaco-editor/react": "^4.6.0",
"@types/d3": "^7.4.3",
"@types/html2canvas": "^0.5.35",
"@types/lz-string": "^1.5.0",
Expand All @@ -40,7 +41,9 @@
"react-dom": "^18.2.0",
"react-icons": "^5.3.0",
"react-router-dom": "^7.0.1",
"tone": "^15.0.4"
"tone": "^15.0.4",
"zod": "^3.24.1",
"zod-validation-error": "^3.4.0"
},
"devDependencies": {
"@chromatic-com/storybook": "^3.2.2",
Expand Down
14 changes: 14 additions & 0 deletions src/components/GravitySimulator/GravitySimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import { useSimulatorState } from "../../hooks/useSimulatorState";
import { useParticleSystem } from "../../hooks/useParticleSystem";
import { useScreenshot } from "../../hooks/useScreenshot";
import { JsonScenarioPanel } from "../JsonScenarioPanel/JsonScenarioPanel";

export interface GravitySimulatorProps {
gravityRef: React.RefObject<HTMLDivElement>;
Expand Down Expand Up @@ -315,6 +316,12 @@
saveScenario,
});

const [isJsonPanelOpen, setIsJsonPanelOpen] = useState(false);

const handleJsonPanelToggle = useCallback(() => {
setIsJsonPanelOpen((prev) => !prev);
}, []);

// Audio files definition
const audioFiles = useMemo(
() => [
Expand Down Expand Up @@ -484,14 +491,14 @@

onApiReady(api);
},
[

Check warning on line 494 in src/components/GravitySimulator/GravitySimulator.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has missing dependencies: 'createParticle', 'gravityPoints', 'gravityRef', 'handleFullscreenToggle', 'handleSelectScenario', 'isFullscreen', 'isPaused', 'onApiReady', 'particles', 'paths', 'physicsConfig', 'setGravityPoints', 'setIsColorInverted', 'setIsFullscreen', 'setIsPaused', 'setIsSimulationStarted', 'setParticles', 'updateSettings', and 'wrappedHandlePointDelete'. Either include them or remove the dependency array. If 'onApiReady' changes too often, find the parent component that defines it and wrap that definition in useCallback
// do not ever relace this with actual dependencies or ill ask you to write this line a 1000 times
]
);

useEffect(() => {
particlesRef.current = particles;
}, [particles]);

Check warning on line 501 in src/components/GravitySimulator/GravitySimulator.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has a missing dependency: 'particlesRef'. Either include it or remove the dependency array

const onSelectScenario = useCallback(
(scenario: Scenario) => {
Expand Down Expand Up @@ -546,6 +553,7 @@
onScreenshot={handleScreenshot}
onScenarioPanel={handleScenarioPanelToggle}
onSettingsPanel={handleSettingsPanelToggle}
onJsonPanel={handleJsonPanelToggle}
isPaused={isPaused}
isFullscreen={isFullscreen}
isAudioPlaying={isAudioPlaying}
Expand Down Expand Up @@ -599,6 +607,12 @@
onSelectScenario={onSelectScenario}
/>

<JsonScenarioPanel
isOpen={isJsonPanelOpen}
onClose={() => setIsJsonPanelOpen(false)}
onApplyScenario={handleSelectScenario}
/>

<SaveScenarioModal
isOpen={isSaveModalOpen}
onClose={() => setIsSaveModalOpen(false)}
Expand Down
Loading
Loading