diff --git a/ui/public/images/countries.svg b/ui/public/images/countries.svg index 751e064..f0e7be0 100644 --- a/ui/public/images/countries.svg +++ b/ui/public/images/countries.svg @@ -17,23 +17,26 @@ fill: #f0f0f0; } .land:hover { - fill: #f0f0f0; + fill: #2563eb; } .landxx:hover { - fill: #f0f0f0; + fill: #2563eb; } - .water { - fill: #0f172a; -} + .ocean { fill: #0f172a; } + + .ocean:hover, .ocean.visited-country { + fill: #0f172a !important; + } + .entities path { fill: #334155; } - .visited-country { - fill: #2563eb; - } + .entities path.visited-country { + fill: #2563eb !important; +} { - const countryName = svgId.replace('countries_svg__', ''); - - if (!visitedCountries.some(country => country.name === countryName)) { + if (svgId === 'countries_svg__ocean') { + return; + } + + const countryName = svgId; + + if (!visitedCountries.some(country => country.code === svgId)) { const newCountry = { code: svgId, name: countryName }; setVisitedCountries([...visitedCountries, newCountry]); - console.log(`Country ${svgId} point added!`); + console.log(`Country ${svgId} added!`); } + }; + + // Функции для масштабирования + const zoomIn = () => { + setScale(scale * 1.1); + }; + + const zoomOut = () => { + setScale(scale / 1.1); + }; - // Add class to visited country - const visitedCountryElement = document.getElementById(svgId); - if (visitedCountryElement) { - visitedCountryElement.classList.add('visited-country'); + const resetZoom = () => { + setScale(1); + setPosition({ x: 0, y: 0 }); // Сброс позиции при сбросе масштаба + }; + + // Обработчики событий мыши + const handleMouseDown = (e) => { + setIsDragging(true); + setStartPosition({ x: e.clientX - position.x, y: e.clientY - position.y }); + e.preventDefault(); // Предотвратить стандартное поведение + }; + + const handleMouseUp = () => { + setIsDragging(false); + }; + + const handleMouseMove = (e) => { + if (isDragging) { + setPosition({ + x: e.clientX - startPosition.x, + y: e.clientY - startPosition.y, + }); + e.preventDefault(); } }; + useEffect(() => { + visitedCountries.forEach(country => { + const countryElement = document.getElementById(country.code); + if (countryElement) { + countryElement.style.fill = 'rgb(121, 80, 255)'; // Задаем цвет для посещенных стран + } + }); + }, [visitedCountries]); + return ( -
- { - if (e.target.id) { - handleCountryClick(e.target.id); - } - }} /> -
    - {visitedCountries.map((country) => ( -
  • {country.name}
  • - ))} -
+
+
+ + + +
+
+ { + const target = e.target as SVGElement; + handleCountryClick(target.id); + }} + /> +
); } diff --git a/ui/src/styles/globals.css b/ui/src/styles/globals.css index 905caee..22a922a 100644 --- a/ui/src/styles/globals.css +++ b/ui/src/styles/globals.css @@ -1,3 +1,7 @@ +@import 'tailwindcss/base'; +@import 'tailwindcss/components'; +@import 'tailwindcss/utilities'; + @font-face { font-family: 'ABC Monument Grotesk'; font-style: normal; @@ -42,8 +46,6 @@ body { overflow-x: hidden; font-family: 'ABC Monument Grotesk'; background-color: #0f172a; - color: rgb(36, 166, 231); - font-size: 14px; height: 100%; width: 100%; position: relative;