Skip to content

Commit 6ed405f

Browse files
minORCray-oxd
authored andcommitted
DBC22-1568: Making filter icons interactive to be able to toggle filters
1 parent d928c11 commit 6ed405f

File tree

3 files changed

+65
-43
lines changed

3 files changed

+65
-43
lines changed

src/frontend/src/Components/Filters.js

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ export default function Filters(props) {
134134
<div className="filter-items-group">
135135
<div className="filter-items filter-items--delays">
136136
<div className={'filter-item filter-item--closures' + (closures ? ' checked' : '')}>
137-
<div className="filter-item__icon">
138-
<FontAwesomeIcon icon={faMinusCircle} alt="closures" />
139-
</div>
140137
<input
141138
type="checkbox"
142139
name="closures"
@@ -148,19 +145,18 @@ export default function Filters(props) {
148145
}}
149146
defaultChecked={mapContext.visible_layers.closures}
150147
/>
151-
<label htmlFor="filter--closures">Closures</label>
148+
<label htmlFor="filter--closures">
149+
<span className="filter-item__icon">
150+
<FontAwesomeIcon icon={faMinusCircle} alt="closures" />
151+
</span>
152+
Closures
153+
</label>
152154
<OverlayTrigger placement="top" overlay={tooltipClosures}>
153155
<span className="tooltip-info">?</span>
154156
</OverlayTrigger>
155157
</div>
156158

157159
<div className={'filter-item filter-item--major' + (majorEvents ? ' checked' : '')}>
158-
<div className="filter-item__icon">
159-
<svg alt="major delays" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
160-
<path className="customIcon-bg" d="M7.87872 1.12135C9.05029 -0.0502183 10.9498 -0.0502166 12.1214 1.12136L18.8787 7.87868C20.0503 9.05026 20.0503 10.9498 18.8787 12.1213L12.1213 18.8787C10.9497 20.0503 9.05026 20.0503 7.87868 18.8787L1.12136 12.1214C-0.0502174 10.9498 -0.0502174 9.05029 1.12136 7.87872L7.87872 1.12135Z" fill="#1A5A96"/>
161-
<path className="customIcon-fg" d="M10.8176 5.71429V11.4286C10.8176 11.8304 10.4403 12.1429 10.0126 12.1429C9.55976 12.1429 9.20755 11.8304 9.20755 11.4286V5.71429C9.20755 5.33483 9.55976 5.00001 10.0126 5.00001C10.4403 5.00001 10.8176 5.33483 10.8176 5.71429ZM10.0126 15C9.63523 15 9.30818 14.8438 9.13208 14.5536C8.95598 14.2857 8.95598 13.9509 9.13208 13.6607C9.30818 13.3929 9.63523 13.2143 10.0126 13.2143C10.3648 13.2143 10.6918 13.3929 10.8679 13.6607C11.044 13.9509 11.044 14.2857 10.8679 14.5536C10.6918 14.8438 10.3648 15 10.0126 15Z" fill="white"/>
162-
</svg>
163-
</div>
164160
<input
165161
type="checkbox"
166162
name="major"
@@ -172,19 +168,21 @@ export default function Filters(props) {
172168
}}
173169
defaultChecked={mapContext.visible_layers.majorEvents}
174170
/>
175-
<label htmlFor="filter--major">Major</label>
171+
<label htmlFor="filter--major">
172+
<span className="filter-item__icon">
173+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
174+
<path className="customIcon-bg" d="M7.87872 1.12135C9.05029 -0.0502183 10.9498 -0.0502166 12.1214 1.12136L18.8787 7.87868C20.0503 9.05026 20.0503 10.9498 18.8787 12.1213L12.1213 18.8787C10.9497 20.0503 9.05026 20.0503 7.87868 18.8787L1.12136 12.1214C-0.0502174 10.9498 -0.0502174 9.05029 1.12136 7.87872L7.87872 1.12135Z" fill="#1A5A96"/>
175+
<path className="customIcon-fg" d="M10.8176 5.71429V11.4286C10.8176 11.8304 10.4403 12.1429 10.0126 12.1429C9.55976 12.1429 9.20755 11.8304 9.20755 11.4286V5.71429C9.20755 5.33483 9.55976 5.00001 10.0126 5.00001C10.4403 5.00001 10.8176 5.33483 10.8176 5.71429ZM10.0126 15C9.63523 15 9.30818 14.8438 9.13208 14.5536C8.95598 14.2857 8.95598 13.9509 9.13208 13.6607C9.30818 13.3929 9.63523 13.2143 10.0126 13.2143C10.3648 13.2143 10.6918 13.3929 10.8679 13.6607C11.044 13.9509 11.044 14.2857 10.8679 14.5536C10.6918 14.8438 10.3648 15 10.0126 15Z" fill="white"/>
176+
</svg>
177+
</span>
178+
Major
179+
</label>
176180
<OverlayTrigger placement="top" overlay={tooltipMajor}>
177181
<span className="tooltip-info">?</span>
178182
</OverlayTrigger>
179183
</div>
180184

