All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- .htmlnanorc: Configure Parcel to not minify svg to fix
tree.render is not a function
build error, see https://stackoverflow.com/a/67133536/2145103; this error happened after the updates below.
- package-lock.json
- Merged multiple Dependabot PRs for package updates
- ran
npm audit fix
for a few vulnerability fixes
- description: Remove old local storage data if on user's device
- modules/localStorage.js: Add function to remove localstorage item
- modules/neighborhoodHandler.js: Get v2 data if exists in localstorage
- main.js:
- Delete old localstorage data if exists
- Set new localstorage data
- description: Refactor in new Open Baltimore neighborhoods data
- modules/xhrHandler.js: update API endpoint
- modules/geolocationHandler.js: use new data shape (the data is now based mostly on polygons, with some multipolygons; whereas previous data was only multipolygons)
- data/Neighborhoods.geojson: replace with new data
- data/formattedExample.json: removed this unnecessary file, since the new data allows for selecting which properties to include for each neighborhood boundary set. I only selected the name property, so the geojson file is much smaller and easier to wield and format in a text editor.
- branch: master
- description: fix overflow-x styling on the coordinates
- hood.css: change the
pre
'soverflow-x
value fromscroll
toauto
to hide the always-visible horizontal scroll bar on windows desktop
- branch: static
- description: copy static file (humans.txt) to build directory on build
- package.json:
- add
static
script that hard code copies humans.txt to dist/ - add
&& npm run static
tobuild
script
- add
- branch: master
- description: fix body svg color when setting theme via localStorage (v0.13.0 set the bgImage svg color to green even when light mode was set via localStorage)
- checkLocalTheme.js:
- add console.log to else statement
- import and use topography.js
- rename module initTheme.js
- main.js: import new initTheme.js module
- branch: modularize-localstorage
- description: refactor the use of localStorage throughout the app into a module that exports the needed functions that currently exist
- modules/localStorage.js: export check, get, and set
- main.js: import and use localStorage module
- checkLocalTheme.js: import and use localStorage module
- neighborhoodHandler.js: import and use localStorage module
- themeHandler.js: import and use localStorage module
- branch: persistent-color-theme
- description: persist the user's color theme selection in localstorage
- modules/checkLocalTheme.js: sets theme class on body if localStorage.THEME exists
- modules/themeHandler.js: sets localStorage.THEME on click
- main.js: import checkLocalTheme.js (in the way where it's never used/called outside of the import)
- branch: master
- description: update dependency version for security fix via github dependabot
- package-lock.json: bump serialize-to-js to v3.0.1
- branch: localstorage
- description: cache city data via localStorage
- modules/geolocationHandler.js
- refactor geolocation logic from main.js into its own module
- make the default export function accept a data object so that its parent can pass data to this module
- use es6 object destructuring to create locally-scoped variables from the passed in data object
- this is my first example of creating my own front end framework-like functionality of passing props to a child component 🎉
- modules/storageAvailable.js: create modult to test for
Window.localStorage
availability via MDN docs - modules/themeHandler.js
- refactor all the logic that handles theme toggling to its own module
- this module doesn't export anything, so it's like main.js just imports the whole file as is on
import themeHandler from './themehandler.js'
, since I never callthemeHandler()
as a function
- modules/xhrHandler.js
- refactor all the xhr logic to its own module
- this module calls the
neighborhoodHandler
module in thexhr.onload
statement- data needs to be passed to neighborhoodHandler. Since
xhr.onload = neighborhoodHandler
doesn't work when the callback is written as a called function (ie:xhr.onload = neighborhoodHandler()
), I add a new property onto the xhr object with the data that the sub module needs so the sub module can access the data.- The sub module will receive the xhr object without me explicitly passing the object to it (via the internal workings of a XMLHttpRequest).
- this way, the sub module can call
this.setLocalStorage
to get access to thesetLocalStorage
argument that was passed to the xhrHandler.
- data needs to be passed to neighborhoodHandler. Since
- modules/neighborhoodHandler.js
- refactor the neighborhood handling logic into its own module
- this is where
Window.localStorage
is set- the
NEIGHBORHOODS
data variable is now defined either from the xhr or from localStorage - if
localStorage.NEIGHBORHOODS
does not already exist, the module sets a NEIGHBORHOODS key onto localStorage with a value of the fetched data via the xhr
- the
- main.js
- refactor around the use of sub modules
- the flow is now:
- if localStorage is available, but the Baltimore open data is not already available in localStorage, the xhrHandler gets the data, and passes it off to the neighborhoodHandler which updates the DOM and writes the data to localStorage.NEIGHBORHOODS
- if localeStorage is available and localStorage.NEIGHBORHOODS exists, the neighborhoodHandler is called to update the DOM
- if localStorage is not available, the xhrHandler is called to fetch the data, and the neighborhoodsHandler then updates the DOM without writing the data to localStorage
- branch: master
- description: Add 'Baltimore' to the url encoded wikipedia search query
- main.js:
- add ', Baltimore' to the query string,
- url encode the comma char,
- rename the encoding function
- branch: master
- description: Fix out of town error alert
- main.js: test for
HOOD
as an empty array in a better way, update the alert message
- branch: error-handling
- description:
- provide error messages to user when
- JavaScript is disabled
- your browser doesn't support geolocation
- your os appears to have disabled location services for your browser
- you appear to be outside the city of Baltimore
- provide error messages to user when
- index.html: Add
<noscript>
- main.js:
- Check for geo navigator feature
- if no self coordinates return, throw error
- if coords are not found in any Bmore neighborhood, throw outside city error
- branch: topography-bg
- description: Add a svg background to the body via Hero Patterns
- use the Topography pattern, adapted for my design
- dynamically set the svg's fill color based on app theme
- topography.js: create es6 module that exports a function that returns a string representing a css background-image url of a data encoded svg 🎉
- main.js
- import { dataImageUrl } from topography.js
- set body.style.backgroundImage to default dark mode
- update body.style.backgroundImage on color mode toggle click
- branch: inline-css
- description:
- refactor the css from inlined in the source index.html to an external css file to be inlined into the built index.html. This was spawned because I didn't like html being the project's main language as depicted via github. The reason the html file is so large is because of the css. So extracting it out to its own file will change that. For perf reasons, I'm going to inline the css into the built index.html file that is served via netlify.
- the effect of using this inliner plugin also inlines the JS, so that the app is wholy contained in the built index.html file. I'll have to compare the fully served netlify files (ie: the state of bmore.space after merging this branch with master) to get the real numbers for before/after comparison
This analysis was committed after bumping the version to v0.8.0.
- index.html: 1.88kb transferred, 37ms
- main.{PARCEL STRING}.js: 2.54kb transferred, 85ms
total: 4.42kb transferred, ~122ms
- index.html: 3.94kb transferred, 39ms
total: 3.94kb transferred, ~39ms
Inlining external css and js FTW 🎉
By the way - now GitHub lists css as the main language associated with the project :)
- dev dependency: parcel-plugin-inliner
- css/hood.css: copy css from index.html
- index.html: remove css, link to hood.css
- package.json: add
--public-url .
to build script via the inliner plugin docs:
Very important!
You have to run the build step in Parcel with the --public-url . option for the inliner to actually find the files. If you leave this out the default is /, and the inliner won't be able to look for the files in the right location.
Example:
parcel build app/index.html --public-url .
- branch: color-themes
- description: Make a button to change the color theme
- index.html: Add button w/ svg via jxnblk
- main.js: Add color theme selection logic
- branch: responsive
- description: Add responsive design
- index.html: Add responsive styles to all UI
- branch: master
- description: Update UI design
- readme: check some todos
- index.html
- decrease
--shadow-thickness
for neighborhood name - removed the self-referential link at the top of the document
- added a wrapper around the neighborhood text for adding some emphasis on the app's punchline. make the wrapper an anchor so the hood name's box-shadow remains only as wide as the name text
- set neighborhood colors according to the theme
- decrease
- main.js:
- implement new neighborhood wrapper logic
- branch: basic styling
- description:
- update styling
- update markup
- update app logic accordingly
- humans.text
- index.html
- add style tag to head
- add metadata in head
- add footer
- update markup
- main.js
- update logic according to new markup and class names
- animate the rendering of neighborhood name and coordinates
- copy the coordinates on click (only works in FF, chrome, android, opera)
- make the neighborhood name into a link that searches wikipedia for the neighborhood, often leading directly to the neighborhood's wiki page
- css/hood.css - deleted in favor of writing styles in index.html head
- branch: d3
- description: Import only
polygonContains
from d3-polygon to decrease bundle size
- main.js: Refactor import and usage of d3-polygon
This decreased the netlify-served js bundle from 2.46kb transferred to 2.30kb transferred 🎉
- branch: master
- description: experiment on js bundle delivery
- parcel as dev-dependency
- d3-polygon as dependency
- index.html: Removed the d3-polygon import
- main.js: Import d3-polygon
- .gitignore: Ignore Parcel output
-
local serving via http-server of the v0.3.0 js bundles:
- d3-polygon: 1.33kb transferred
- main.js: 1.85kb transferred
-
w/ parcel that only bundles main.js
- d3-polygon: 1.33kb transferred
- main.{PARCEL STRING}.js: 2.20kb transferred
-
w/ parcel that bundles both d3-polygon and main.js
- main.{PARCEL STRING}.js: 5.71kb transferred
Fuck parcel in this case! I find it so wack that introducing parcel nearly doubles the size of the bundle, even if it decreases the js bundle downloads from 2 to 1.
Here's another question: which is worse, 2 download bundles, each < 2kb, or 1 download bundle of 5.71kb?
Let's experiment!
-
2 js bundle downloads, served via http-server, @ v0.3.0 state
- d3-polygon: 1.33kb transferred, 32ms, 147ms, 27ms, 84ms, 136ms
- main.js: 1.85kb transferred, 1ms, 1ms, 1ms, 1ms, 1ms
-
1 js bundle download, served via http-server, via parcel build
- main.{PARCEL STRING}.js: 5.71kb transferred, 1ms, 2ms, 1ms, 1ms, 1ms
The comparison of the two approaches is:
- the parcel route which yields a 5.71kb transferred bundle size, but only 1 bundle download, in only 1ms
- the index.html route which yields a 3.18kb transferred bundle size, but with 2 bundle downloads, in an average total time of 85ms
I'm inclined to decide not to use parcel, for the sake of prioritizing overall file size download on mobile over the matter of milliseconds that is at stake here.
However, I also want to use postcss in order to use autoprefixer for my future css work. Then there is also the future service worker implementation, which will be another js bundle. So perhaps I should go with parcel.
- branch: master
- description: wire up custom domain w/ https via netlify
- branch: master
- description: get d3-polygon working to filter neighborhoods by the user's geolocation
- changelog.md
- package-lock.json: via npm i, really just to be able to use my bump library which, as it currently stands, requires a lock file
- index.html: import d3-polygon library
- main.js:
- move all geolocation logic to the XHR.onload scope
- given the user's geolocation coords, filter the neighborhood multipolygons for the neighborhood that contains the coords.
- branch: master
- description: get basic functionality working
- get geolocation
- get neighborhood data from city
- data/
- index.html
- main.js
- readme.md