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

Updated links for devsoc #587

Merged
merged 2 commits into from
Jan 25, 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
4 changes: 2 additions & 2 deletions client/src/components/Features/Features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const Features = () => {
</ListItemIcon>
<Typography color="textSecondary">
<Link
href="https://github.com/csesoc/Structs.sh"
href="https://github.com/devsoc-unsw/structs.sh"
color="textSecondary"
target="_blank"
>
Expand All @@ -128,7 +128,7 @@ const Features = () => {
<Box padding="20px">
<div
className="github-card"
data-github="csesoc/structs.sh"
data-github="devsoc-unsw/structs.sh"
data-width="100%"
data-theme="medium"
/>
Expand Down
15 changes: 5 additions & 10 deletions client/src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Footer = () => {
Information
</Typography>
<Typography color="textSecondary">
<Link href="https://github.com/csesoc/Structs.sh" color="inherit">
<Link href="https://github.com/devsoc-unsw/structs.sh" color="inherit">
GitHub Repository
</Link>
</Typography>
Expand All @@ -61,25 +61,20 @@ const Footer = () => {
Social
</Typography>
<Typography color="textSecondary">
<Link href="https://csesoc.unsw.edu.au/" color="inherit">
CSESoc Website
<Link href="https://devsoc.app/" color="inherit">
DevSoc Website
</Link>
</Typography>
<Typography color="textSecondary">
<Link href="https://www.facebook.com/csesoc/" color="inherit">
<Link href="https://www.facebook.com/devsocUNSW" color="inherit">
Facebook
</Link>
</Typography>
<Typography color="textSecondary">
<Link href="https://www.youtube.com/channel/UC1JHpRrf9j5IKluzXhprUJg" color="inherit">
YouTube
</Link>
</Typography>
</Grid>
</Grid>
</Container>
<Box textAlign="center" paddingTop={5}>
<Typography color="textSecondary">© {new Date().getFullYear()} — CSESoc UNSW</Typography>
<Typography color="textSecondary">© {new Date().getFullYear()} — Software Development Society (DevSoc)</Typography>
</Box>
</StyledFooter>
);
Expand Down
76 changes: 74 additions & 2 deletions client/src/components/Visualiser/VisualiserCanvas.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { PointerEvent, useEffect, useRef, useState } from 'react';
import { Box } from '@mui/material';
import { styled } from '@mui/material/styles';

Expand All @@ -19,6 +19,10 @@ const ZoomableSvg = styled('svg')(({ scale }) => ({
*/
const VisualiserCanvas: React.FC = () => {
const [scale, setScale] = useState(1);
const svgRef = useRef(null);
const [height, setHeight] = useState(1000);
const [width, setWidth] = useState(1000);

const ZOOM_SPEED = 0.05;
const MAX_SCALE = 2;
const MIN_SCALE = 0.5;
Expand All @@ -30,15 +34,83 @@ const VisualiserCanvas: React.FC = () => {
}
};

const [isPointerDown, setIsPointerDown] = useState(false);

const [pointerOrigin, setPointerOrigin] = useState({
x: 0,
y: 0,
});

const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {
setIsPointerDown(true);

setPointerOrigin({
x: event.clientX,
y: event.clientY,
});
};

const [viewBox, setViewBox] = useState({
x: 0,
y: 0,
});

const [newViewBox, setNewViewBox] = useState({
x: 0,
y: 0,
});

const handlePointerMove = (event: PointerEvent<HTMLDivElement>) => {
if (!isPointerDown) {
return;
}

event.preventDefault();

// Ensure x is between -width and width and y is between -height and height
setNewViewBox({
x: Math.min(width, Math.max(-width, viewBox.x - (event.clientX - pointerOrigin.x))),
y: Math.min(height, Math.max(-height, viewBox.y - (event.clientY - pointerOrigin.y))),
});
};

const handlePointerUp = () => {
setIsPointerDown(false);

setViewBox({
x: newViewBox.x,
y: newViewBox.y,
});
};

useEffect(() => {
setHeight(svgRef.current.clientHeight);
setWidth(svgRef.current.clientWidth);
setViewBox((prevViewBox) => ({
...prevViewBox,
height,
width,
}));
}, []);

return (
<Box
onWheel={onScroll}
id="visualiser-container"
margin="auto"
height="100vh"
width={window.screen.width}
onPointerDown={handlePointerDown}
onPointerUp={handlePointerUp}
onPointerMove={handlePointerMove}
onPointerLeave={handlePointerUp}
>
<ZoomableSvg onWheel={onScroll} id="visualiser-canvas" scale={scale} />
<ZoomableSvg
ref={svgRef}
id="visualiser-canvas"
scale={scale}
viewBox={`${newViewBox.x} ${newViewBox.y} ${width} ${height}`}
/>
</Box>
);
};
Expand Down
Loading