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

this is for updating the branch to rebase it to main since visual studio code keep bugging #376

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f652b8d
Bump eslint-config-next from 15.0.3 to 15.0.4
dependabot[bot] Dec 9, 2024
6795c1c
Bump swiper from 11.1.14 to 11.1.15
dependabot[bot] Dec 9, 2024
33c1dee
Bump i18next from 23.16.5 to 24.0.5
dependabot[bot] Dec 9, 2024
4734f27
this is for hovering on image and show the text
SamuelPelletierEvraire Dec 11, 2024
ad3ba66
this is for hovering on image and show the text
SamuelPelletierEvraire Dec 11, 2024
1acd71c
Merge branch 'main' into hover-text-show-on-image
SamuelPelletierEvraire Dec 13, 2024
78ad385
Merge branch 'hover-text-show-on-image' of https://github.com/ai-cfia…
SamuelPelletierEvraire Dec 13, 2024
11d753c
Merge branch 'main' into dependabot/npm_and_yarn/i18next-24.0.5
SamuelPelletierEvraire Dec 13, 2024
976c08d
Merge pull request #374 from ai-cfia/dependabot/npm_and_yarn/i18next-…
SamuelPelletierEvraire Dec 13, 2024
97bf609
Bump nanoid from 3.3.7 to 3.3.8 in the npm_and_yarn group
dependabot[bot] Dec 13, 2024
4d9728a
Bump dotenv from 16.4.5 to 16.4.7
dependabot[bot] Dec 13, 2024
90f1074
Merge branch 'main' into dependabot/npm_and_yarn/eslint-config-next-1…
SamuelPelletierEvraire Dec 13, 2024
ae32bba
Merge pull request #372 from ai-cfia/dependabot/npm_and_yarn/eslint-c…
SamuelPelletierEvraire Dec 13, 2024
56e30ce
Merge branch 'main' into dependabot/npm_and_yarn/dotenv-16.4.7
SamuelPelletierEvraire Dec 13, 2024
591c78b
Merge pull request #371 from ai-cfia/dependabot/npm_and_yarn/dotenv-1…
SamuelPelletierEvraire Dec 13, 2024
c0a23a7
Merge branch 'main' into dependabot/npm_and_yarn/swiper-11.1.15
SamuelPelletierEvraire Dec 14, 2024
8ba95ec
Merge pull request #373 from ai-cfia/dependabot/npm_and_yarn/swiper-1…
SamuelPelletierEvraire Dec 14, 2024
4d46cb0
Merge branch 'main' into dependabot/npm_and_yarn/npm_and_yarn-af93afb32e
SamuelPelletierEvraire Dec 14, 2024
cb5bf0c
Merge pull request #379 from ai-cfia/dependabot/npm_and_yarn/npm_and_…
SamuelPelletierEvraire Dec 14, 2024
8dcf5c6
Merge branch 'main' into hover-text-show-on-image
SamuelPelletierEvraire Dec 16, 2024
0a8bd6e
made some modification on new feature
SamuelPelletierEvraire Dec 16, 2024
c0f6b9b
Merge branch 'hover-text-show-on-image' of https://github.com/ai-cfia…
SamuelPelletierEvraire Dec 16, 2024
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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"typescript.updateImportsOnFileMove.enabled": "always",
"i18n-ally.localesPaths": [
"public/locales"
]
],
"i18n-ally.keystyle": "nested"
}
58 changes: 31 additions & 27 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@mui/material": "^6.1.8",
"@mui/material-nextjs": "^6.1.4",
"axios": "^1.7.9",
"dotenv": "^16.4.5",
"i18next": "^23.16.5",
"dotenv": "^16.4.7",
"i18next": "^24.0.5",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-chained-backend": "^4.6.2",
"i18next-http-backend": "^2.6.2",
Expand All @@ -39,7 +39,7 @@
"react-hook-form": "^7.53.2",
"react-i18next": "^15.1.1",
"react-zoom-pan-pinch": "^3.6.1",
"swiper": "^11.1.14",
"swiper": "^11.1.15",
"ts-node": "^10.9.2",
"zustand": "^5.0.0"
},
Expand All @@ -54,7 +54,7 @@
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"eslint": "^8",
"eslint-config-next": "15.0.3",
"eslint-config-next": "15.0.4",
"jest": "^29.7.0",
"postcss": "^8",
"prettier": "^3.3.3",
Expand Down
143 changes: 143 additions & 0 deletions src/app/TestImagePage/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
"use client";

