Uncategorized

Lab 5: Bridge Troll

This weeks lab was quite interesting, it required a bit more coding and thinking. Our teacher decided to build a small project that will require us to fix or add a feature to project by first forking it and creating our own branch.

About The Project

Bridge Troll is a small app that shows us where bridges are located in Ontario. Leaflet is the map library that used in the project. Of course, Leaflet is an open source javascript library. I have used it before in one of my personal projects it’s a really cool and well built library in my opinion.

Screenshot from 2018-04-24 14-39-12

Required Feature

So, what was required from us was to implement a dark mode based on the sunlight using a library called suncalc. The suncalc library allows us to figure out if it’s currently sunset or sunrise. The most common approach for this lab was to first figure out how to get the sunrise/sunset time based on geolocation, and the next step was to get a dark theme for the map and toggle between a bright map and a dark map.

My Solution

Because I didn’t want to go through the trouble going through all the themes I decided to make use of the CSS brightness property. I would just toggle the value between 100% and %50 to create a bright an dark mood. Here is the code for the solution. Below is an image of the end result.

Screenshot from 2018-04-24 15-23-38

Its really nice to know that a library such as suncalc exist! I might use in the future or even build a version for Haskell, it didn’t seem too big just 300 lines of code!

 

Leave a comment