import { useState } from "react"; import { Box, Grid, Typography, Card, CardContent, Modal } from "@mui/material"; import pictoMaitriseOeuvre from "../assets/picto-maitrise-oeuvre.avif"; import pictoStructure from "../assets/picto-structure.avif"; import pictoElectricite from "../assets/picto-electricite.avif"; import PropTypes from "prop-types"; // Style commun pour le contenu du modal const modalStyle = { padding: 4, borderRadius: "20px", background: "rgba(255, 255, 255, 0.9)", boxShadow: "0 8px 32px rgba(0, 0, 0, 0.2)", backdropFilter: "blur(10px)", maxWidth: 600, margin: "auto", mt: 4, position: "relative", }; // Style commun pour l'icône affichée en haut à droite dans le modal const iconStyle = { position: "absolute", top: 16, right: 16, width: 80, height: 80, backgroundSize: "cover", backgroundPosition: "center", borderRadius: "50%", }; // Style commun pour les boutons "En savoir plus" et "Retour" const buttonStyle = { marginTop: "16px", padding: "8px 16px", backgroundColor: "#0e467f", color: "#fff", border: "none", borderRadius: "4px", cursor: "pointer", textTransform: "none", }; // Fonction pour générer le style de la carte en fonction de l'image de fond const cardStyle = (image) => ({ boxShadow: 3, padding: 2, textAlign: "center", backgroundColor: "#fff", backgroundImage: `linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7)), url(${image})`, backgroundSize: "40%", backgroundRepeat: "no-repeat", backgroundPosition: "center left", }); // Composant Modal réutilisable const ExpertiseModal = ({ modalId, image, title, text, openModal, handleClose }) => ( {title} ); const Expertices = ({ expertiseTitle, expertise1Title, expertise1Text, expertise2Title, expertise2Text, expertise3Title, expertise3Text, }) => { const [openModal, setOpenModal] = useState(null); const handleOpenModal = (modalId) => setOpenModal(modalId); const handleCloseModal = () => setOpenModal(null); // Fonction qui supprime les balises HTML et tronque le texte s'il est trop long const truncateText = (text, maxLength) => { const plainText = text.replace(/<[^>]+>/g, ""); return plainText.length > maxLength ? `${plainText.substring(0, maxLength)}...` : plainText; }; return ( {expertiseTitle} {/* Expertise 1 */} {expertise1Title} {truncateText(expertise1Text, 70)} {/* Expertise 2 */} {expertise2Title} {truncateText(expertise2Text, 70)} {/* Expertise 3 */} {expertise3Title} {truncateText(expertise3Text, 70)} {/* Modaux */} ); }; Expertices.propTypes = { expertiseTitle: PropTypes.string.isRequired, expertise1Title: PropTypes.string.isRequired, expertise1Text: PropTypes.string.isRequired, expertise2Title: PropTypes.string.isRequired, expertise2Text: PropTypes.string.isRequired, expertise3Title: PropTypes.string.isRequired, expertise3Text: PropTypes.string.isRequired, }; export default Expertices;