181185
<div className={'filter-item filter-item--minor' + (minorEvents ? ' checked' : '')}>
182-
<div className="filter-item__icon">
183-
<svg alt="minor delays" width="18" height="17" viewBox="0 0 18 17" fill="none" xmlns="http://www.w3.org/2000/svg">
184-
<path className="customIcon-bg" d="M11.2552 15.2763C10.3487 16.9079 7.65127 16.9079 6.74483 15.2763L0.247828 3.5816C-0.54594 2.1528 0.663609 0.5 2.50299 0.5L15.497 0.500001C17.3364 0.500001 18.5459 2.1528 17.7522 3.5816L11.2552 15.2763Z" fill="#1A5A96"/>
185-
<path className="customIcon-fg" d="M9.81761 3.21429V8.92857C9.81761 9.33036 9.44025 9.64286 9.01258 9.64286C8.55975 9.64286 8.20755 9.33036 8.20755 8.92857V3.21429C8.20755 2.83482 8.55975 2.5 9.01258 2.5C9.44025 2.5 9.81761 2.83482 9.81761 3.21429ZM9.01258 12.5C8.63522 12.5 8.30818 12.3438 8.13208 12.0536C7.95598 11.7857 7.95598 11.4509 8.13208 11.1607C8.30818 10.8929 8.63522 10.7143 9.01258 10.7143C9.36478 10.7143 9.69183 10.8929 9.86793 11.1607C10.044 11.4509 10.044 11.7857 9.86793 12.0536C9.69183 12.3438 9.36478 12.5 9.01258 12.5Z" fill="white"/>
186-
</svg>
187-
</div>
188186
<input
189187
type="checkbox"
190188
name="minor"
@@ -196,16 +194,21 @@ export default function Filters(props) {
196194
}}
197195
defaultChecked={mapContext.visible_layers.minorEvents}
198196
/>
199-
<label htmlFor="filter--minor">Minor</label>
197+
<label htmlFor="filter--minor">
198+
<span className="filter-item__icon">
199+
<svg width="18" height="17" viewBox="0 0 18 17" fill="none" xmlns="http://www.w3.org/2000/svg">
200+
<path className="customIcon-bg" d="M11.2552 15.2763C10.3487 16.9079 7.65127 16.9079 6.74483 15.2763L0.247828 3.5816C-0.54594 2.1528 0.663609 0.5 2.50299 0.5L15.497 0.500001C17.3364 0.500001 18.5459 2.1528 17.7522 3.5816L11.2552 15.2763Z" fill="#1A5A96"/>
201+
<path className="customIcon-fg" d="M9.81761 3.21429V8.92857C9.81761 9.33036 9.44025 9.64286 9.01258 9.64286C8.55975 9.64286 8.20755 9.33036 8.20755 8.92857V3.21429C8.20755 2.83482 8.55975 2.5 9.01258 2.5C9.44025 2.5 9.81761 2.83482 9.81761 3.21429ZM9.01258 12.5C8.63522 12.5 8.30818 12.3438 8.13208 12.0536C7.95598 11.7857 7.95598 11.4509 8.13208 11.1607C8.30818 10.8929 8.63522 10.7143 9.01258 10.7143C9.36478 10.7143 9.69183 10.8929 9.86793 11.1607C10.044 11.4509 10.044 11.7857 9.86793 12.0536C9.69183 12.3438 9.36478 12.5 9.01258 12.5Z" fill="white"/>
202+
</svg>
203+
</span>
204+
Minor
205+
</label>
200206
<OverlayTrigger placement="top" overlay={tooltipMinor}>
201207
<span className="tooltip-info">?</span>
202208
</OverlayTrigger>
203209
</div>
204210

