1
- import { useId } from 'preact/hooks'
2
- import { LuEye , LuHome , LuLayers , LuVideo } from 'react-icons/lu'
3
- import { useToggle } from '../lib/hooks.js'
1
+ import { LuEye , LuHome , LuLayers , LuHelpCircle } from 'react-icons/lu'
2
+ import { useState } from 'preact/hooks'
4
3
import { clsx } from '../lib/utils.js'
5
4
import { GridAnimation } from './Animations.jsx'
6
5
import { toChildArray } from 'preact'
7
6
8
7
const FLOOR_LABELS = [ 'Piano Terra' , '1° Piano' , '2° Piano' ]
9
8
const GROUP_LABELS = [ 'Edifici A e B' , 'Edificio ex-Albergo' ]
10
9
11
- const LayerFloor = ( { label, cameraToViewpoint, data : { viewpoint, visible , toggle } } ) => {
10
+ const LayerFloor = ( { label, cameraToViewpoint, data : { viewpoint } } ) => {
12
11
return (
13
12
< div class = "row" >
14
13
< div class = "icon" role = "button" onClick = { ( ) => cameraToViewpoint ( viewpoint ) } >
@@ -32,9 +31,7 @@ const LayerGroup = ({ label, data: { floors }, cameraToViewpoint }) => {
32
31
)
33
32
}
34
33
35
- const CollapsibleIconPanel = ( { children } ) => {
36
- const [ layersPopup , toggleLayersPopup ] = useToggle ( false )
37
-
34
+ const CollapsibleIconPanel = ( { layersPopup, toggleLayersPopup, children } ) => {
38
35
// extracts jsx nodes from the "children" prop
39
36
const [ iconJsx , labelJsx , contentJsx ] = toChildArray ( children )
40
37
@@ -75,6 +72,11 @@ const CollapsibleIconButton = ({ onClick, children }) => {
75
72
}
76
73
77
74
export const Buttons = ( { planimetriaRef, reset, layerToggles : { dip, exdma } , showOnlyRegion } ) => {
75
+ // we only want to have one uncollapsed panel at a time
76
+ // so we need to keep track of which panel is open
77
+ // and close it when another one is opened
78
+ const [ layersPopup , setLayersPopup ] = useState ( null )
79
+
78
80
const onResetView = ( ) => {
79
81
if ( planimetriaRef . current ) {
80
82
planimetriaRef . current . animateCameraToViewpoint ( 'home' )
@@ -89,7 +91,10 @@ export const Buttons = ({ planimetriaRef, reset, layerToggles: { dip, exdma }, s
89
91
90
92
return (
91
93
< div class = "buttons" >
92
- < CollapsibleIconPanel >
94
+ < CollapsibleIconPanel
95
+ layersPopup = { layersPopup === 'layers' }
96
+ toggleLayersPopup = { ( ) => setLayersPopup ( layersPopup === 'layers' ? null : 'layers' ) }
97
+ >
93
98
< LuLayers />
94
99
< div class = "label" >
95
100
< div class = "fix-text" > Livelli</ div >
@@ -106,6 +111,30 @@ export const Buttons = ({ planimetriaRef, reset, layerToggles: { dip, exdma }, s
106
111
< div class = "fix-text" > Reimposta Vista</ div >
107
112
</ div >
108
113
</ CollapsibleIconButton >
114
+ < CollapsibleIconPanel
115
+ layersPopup = { layersPopup === 'help' }
116
+ toggleLayersPopup = { ( ) => setLayersPopup ( layersPopup === 'help' ? null : 'help' ) }
117
+ >
118
+ < LuHelpCircle />
119
+ < div class = "label" >
120
+ < div class = "fix-text" > Help</ div >
121
+ </ div >
122
+ < div class = "content" >
123
+ < div class = "title" > Come navigare la mappa</ div >
124
+ < ul >
125
+ < li > Per spostare la mappa, trascina con il mouse o con un dito.</ li >
126
+ < li > Per zoomare, usa la rotellina del mouse o i gesti di pinch-to-zoom.</ li >
127
+ < li > Per ruotare, clicca e trascina con il tasto destro del mouse o con due dita.</ li >
128
+ < li >
129
+ Per selezionare un piano, clicca sull'icona dell'occhio corrispondente dentro il
130
+ pannello < LuLayers /> .
131
+ </ li >
132
+ < li >
133
+ Per tornare alla vista iniziale, clicca su < LuHome /> .
134
+ </ li >
135
+ </ ul >
136
+ </ div >
137
+ </ CollapsibleIconPanel >
109
138
</ div >
110
139
)
111
140
}
0 commit comments