|
| 1 | +import React, { useEffect } from 'react'; |
| 2 | +import { useTranslation } from 'react-i18next'; |
| 3 | +import { X, MapPin, Clock, Navigation, Lightbulb } from 'lucide-react'; |
| 4 | + |
| 5 | +const mapsUrl = (name) => |
| 6 | + `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(`${name} Yaoundé`)}`; |
| 7 | + |
| 8 | +const TouristSiteDrawer = ({ site, onClose }) => { |
| 9 | + const { t } = useTranslation(); |
| 10 | + |
| 11 | + useEffect(() => { |
| 12 | + if (!site) return undefined; |
| 13 | + const handleKey = (e) => { |
| 14 | + if (e.key === 'Escape') onClose(); |
| 15 | + }; |
| 16 | + document.addEventListener('keydown', handleKey); |
| 17 | + const prevOverflow = document.body.style.overflow; |
| 18 | + document.body.style.overflow = 'hidden'; |
| 19 | + return () => { |
| 20 | + document.removeEventListener('keydown', handleKey); |
| 21 | + document.body.style.overflow = prevOverflow; |
| 22 | + }; |
| 23 | + }, [site, onClose]); |
| 24 | + |
| 25 | + if (!site) return null; |
| 26 | + |
| 27 | + const highlights = Array.isArray(site.highlights) ? site.highlights : []; |
| 28 | + |
| 29 | + return ( |
| 30 | + <> |
| 31 | + <div className="site-drawer-overlay" onClick={onClose} role="presentation" /> |
| 32 | + <aside className="site-drawer" role="dialog" aria-modal="true" aria-label={site.name}> |
| 33 | + <button type="button" className="site-drawer-close" onClick={onClose} aria-label={t('touristSites.close')}> |
| 34 | + <X size="1.5rem" /> |
| 35 | + </button> |
| 36 | + |
| 37 | + <div className="site-drawer-img"> |
| 38 | + <img src={site.image} alt={site.name} /> |
| 39 | + </div> |
| 40 | + |
| 41 | + <div className="site-drawer-body"> |
| 42 | + <h2 style={{ marginBottom: 'var(--spacing-xs)' }}>{site.name}</h2> |
| 43 | + <p style={{ color: 'var(--color-text-secondary)' }}>{site.description}</p> |
| 44 | + |
| 45 | + {site.longDescription && ( |
| 46 | + <p style={{ marginTop: 'var(--spacing-sm)' }}>{site.longDescription}</p> |
| 47 | + )} |
| 48 | + |
| 49 | + <h3 style={{ marginTop: 'var(--spacing-md)', marginBottom: 'var(--spacing-xs)' }}> |
| 50 | + <Clock size="1em" style={{ verticalAlign: '-0.125em', marginRight: '0.5rem', color: 'var(--color-orange)' }} /> |
| 51 | + {t('touristSites.duration')} |
| 52 | + </h3> |
| 53 | + <p>{t('touristSites.durationHours', { hours: site.duration })}</p> |
| 54 | + |
| 55 | + {site.gettingThere && ( |
| 56 | + <> |
| 57 | + <h3 style={{ marginTop: 'var(--spacing-md)', marginBottom: 'var(--spacing-xs)' }}> |
| 58 | + <Navigation size="1em" style={{ verticalAlign: '-0.125em', marginRight: '0.5rem', color: 'var(--color-orange)' }} /> |
| 59 | + {t('touristSites.gettingThere')} |
| 60 | + </h3> |
| 61 | + <p>{site.gettingThere}</p> |
| 62 | + </> |
| 63 | + )} |
| 64 | + |
| 65 | + {highlights.length > 0 && ( |
| 66 | + <> |
| 67 | + <h3 style={{ marginTop: 'var(--spacing-md)', marginBottom: 'var(--spacing-xs)' }}> |
| 68 | + <Lightbulb size="1em" style={{ verticalAlign: '-0.125em', marginRight: '0.5rem', color: 'var(--color-orange)' }} /> |
| 69 | + {t('touristSites.highlights')} |
| 70 | + </h3> |
| 71 | + <ul style={{ paddingLeft: '1.5rem' }}> |
| 72 | + {highlights.map((item, i) => <li key={i}>{item}</li>)} |
| 73 | + </ul> |
| 74 | + </> |
| 75 | + )} |
| 76 | + |
| 77 | + <div style={{ marginTop: 'var(--spacing-lg)' }}> |
| 78 | + <a |
| 79 | + href={site.mapUrl || mapsUrl(site.name)} |
| 80 | + target="_blank" |
| 81 | + rel="noopener noreferrer" |
| 82 | + className="btn btn-primary" |
| 83 | + style={{ width: '100%', justifyContent: 'center', display: 'inline-flex', alignItems: 'center' }} |
| 84 | + > |
| 85 | + <MapPin size="1em" style={{ verticalAlign: '-0.125em', marginRight: '0.5rem' }} /> |
| 86 | + {t('venue.openInMaps')} |
| 87 | + </a> |
| 88 | + </div> |
| 89 | + </div> |
| 90 | + </aside> |
| 91 | + </> |
| 92 | + ); |
| 93 | +}; |
| 94 | + |
| 95 | +export default TouristSiteDrawer; |
0 commit comments