Skip to content

Commit

Permalink
Merge branch 'main' into hotfix/thkids
Browse files Browse the repository at this point in the history
  • Loading branch information
BeritJanssen committed Sep 27, 2024
2 parents 8584d4b + c240ca1 commit 5e0cf34
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/podman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ jobs:
- name: Prune old images
run: podman image prune -a -f
- name: Check Podman images
run: podman-compose -f docker compose-deploy.yml ps
run: podman-compose -f docker-compose-deploy.yml ps

e2e-acceptance:
name: E2E tests on acceptance environment
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker-compose definition for development
# docker compose definition for development

version: '2.4'

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Profile from "../Profile/Profile";
import Reload from "../Reload/Reload";
import StoreProfile from "../StoreProfile/StoreProfile";
import useDisableRightClickOnTouchDevices from "../../hooks/useDisableRightClickOnTouchDevices";
import useDisableIOSPinchZoomOnTouchDevices from "@/hooks/useDisableIOSPinchZoomOnTouchDevices";
import { InternalRedirect } from "../InternalRedirect/InternalRedirect";
import Helmet from "@/components/Helmet/Helmet";

Expand All @@ -31,6 +32,7 @@ const App = () => {
const queryParams = window.location.search;

useDisableRightClickOnTouchDevices();
useDisableIOSPinchZoomOnTouchDevices();

useEffect(() => {
const urlParams = new URLSearchParams(queryParams);
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/components/Circle/Circle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
margin-bottom: 15px;
margin-top: 15px;

> svg,
>svg,
.content {
position: absolute;
left: 0;
top: 0;
}

> svg {
>svg {
@extend .circleIntro;
}

.circle-percentage {
transition: stroke-dashoffset 0.1s linear;
transform: rotate(-90deg);
transform-origin: 50% 50%;

// 102.5px is the radius of the circle
// translateX because the circle is rotated -90deg
transform: rotate(-90deg) translateX(calc(-102.5px * 2));
}
}
36 changes: 36 additions & 0 deletions frontend/src/hooks/useDisableIOSPinchZoomOnTouchDevices.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { vi, describe, test, expect, afterEach } from "vitest";
import { renderHook } from "@testing-library/react-hooks";
import { waitFor } from "@testing-library/react";
import useDisableIOSPinchZoomOnTouchDevices from "./useDisableIOSPinchZoomOnTouchDevices";

describe("useDisableIOSPinchZoomOnTouchDevices", () => {
afterEach(() => {
vi.unstubAllGlobals();
});

test("should prevent gesturestart on touch devices", async () => {
vi.stubGlobal("ontouchstart", true);

const mockEvent = new Event('gesturestart');
mockEvent.preventDefault = vi.fn();

const spy = vi.spyOn(mockEvent, 'preventDefault').mockImplementation(() => { });

renderHook(() => useDisableIOSPinchZoomOnTouchDevices());

await waitFor(() => document.dispatchEvent(mockEvent));
await waitFor(() => expect(spy).toHaveBeenCalledTimes(1));
});

test("should not prevent gesturestart on non-touch devices", () => {
const mockEvent = new Event('gesturestart');
mockEvent.preventDefault = vi.fn();

const spy = vi.spyOn(mockEvent, 'preventDefault').mockImplementation(() => { });

renderHook(() => useDisableIOSPinchZoomOnTouchDevices());

document.dispatchEvent(mockEvent);
expect(spy).not.toHaveBeenCalled();
});
});
20 changes: 20 additions & 0 deletions frontend/src/hooks/useDisableIOSPinchZoomOnTouchDevices.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useEffect } from 'react';

const useDisableIOSPinchZoomOnTouchDevices = () => useEffect(() => {
const isTouchDevice = () => !!('ontouchstart' in window || !!(navigator.maxTouchPoints));

const handlePinchZoom = (event: Event) => {
if (isTouchDevice()) {
event.preventDefault();
}
};

document.addEventListener('gesturestart', handlePinchZoom);

return () => {
document.removeEventListener('gesturestart', handlePinchZoom);
};
}, []);


export default useDisableIOSPinchZoomOnTouchDevices;
3 changes: 3 additions & 0 deletions frontend/src/scss/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ body.root {
background-position: center center;
background-repeat: no-repeat;
min-height: 100vh;

/* disable pinch zoom on iOS */
touch-action: manipulation;
}

#root {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stories/Circle.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const LongDuration = {
radius: 100,
strokeWidth: 5,
color: "white",
duration: 30,
duration: 60,
animateCircle: true,
running: true,
},
Expand Down
1 change: 0 additions & 1 deletion scripts/build-front
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
docker compose run --rm client yarn build

1 change: 0 additions & 1 deletion scripts/test-back
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
docker compose run --rm server bash -c "python manage.py test $@"

1 change: 0 additions & 1 deletion scripts/test-back-coverage
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
docker compose run --rm server bash -c "coverage run manage.py test && coverage report --show-missing"

1 change: 0 additions & 1 deletion scripts/test-front
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
docker compose run --rm client yarn test --watch=false

1 change: 0 additions & 1 deletion scripts/test-front-watch
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
docker compose run --rm client yarn test --watch=true

0 comments on commit 5e0cf34

Please sign in to comment.