Skip to content

Commit 8f4c570

Browse files
authored
Merge pull request #447 from sugarlabs/gsoc-dmp-2025/week-6/justin
GSoC/DMP Week 6: feat(masonry): add drag and drop, collision detection, and reverse mapping
2 parents 8fb5394 + a9d5397 commit 8f4c570

35 files changed

+1988
-891
lines changed

modules/masonry/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"playground": "vite playground --host --port 5601"
1414
},
1515
"dependencies": {
16+
"@react-aria/dnd": "^3.10.1",
17+
"@react-stately/dnd": "^3.6.0",
18+
"recoil": "^0.7.7",
1619
"uuid": "^10.0.0"
1720
},
1821
"devDependencies": {

modules/masonry/playground/App.tsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React, { useState } from 'react';
2+
import WorkspaceApp from './pages/Workspace/index';
3+
import CollisionDetection from '../src/collision-detection/CollisionDetection';
4+
5+
export default function App() {
6+
const [tab, setTab] = useState<'workspace' | 'collision' | 'collision-detection'>('workspace');
7+
8+
return (
9+
<div style={{ height: '100vh', width: '100vw', display: 'flex', flexDirection: 'column' }}>
10+
{/* Top-right tab bar */}
11+
<div
12+
style={{
13+
position: 'fixed',
14+
top: 0,
15+
right: 0,
16+
zIndex: 1000,
17+
display: 'flex',
18+
background: '#f8f9fa',
19+
borderBottom: '1px solid #ddd',
20+
borderLeft: '1px solid #ddd',
21+
borderRadius: '0 0 0 12px',
22+
boxShadow: '0 2px 8px #dfe6e9',
23+
}}
24+
>
25+
<button
26+
onClick={() => setTab('workspace')}
27+
style={{
28+
padding: '12px 24px',
29+
border: 'none',
30+
background: tab === 'workspace' ? '#3498db' : 'transparent',
31+
color: tab === 'workspace' ? 'white' : '#2c3e50',
32+
fontWeight: 600,
33+
cursor: 'pointer',
34+
borderBottom: tab === 'workspace' ? '2px solid #2980b9' : 'none',
35+
outline: 'none',
36+
borderRadius: '0 0 0 12px',
37+
}}
38+
>
39+
Workspace
40+
</button>
41+
<button
42+
onClick={() => setTab('collision-detection')}
43+
style={{
44+
padding: '12px 24px',
45+
border: 'none',
46+
background: tab === 'collision-detection' ? '#e17055' : 'transparent',
47+
color: tab === 'collision-detection' ? 'white' : '#2c3e50',
48+
fontWeight: 600,
49+
cursor: 'pointer',
50+
borderBottom: tab === 'collision-detection' ? '2px solid #d35400' : 'none',
51+
outline: 'none',
52+
}}
53+
>
54+
Collision Detection
55+
</button>
56+
</div>
57+
58+
{/* Main Content */}
59+
<div
60+
style={{
61+
flex: 1,
62+
minHeight: 0,
63+
marginTop: 48,
64+
}}
65+
>
66+
{tab === 'workspace' && <WorkspaceApp />}
67+
{tab === 'collision-detection' && <CollisionDetection />}
68+
</div>
69+
</div>
70+
);
71+
}

modules/masonry/playground/index.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import { createRoot } from 'react-dom/client';
2-
import { createBrowserRouter, Navigate, RouterProvider } from 'react-router-dom';
1+
import React from 'react';
2+
import ReactDOM from 'react-dom/client';
3+
import '../src/palette/palette.css';
4+
import App from './App';
5+
import { RecoilRoot } from 'recoil';
36

4-
import WorkSpace from './pages/workspace';
5-
6-
const router = createBrowserRouter([
7-
{
8-
path: '/workspace',
9-
element: <WorkSpace />,
10-
},
11-
{
12-
path: '/',
13-
element: <Navigate to="/workspace" />,
14-
},
15-
]);
16-
17-
const root = createRoot(document.getElementById('playground-root') as HTMLElement);
18-
root.render(<RouterProvider router={router} />);
7+
ReactDOM.createRoot(document.getElementById('playground-root')!).render(
8+
<React.StrictMode>
9+
<RecoilRoot>
10+
<App />
11+
</RecoilRoot>
12+
</React.StrictMode>,
13+
);

modules/masonry/playground/pages/workspace/BrickBlock.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

modules/masonry/playground/pages/workspace/BrickData.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

modules/masonry/playground/pages/workspace/BrickExpression.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

modules/masonry/playground/pages/workspace/BrickFactory.tsx

Lines changed: 0 additions & 87 deletions
This file was deleted.

modules/masonry/playground/pages/workspace/BrickStatement.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

modules/masonry/playground/pages/workspace/BricksCoordsStore.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)