|
2 | 2 |
|
3 | 3 | import React, { useState, useEffect, useMemo } from "react"; |
4 | 4 | import { useSearchParams, usePathname, useRouter } from "next/navigation"; |
| 5 | +import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch"; |
5 | 6 | import EventDayButton from "@/components/EventDayButton"; |
6 | 7 | import GridList from "@/components/GridList"; |
7 | | -import ZoomSvg from "@/components/svg/ZoomableSvg"; |
8 | 8 | import CompanyStand from "./stands/CompanyStand"; |
9 | 9 | import Entrances from "./stands/Entrances"; |
10 | 10 | import CoworkingZone from "./stands/CoworkingZone"; |
@@ -135,30 +135,67 @@ const VenueStands: React.FC<VenueStandsProps> = ({ companies }) => { |
135 | 135 | ))} |
136 | 136 | </GridList> |
137 | 137 |
|
138 | | - <ZoomSvg minZoom={0.6}> |
139 | | - <svg viewBox="0 0 512 380" className="w-full h-auto max-w-4xl mx-auto"> |
140 | | - <Entrances /> |
141 | | - <SessionsStands /> |
142 | | - <FoodZone /> |
143 | | - <CoworkingZone /> |
144 | | - |
145 | | - {/* Company Stands */} |
146 | | - <g id="stands"> |
147 | | - {standsForSelectedDay.map((stand) => { |
148 | | - const company = getCompanyAtPosition(stand.standId); |
149 | | - return ( |
150 | | - <CompanyStand |
151 | | - key={`stand-${stand.standId}`} |
152 | | - stand={stand} |
153 | | - company={company} |
154 | | - standPositions={standPositions} |
155 | | - isSelected={isStandHighlighted(company)} |
156 | | - /> |
157 | | - ); |
158 | | - })} |
159 | | - </g> |
160 | | - </svg> |
161 | | - </ZoomSvg> |
| 138 | + <div className="relative w-full"> |
| 139 | + <TransformWrapper |
| 140 | + initialScale={1} |
| 141 | + centerZoomedOut={true} |
| 142 | + centerOnInit={true} |
| 143 | + > |
| 144 | + {({ zoomIn, zoomOut, resetTransform, ...rest }) => ( |
| 145 | + <React.Fragment> |
| 146 | + <div className="absolute top-4 right-4 flex flex-col gap-2 z-10"> |
| 147 | + <button |
| 148 | + onClick={() => zoomIn()} |
| 149 | + className="button button-primary !bg-sinfo-primary flex-1 p-2 rounded hover:opacity-90 transition-opacity" |
| 150 | + > |
| 151 | + + |
| 152 | + </button> |
| 153 | + <button |
| 154 | + onClick={() => zoomOut()} |
| 155 | + className="button button-primary !bg-sinfo-primary flex-1 p-2 rounded hover:opacity-90 transition-opacity" |
| 156 | + > |
| 157 | + - |
| 158 | + </button> |
| 159 | + {/* <button |
| 160 | + onClick={() => resetTransform()} |
| 161 | + className="button button-primary !bg-sinfo-secondary flex-1 p-2 rounded hover:opacity-90 transition-opacity" |
| 162 | + > |
| 163 | + Reset |
| 164 | + </button> */} |
| 165 | + </div> |
| 166 | + <div className="relative overflow-hidden border border-gray-300 rounded"> |
| 167 | + <TransformComponent> |
| 168 | + <svg |
| 169 | + viewBox="0 0 512 380" |
| 170 | + className="w-full h-auto max-w-4xl mx-auto" |
| 171 | + > |
| 172 | + <Entrances /> |
| 173 | + <SessionsStands /> |
| 174 | + <FoodZone /> |
| 175 | + <CoworkingZone /> |
| 176 | + |
| 177 | + {/* Company Stands */} |
| 178 | + <g id="stands"> |
| 179 | + {standsForSelectedDay.map((stand) => { |
| 180 | + const company = getCompanyAtPosition(stand.standId); |
| 181 | + return ( |
| 182 | + <CompanyStand |
| 183 | + key={`stand-${stand.standId}`} |
| 184 | + stand={stand} |
| 185 | + company={company} |
| 186 | + standPositions={standPositions} |
| 187 | + isSelected={isStandHighlighted(company)} |
| 188 | + /> |
| 189 | + ); |
| 190 | + })} |
| 191 | + </g> |
| 192 | + </svg> |
| 193 | + </TransformComponent> |
| 194 | + </div> |
| 195 | + </React.Fragment> |
| 196 | + )} |
| 197 | + </TransformWrapper> |
| 198 | + </div> |
162 | 199 | </div> |
163 | 200 | ); |
164 | 201 | }; |
|
0 commit comments