205211
<div className={'filter-item filter-item--future-events' + (futureEvents ? ' checked' : '')}>
206-
<div className="filter-item__icon">
207-
<FontAwesomeIcon icon={faCalendarDays} alt="future events" />
208-
</div>
209212
<input
210213
type="checkbox"
211214
name="future events"
@@ -217,7 +220,12 @@ export default function Filters(props) {
217220
}}
218221
defaultChecked={mapContext.visible_layers.futureEvents}
219222
/>
220-
<label htmlFor="filter--future-events">Future Events</label>
223+
<label htmlFor="filter--future-events">
224+
<span className="filter-item__icon">
225+
<FontAwesomeIcon icon={faCalendarDays} alt="future events" />
226+
</span>
227+
Future Events
228+
</label>
221229
<OverlayTrigger placement="top" overlay={tooltipFutureevents}>
222230
<span className="tooltip-info">?</span>
223231
</OverlayTrigger>
@@ -231,9 +239,6 @@ export default function Filters(props) {
231239
<div className="filter-items-group">
232240
<div className="filter-items filter-items--conditions">
233241
<div className={'filter-item filter-item--highway-cameras' + (highwayCams ? ' checked' : '') + (disableFeatures ? ' disabled' : '')}>
234-
<div className="filter-item__icon">
235-
<FontAwesomeIcon icon={faVideo} alt="highway cameras" />
236-
</div>
237242
<input
238243
type="checkbox"
239244
name="highway cameras"
@@ -242,16 +247,18 @@ export default function Filters(props) {
242247
defaultChecked={mapContext.visible_layers.highwayCams}
243248
disabled={disableFeatures}
244249
/>
245-
<label htmlFor="filter--highway-cameras">Highway cameras</label>
250+
<label htmlFor="filter--highway-cameras">
251+
<span className="filter-item__icon">
252+
<FontAwesomeIcon icon={faVideo} alt="highway cameras" />
253+
</span>
254+
Highway cameras
255+
</label>
246256
<OverlayTrigger placement="top" overlay={tooltipHighwaycameras}>
247257
<span className="tooltip-info">?</span>
248258
</OverlayTrigger>
249259
</div>
250260

251261
<div className={'filter-item filter-item--road-conditions' + (roadConditions ? ' checked' : '') + (disableFeatures ? ' disabled' : '')}>
252-
<div className="filter-item__icon">
253-
<FontAwesomeIcon icon={faSnowflake} alt="road conditions" />
254-
</div>
255262
<input
256263
type="checkbox"
257264
name="road conditions"
@@ -264,16 +271,18 @@ export default function Filters(props) {
264271
defaultChecked={mapContext.visible_layers.roadConditions}
265272
disabled={disableFeatures}
266273
/>
267-
<label htmlFor="filter--road-conditions">Road conditions</label>
274+
<label htmlFor="filter--road-conditions">
275+
<span className="filter-item__icon">
276+
<FontAwesomeIcon icon={faSnowflake} alt="road conditions" />
277+
</span>
278+
Road conditions
279+
</label>
268280
<OverlayTrigger placement="top" overlay={tooltipRoadconditions}>
269281
<span className="tooltip-info">?</span>
270282
</OverlayTrigger>
271283
</div>
272284

273285
<div className={'filter-item filter-item--inland-ferries' + (inlandFerries ? ' checked' : '') + (disableFeatures ? ' disabled' : '')}>
274-
<div className="filter-item__icon">
275-
<FontAwesomeIcon icon={faFerry} alt="inland ferries" />
276-
</div>
277286
<input
278287
type="checkbox"
279288
name="inland ferries"
@@ -282,17 +291,22 @@ export default function Filters(props) {
282291
defaultChecked={mapContext.visible_layers.inlandFerries}
283292
disabled={disableFeatures}
284293
/>
285-
<label htmlFor="filter--inland-ferries">Inland ferries</label>
294+
<label htmlFor="filter--inland-ferries">
295+
<span className="filter-item__icon">
296+
<FontAwesomeIcon icon={faFerry} alt="inland ferries" />
297+
</span>
298+
Inland ferries
299+
</label>
286300
<OverlayTrigger placement="top" overlay={tooltipInlandferries}>
287301
<span className="tooltip-info">?</span>
288302
</OverlayTrigger>
289303
</div>
290304

291305
{/*
292306
<div className={'filter-item filter-item--rest-stops'}>
293-
<div className="filter-item__icon">
307+
<span className="filter-item__icon">
294308
<FontAwesomeIcon icon={faRestroom} alt="provincial rest stops" />
295-
</div>
309+
</span>
296310
<input
297311
type="checkbox"
298312
name="provincial rest stops"
@@ -305,9 +319,9 @@ export default function Filters(props) {
305319
</div>
306320
307321
<div className={'filter-item filter-item--weather'}>
308-
<div className="filter-item__icon">
322+
<span className="filter-item__icon">
309323
<FontAwesomeIcon icon={faCloudSun} alt="weather" />
310-
</div>
324+
</span>
311325
<input
312326
type="checkbox"
313327
name="weather"

src/frontend/src/Components/Filters.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,17 @@ button.btn.open-filters {
7777
& + .filter-item {
7878
margin-top: 8px;
7979
}
80-
80+
8181
&--closures {
8282
svg {
8383
font-size: 1.25rem;
8484
}
8585
}
8686

8787
label {
88+
display: flex;
89+
align-items: center;
90+
8891
&:hover {
8992
cursor: pointer;
9093
text-decoration: underline;
@@ -156,7 +159,9 @@ button.btn.open-filters {
156159
}
157160

158161
input {
159-
display: none;
162+
position: absolute;
163+
z-index: -1;
164+
margin-left: 10px;
160165
}
161166

162167
.tooltip-info {

src/frontend/src/styles/bootstrap-customizations.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ $danger: $Error;
103103
}
104104

105105
// Tooltip
106-
.tooltip.show {
107-
margin-bottom: 4px;
108-
opacity: 1;
106+
.tooltip {
109107

110108
.tooltip-inner {
111109
width: 256px;
@@ -118,4 +116,9 @@ $danger: $Error;
118116
margin-bottom: 0;
119117
}
120118
}
119+
120+
&.show {
121+
margin-bottom: 4px;
122+
opacity: 1;
123+
}
121124
}

0 commit comments

Comments
 (0)