1
1
import React , { PureComponent } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
- import { isTouch } from 'utils/browser' ;
4
3
5
- import { Tooltip } from 'react-tippy' ;
6
4
import Dropdown from 'components/dropdown' ;
7
5
import Loader from 'components/loader' ;
8
6
import Icon from 'components/icon' ;
9
7
import Button from 'components/button' ;
10
- import Tip from 'components/tip' ;
11
8
12
9
import arrowDownIcon from 'assets/icons/arrow-down.svg' ;
13
10
import shareIcon from 'assets/icons/share.svg' ;
14
11
import downloadIcon from 'assets/icons/download.svg' ;
15
12
import './header-styles.scss' ;
16
13
17
14
class Header extends PureComponent {
15
+ constructor ( props ) {
16
+ super ( props ) ;
17
+ this . state = {
18
+ disableTooltips : false
19
+ } ;
20
+ }
21
+
18
22
render ( ) {
19
23
const {
20
24
className,
@@ -31,7 +35,7 @@ class Header extends PureComponent {
31
35
location,
32
36
forestAtlasLink
33
37
} = this . props ;
34
- const isDeviceTouch = isTouch ( ) ;
38
+ const { disableTooltips } = this . state ;
35
39
36
40
return (
37
41
< div className = { `${ className } c-header` } >
@@ -47,19 +51,12 @@ class Header extends PureComponent {
47
51
...location
48
52
} }
49
53
tooltip = { {
50
- theme : 'tip' ,
51
- position : 'bottom' ,
52
- arrow : true ,
53
- disabled : isDeviceTouch ,
54
- html : (
55
- < Tip
56
- text = { `Download the country data${
57
- locationNames . country
58
- ? ` for ${ locationNames . country . label } `
59
- : ''
60
- } `}
61
- />
62
- )
54
+ text : `Download the country data${
55
+ locationNames . country
56
+ ? ` for ${ locationNames . country . label } `
57
+ : ''
58
+ } `,
59
+ position : 'bottom'
63
60
} }
64
61
>
65
62
< Icon icon = { downloadIcon } />
@@ -68,88 +65,108 @@ class Header extends PureComponent {
68
65
className = "theme-button-small theme-button-grey square"
69
66
onClick = { ( ) => setShareModal ( shareData ) }
70
67
tooltip = { {
71
- theme : 'tip' ,
72
- position : 'bottom' ,
73
- arrow : true ,
74
- disabled : isDeviceTouch ,
75
- html : < Tip text = "Share this page" />
68
+ text : 'Share this page' ,
69
+ position : 'bottom'
76
70
} }
77
71
>
78
72
< Icon icon = { shareIcon } />
79
73
</ Button >
80
74
</ div >
81
75
< div className = "row" >
82
76
< div className = "columns small-12 large-6" >
83
- < Tooltip
84
- theme = "tip"
85
- position = "top"
86
- arrow
87
- disabled = { isDeviceTouch }
88
- html = {
89
- < Tip text = "Choose the country and region you want to explore" />
90
- }
91
- >
92
- < div className = "select-container" >
93
- < div className = "select" >
94
- < Icon icon = { arrowDownIcon } className = "icon" />
95
- < Dropdown
96
- theme = "theme-select-dark"
97
- placeholder = "Country"
98
- noItemsFound = "No country found"
99
- value = { locationNames . country }
100
- options = { locationOptions . countries }
101
- onChange = { handleCountryChange }
102
- searchable
103
- disabled = { loading }
104
- />
105
- </ div >
106
- { locationOptions . regions &&
107
- locationOptions . regions . length > 1 && (
108
- < div className = "select" >
109
- < Icon icon = { arrowDownIcon } className = "icon" />
110
- < Dropdown
111
- theme = "theme-select-dark"
112
- placeholder = "Region"
113
- noItemsFound = "No region found"
114
- value = { locationNames . region }
115
- options = { locationOptions . regions }
116
- onChange = { region =>
117
- handleRegionChange ( locationNames . country , region )
118
- }
119
- searchable
120
- disabled = { loading }
121
- />
122
- </ div >
123
- ) }
124
- { locationNames . region &&
125
- locationNames . region . value &&
126
- locationOptions . subRegions &&
127
- locationOptions . subRegions . length > 1 && (
128
- < div className = "select" >
129
- < Icon
130
- icon = { arrowDownIcon }
131
- className = "icon c-header__select-arrow"
132
- />
133
- < Dropdown
134
- theme = "theme-select-dark"
135
- placeholder = "Region"
136
- noItemsFound = "No region found"
137
- value = { locationNames . subRegion }
138
- options = { locationOptions . subRegions }
139
- onChange = { subRegion =>
140
- handleSubRegionChange (
141
- locationNames . country ,
142
- locationNames . region ,
143
- subRegion
144
- )
145
- }
146
- searchable
147
- disabled = { loading }
148
- />
149
- </ div >
150
- ) }
77
+ < div className = "select-container" >
78
+ < div className = "select" >
79
+ < Icon icon = { arrowDownIcon } className = "icon" />
80
+ < Dropdown
81
+ theme = "theme-select-dark"
82
+ placeholder = "Country"
83
+ noItemsFound = "No country found"
84
+ value = { locationNames . country }
85
+ options = { locationOptions . countries }
86
+ onChange = { handleCountryChange }
87
+ searchable
88
+ disabled = { loading }
89
+ tooltip = { {
90
+ text : 'Choose the country you want to explore' ,
91
+ delay : 1000 ,
92
+ disabled : disableTooltips
93
+ } }
94
+ onOpen = { ( ) => {
95
+ this . setState ( { disableTooltips : true } ) ;
96
+ } }
97
+ onClose = { ( ) => {
98
+ this . setState ( { disableTooltips : false } ) ;
99
+ } }
100
+ />
151
101
</ div >
152
- </ Tooltip >
102
+ { locationOptions . regions &&
103
+ locationOptions . regions . length > 1 && (
104
+ < div className = "select" >
105
+ < Icon icon = { arrowDownIcon } className = "icon" />
106
+ < Dropdown
107
+ theme = "theme-select-dark"
108
+ placeholder = "Region"
109
+ noItemsFound = "No region found"
110
+ value = { locationNames . region }
111
+ options = { locationOptions . regions }
112
+ onChange = { region =>
113
+ handleRegionChange ( locationNames . country , region )
114
+ }
115
+ searchable
116
+ disabled = { loading }
117
+ tooltip = { {
118
+ text : 'Choose the region you want to explore' ,
119
+ delay : 1000 ,
120
+ disabled : disableTooltips
121
+ } }
122
+ onOpen = { ( ) => {
123
+ this . setState ( { disableTooltips : true } ) ;
124
+ } }
125
+ onClose = { ( ) => {
126
+ this . setState ( { disableTooltips : false } ) ;
127
+ } }
128
+ />
129
+ </ div >
130
+ ) }
131
+ { locationNames . region &&
132
+ locationNames . region . value &&
133
+ locationOptions . subRegions &&
134
+ locationOptions . subRegions . length > 1 && (
135
+ < div className = "select" >
136
+ < Icon
137
+ icon = { arrowDownIcon }
138
+ className = "icon c-header__select-arrow"
139
+ />
140
+ < Dropdown
141
+ theme = "theme-select-dark"
142
+ placeholder = "Region"
143
+ noItemsFound = "No region found"
144
+ value = { locationNames . subRegion }
145
+ options = { locationOptions . subRegions }
146
+ onChange = { subRegion =>
147
+ handleSubRegionChange (
148
+ locationNames . country ,
149
+ locationNames . region ,
150
+ subRegion
151
+ )
152
+ }
153
+ searchable
154
+ disabled = { loading }
155
+ tooltip = { {
156
+ text : 'Choose the region you want to explore' ,
157
+ delay : 1000 ,
158
+ disabled : disableTooltips
159
+ } }
160
+ onOpen = { ( ) => {
161
+ this . setState ( { disableTooltips : true } ) ;
162
+ } }
163
+ onClose = { ( ) => {
164
+ this . setState ( { disableTooltips : false } ) ;
165
+ } }
166
+ />
167
+ </ div >
168
+ ) }
169
+ </ div >
153
170
</ div >
154
171
< div className = "columns large-6 medium-12 small-12" >
155
172
< div className = "description text -title-xs" >
0 commit comments