import React, { useState, useEffect, useCallback, useRef } from "react";
import { Container, Box, Button, TextareaAutosize } from "@mui/material";
import { TextData, ImageSize } from "@/types/types";
import TextOverlay from "@/components/textOverlay";
import MyZoomPanComponent from "@/components/textOverlay";

const UploadImagePage: React.FC = () => {
const [imageSrc, setImageSrc] = useState<string | null>(null);
const [imageSize, setImageSize] = useState<ImageSize | null>(null);
const [initialSize, setInitialSize] = useState<ImageSize | null>(null);
const [currentSize, setCurrentSize] = useState<ImageSize | null>(null);
const [scaleX, setScaleX] = useState<number>(1);
const [scaleY, setScaleY] = useState<number>(1);
const [isTextareaHovered, setIsTextareaHovered] = useState<boolean>(false);

const containerRef = useRef<HTMLDivElement>(null);

const handleImageChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files ? e.target.files[0] : null;
if (file) {
const reader = new FileReader();
reader.onload = (readerEvent: ProgressEvent<FileReader>) => {
const result = readerEvent.target?.result as string;
setImageSrc(result);
const img = new Image();
img.onload = () => {
const newSize = { width: img.width, height: img.height };
setImageSize(newSize);
setInitialSize(newSize);
setCurrentSize(newSize);
};
img.src = result;
};
reader.readAsDataURL(file);
}
};

const recalculateSizes = useCallback(() => {
if (imageSrc) {
const imgElement = document.getElementById(
"uploaded-image",
) as HTMLImageElement;
if (imgElement && initialSize) {
const currentWidth = imgElement.clientWidth;
const currentHeight = imgElement.clientHeight;
setCurrentSize({ width: currentWidth, height: currentHeight });
setScaleX(currentWidth / initialSize.width);
setScaleY(currentHeight / initialSize.height);
}
}
}, [imageSrc, initialSize]);

useEffect(() => {
recalculateSizes();
}, [imageSrc, recalculateSizes]);

useEffect(() => {
const handleResize = () => {
recalculateSizes();
};

const resizeObserver = new ResizeObserver(() => {
recalculateSizes();
});

if (containerRef.current) {
resizeObserver.observe(containerRef.current);
}

window.addEventListener("resize", handleResize);

return () => {
if (containerRef.current) resizeObserver.unobserve(containerRef.current);
window.removeEventListener("resize", handleResize);
};
}, [recalculateSizes]);

return (
<Container className="flex full flex-row">
<Box
className="justify-center flex"
sx={{
alignItems: "center",
borderRight: "1px solid black",
marginRight: "10px",
}}
>
{currentSize && (
<p>
Dimensions actuelles de l'image: {currentSize.width} x{" "}
{currentSize.height} pixels <br />
<br />
Dimensions initiales de l'image: {initialSize?.width} x{" "}
{initialSize?.height} pixels
</p>
)}
</Box>
<Box sx={{ my: 4, position: "relative" }} ref={containerRef}>
{imageSrc && (
<div
style={{
position: "relative",
width: "100%",
height: "auto",
display: "inline-block",
}}
>
<MyZoomPanComponent
imageUrl={imageSrc}
textData={null}
scaleX={scaleX}
scaleY={scaleY}
offsetX={1}
offsetY={1}
/>
</div>
)}
<Button variant="contained" component="label">
Télécharger une image
<input
type="file"
hidden
accept="image/*"
onChange={handleImageChange}
/>
</Button>
</Box>
<Box>
<TextareaAutosize
minRows={3}
className="border-2 border-gray-900 rounded-md p-2"
style={{ width: "100%" }}
onMouseEnter={() => setIsTextareaHovered(true)}
onMouseLeave={() => setIsTextareaHovered(false)}
/>
</Box>
</Container>
);
};

export default UploadImagePage;
Loading
Loading