diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..32e07b4f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "WillLuke.nextjs.hasPrompted": true +} \ No newline at end of file diff --git a/apps/frontend/src/components/MediaPopup.tsx b/apps/frontend/src/components/MediaPopup.tsx new file mode 100644 index 00000000..528357e3 --- /dev/null +++ b/apps/frontend/src/components/MediaPopup.tsx @@ -0,0 +1,86 @@ +import React, { useState } from 'react'; + +interface MediaPopupProps { + images: string[]; // List of image URLs or file references + onAddImages: (selectedImages: string[]) => void; // Callback for selected images +} + +const MediaPopup: React.FC = ({ images, onAddImages }) => { + const [selectedImages, setSelectedImages] = useState([]); + + // Toggle the selection of an image + const toggleImageSelection = (image: string) => { + if (selectedImages.includes(image)) { + setSelectedImages(selectedImages.filter((img) => img !== image)); // Remove if already selected + } else { + setSelectedImages([...selectedImages, image]); // Add to selected images + } + }; + + // Handle the add button click + const handleAddClick = () => { + onAddImages(selectedImages); // Pass selected images back to the parent + setSelectedImages([]); // Clear selection after adding + }; + + return ( +
+

Select Images

+
+ {images.map((image) => ( +
toggleImageSelection(image)} + > + media +
+ ))} +
+ + + +
+ ); +}; + +export default MediaPopup; diff --git a/apps/frontend/src/components/PostCreator.tsx b/apps/frontend/src/components/PostCreator.tsx new file mode 100644 index 00000000..0527e60f --- /dev/null +++ b/apps/frontend/src/components/PostCreator.tsx @@ -0,0 +1,60 @@ +import React, { useState } from 'react'; +import MediaPopup from './MediaPopup'; // Import the MediaPopup component + +const PostCreator: React.FC = () => { + const [showMediaPopup, setShowMediaPopup] = useState(false); + const [selectedImages, setSelectedImages] = useState([]); + + const imageGallery = [ + 'image1.jpg', + 'image2.jpg', + 'image3.jpg', + 'image4.jpg', + // Add more image URLs or file paths here + ]; + + // Callback to handle the images selected from the media popup + const handleAddImages = (images: string[]) => { + setSelectedImages((prevImages) => [...prevImages, ...images]); // Add the selected images to the existing list + setShowMediaPopup(false); // Close the popup after adding + }; + + return ( +
+

Create a Post

+ + + {/* Display selected images */} +
+ {selectedImages.map((image) => ( + Selected + ))} +
+ + {/* Media popup */} + {showMediaPopup && ( + + )} + + +
+ ); +}; + +export default PostCreator;