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

modifying css for the form page #69

Merged
merged 5 commits into from
Jun 17, 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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
REACT_APP_ACTIVATE_USING_JSON="false"

1 change: 1 addition & 0 deletions src/Components/Carousel/Carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
transition: all 750ms linear;
width: 100%;
height: fit-content;
max-height: 100px;
object-fit: contain;
}

Expand Down
9 changes: 7 additions & 2 deletions src/Components/Carousel/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from "react";
import "./Carousel.css";
import ImageZoomInOut from "../ImageZoomInOut/ImageZoomInOut";
interface CarouselProps {
imgs: {
url: string;
Expand Down Expand Up @@ -45,11 +46,15 @@
<a className="prev" onClick={() => selectImg(currImg - 1)}>
&#10094;
</a>
<img
<ImageZoomInOut
className="main-img"

Check failure on line 50 in src/Components/Carousel/Carousel.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Delete `····`

Check failure on line 50 in src/Components/Carousel/Carousel.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Delete `····`
imageUrl={imgList.length > 0 ? imgList[currImg].url : ""}

Check failure on line 51 in src/Components/Carousel/Carousel.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `··············imageUrl={imgList.length·>·0·?·imgList[currImg].url·:·""}·` with `··········imageUrl={imgList.length·>·0·?·imgList[currImg].url·:·""}`

Check failure on line 51 in src/Components/Carousel/Carousel.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `··············imageUrl={imgList.length·>·0·?·imgList[currImg].url·:·""}·` with `··········imageUrl={imgList.length·>·0·?·imgList[currImg].url·:·""}`
alt="no picture"/>

Check failure on line 52 in src/Components/Carousel/Carousel.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `··············alt="no·picture"` with `··········alt="no·picture"⏎········`

Check failure on line 52 in src/Components/Carousel/Carousel.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `··············alt="no·picture"` with `··········alt="no·picture"⏎········`
{/*<img
id="main-img"
src={imgList.length > 0 ? imgList[currImg].url : ""}
alt={imgList.length > 0 ? imgList[currImg].title : "No picture"}
></img>
></img>*/}
<a className="next" onClick={() => selectImg(currImg + 1)}>
&#10095;
</a>
Expand Down
21 changes: 21 additions & 0 deletions src/Components/ImageZoomInOut/ImageZoomInOut.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.btn-container {
display: flex;
flex-direction: column;
gap: 8px;
background-color: #fff;
border-radius: 8px;
overflow: hidden;
position: absolute;
top: 0;
left: 0;
z-index: 1;
border:1px solid black;
}

.btn-container button {
border: none;
color: #737373;
background-color: #fff;
padding: 10px;
cursor: pointer;
}
127 changes: 127 additions & 0 deletions src/Components/ImageZoomInOut/ImageZoomInOut.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { useState, useRef, useEffect } from "react";
import "./ImageZoomInOut.css";

interface ImageProps {
imageUrl: string;
className?: string; // Optional class name
onClick?: () => void; // Optional click handler function
}

function ImageZoomInOut({ imageUrl, className, onClick }: ImageProps) {
const [scale, setScale] = useState(1);
const [position, setPosition] = useState({ x: 0, y: 0 });
const imageRef = useRef(null);
const intervalRef = useRef<NodeJS.Timeout | null>(null)||scale>1;

Check failure on line 14 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `||scale>` with `·||·scale·>·`

Check failure on line 14 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `||scale>` with `·||·scale·>·`

const handleHoldZoomIn = () => {
if (intervalRef.current && (scale + 0.05 < 1)) return;

Check failure on line 17 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `(scale·+·0.05·<·1)` with `scale·+·0.05·<·1`

Check failure on line 17 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `(scale·+·0.05·<·1)` with `scale·+·0.05·<·1`
intervalRef.current = setInterval(() => {
handleZoomIn();
}, 1);
};

const handleHoldZoomOut = () => {
if (intervalRef.current && (scale + 0.05 < 1)) return;

Check failure on line 24 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `(scale·+·0.05·<·1)` with `scale·+·0.05·<·1`

Check failure on line 24 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `(scale·+·0.05·<·1)` with `scale·+·0.05·<·1`
intervalRef.current = setInterval(() => {
handleZoomOut();
}, 1);
};

const handleHoldZoomInOutStop = () => {
if (intervalRef.current) {
clearInterval(intervalRef.current);
intervalRef.current = null;
}
};

const handleZoomIn = () => {
if (scale + 0.05 > 1) {
setScale((scale) => scale + 0.05);

Check failure on line 39 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Delete `··`

Check failure on line 39 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Delete `··`
}else{

Check failure on line 40 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `else` with `·else·`

Check failure on line 40 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Replace `else` with `·else·`
setScale(1);

Check failure on line 41 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Delete `··`

Check failure on line 41 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Delete `··`
handleHoldZoomInOutStop();

Check failure on line 42 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Delete `··`

Check failure on line 42 in src/Components/ImageZoomInOut/ImageZoomInOut.tsx

View workflow job for this annotation

GitHub Actions / lint-test / lint-test

Delete `··`
}
};

const handleZoomOut = () => {
if (scale - 0.05 > 1) {
setScale((scale) => scale - 0.05);
}else{
setScale(1);
handleHoldZoomInOutStop();
}
};

useEffect(() => {
const image = imageRef.current as unknown as HTMLImageElement;
let isDragging = false;
let prevPosition = { x: 0, y: 0 };

const handleMouseDown = (e: MouseEvent) => {
isDragging = true;
prevPosition = { x: e.clientX, y: e.clientY };
};

const handleMouseMove = (e: MouseEvent) => {
if (!isDragging) return;
const deltaX = e.clientX - prevPosition.x;
const deltaY = e.clientY - prevPosition.y;
prevPosition = { x: e.clientX, y: e.clientY };
setPosition((position) => ({
x: position.x + deltaX,
y: position.y + deltaY,
}));
};

const handleMouseUp = () => {
isDragging = false;
};

image?.addEventListener("mousedown", handleMouseDown);
image?.addEventListener("mousemove", handleMouseMove);
image?.addEventListener("mouseup", handleMouseUp);

return () => {
image?.removeEventListener("mousedown", handleMouseDown);
image?.removeEventListener("mousemove", handleMouseMove);
image?.removeEventListener("mouseup", handleMouseUp);
};
}, [imageRef, scale]);

return (
<div
className={`imageZoomInOut ${className || ""}`}
style={{
backgroundColor: "#ffffff",
borderRadius: "10px",
position: "relative",
overflow: "hidden",
}}
onClick={onClick}
>
<div className={`btn-container ${imageRef.current ? "hidden" : ""}`}>
<button onClick={handleZoomIn} onMouseDown={handleHoldZoomIn} onMouseUp={handleHoldZoomInOutStop} onMouseLeave={handleHoldZoomInOutStop}>
<span className="material-symbols-outlined">+</span>
</button>
<button onClick={handleZoomOut} onMouseDown={handleHoldZoomOut} onMouseUp={handleHoldZoomInOutStop} onMouseLeave={handleHoldZoomInOutStop}>
<span className="material-symbols-outlined">-</span>
</button>
</div>

<img
ref={imageRef}
src={imageUrl}
alt="No Picture"
className="imageZoomInOut"
style={{
width: "50vw",
transform: `scale(${scale}) translate(${position.x}px, ${position.y}px)`,
cursor: "move",
}}
draggable={false}
/>
</div>
);
}

export default ImageZoomInOut;
31 changes: 30 additions & 1 deletion src/Components/Modal/Modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* Styles de la carte */
.card {
width: 75%;
width: 50%;
max-width: 800px;
background-color: white;
padding: 20px;
Expand Down Expand Up @@ -107,3 +107,32 @@
padding-right: 10px;
background: transparent;
}

@media only screen and (min-width: 850px) {
.formPage-container {
grid-template-areas:
"pics data"
"pics open-icon"; /* Add a new row for the open-icon */
grid-template-columns: 42% 55%;
}
}

@media only screen and (max-width: 850px) {
.formPage-container {
grid-template-areas:
"pics"
"data";
justify-content: center;
}
}

.pic-container {
grid-area: pics;
margin-right:10px ;
}

@media (prefers-color-scheme: dark) {
.open-icon {
filter: invert(74%) sepia(37%) saturate(0%) hue-rotate(249deg) brightness(101%) contrast(98%);
}
}
11 changes: 11 additions & 0 deletions src/Components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import React, { useState } from "react";
import "./Modal.css";
import closeIcon from "../../assets/close_icon.png";
import Carousel from "../Carousel/Carousel";
interface ModalProps {
text: string;
imgs: Image[]; // Array of Image objects
handleTextChange: (event: {
target: { value: React.SetStateAction<string> };
}) => void;
close: () => void;
toRef: React.MutableRefObject<HTMLDivElement | null>;
}

interface Image {
url: string; // Image URL
title: string; // Image title (optional)
}

const Modal: React.FC<ModalProps> = ({
text,
handleTextChange,
close,
toRef,
imgs,
}) => {
const [isEditing, setIsEditing] = useState(false); // Added state for edit mode

Expand All @@ -41,6 +49,9 @@ const Modal: React.FC<ModalProps> = ({

return (
<div className="overlay" onClick={handleOverlayClick} ref={toRef}>
<div className="pic-container">
<Carousel imgs={imgs}></Carousel>
</div>
<div className="card">
<img
src={closeIcon}
Expand Down
46 changes: 29 additions & 17 deletions src/Pages/FormPage/FormPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

@media only screen and (min-width: 850px) {
.formPage-container {
grid-template-areas: "pics data";
grid-template-areas:
"pics data"
"pics open-icon"; /* Add a new row for the open-icon */
grid-template-columns: 42% 55%;
}
}
Expand All @@ -26,8 +28,7 @@

@media (prefers-color-scheme: dark) {
.open-icon {
filter: invert(74%) sepia(37%) saturate(0%) hue-rotate(249deg)
brightness(101%) contrast(98%);
filter: invert(74%) sepia(37%) saturate(0%) hue-rotate(249deg) brightness(101%) contrast(98%);
}
}

Expand All @@ -38,25 +39,32 @@
flex-direction: column;
min-height: 100%;
padding-bottom: 60px;
/* Add justify-content: space-between to position elements at the top and bottom */
justify-content: space-between;
align-items: left;
font-family: Arial, sans-serif, Bold;
color: #000000;
font-size: 20px;
}

.data-container h1 {
text-align: left;
margin-left: 20px;
}
.data-container label{
font-family: Arial, sans-serif, Bold; ;
color: #000000;
font-size: 20px;
font-size: 40px;
}

.data-container label {
text-align: left;
margin-left: 30px;
}

.textbox-container {
display: flex; /* Enable flexbox layout */
justify-content: left; /* Center horizontally within the container */
align-items: center; /* Center vertically within the container */
width: 100%; /* Make the container take up the full width */
margin-left: 20px;
flex-direction: row;
}

.underlined {
Expand All @@ -68,8 +76,8 @@ textarea {
border: 1px solid #ccc;
border-radius: 10px;
box-sizing: border-box;
width: 300px;
height: auto;
width: 300px;
height: auto;
min-height: 40px;
max-height: 97px;
resize: none;
Expand All @@ -88,14 +96,19 @@ textarea {
}

.open-icon {
position: relative;
top: 35px;
right: 37px;
margin: -5%;
width: 12%;
height: auto;
position:relative;
margin-left: 30px;
width: 120%; /* Make the label take up the full width of the textbox container */
font-size: 15px; /* Set font size for the label */
text-decoration: underline;
color: darkgrey;
}

.show-more-container{
margin-left: 210px;
margin-right: -30px;
margin-top: -5px;
}
.data-section {
display: flex;
flex-direction: column;
Expand All @@ -107,7 +120,6 @@ textarea {
.input-container {
display: inline-flex;
flex-direction: column;
align-items: baseline;
width: 300px;
}

Expand Down
Loading
Loading