I needed to add this feature
(TODO: change link to blog link) to Quoted Replies and that required me to ’templatize’ svg pattern backgrounds.
By templatize, I mean generating mustache templates for svg images for easy color substitution. To explain further,
the image below is made up of 4 different colors but really, it’s just one main color and 3 variants of it.
I needed to replace the colors in the svg code with 4 variables and define how the variable were related. For example,
variable 1 = #291b2b,
variables 2 to 4 = variable 1 but with different lightness values on the hsl color scale.
The tool then generates a json representation of the image and its variables.
You might need to view the json in a json viewer to see how the colors are referenced.
I tried to do all of this manually but as you can imagine, it was super painful. From detecting the pattern’s constituent
colors and their formats (which are often different), to viewing the detected colors all at a glance and discerning which are related,
and finally working out how they’re related. I decided I was going to build a web app for to easen the process.
However, I didn’t know how to build web apps. Decided to take a react course on frontendmasters.com
and speak to a few of my React friends. After a couple of weeks, I gained some level of proficiency enough to automate the
flow I outlined above. But really, what gave me the confidence to start building ––after days of watching videos and boringly
coding along–– was this talk by Dan Abramov at React Conf ‘18
There really isn’t much to say here. The video below describes what it does.
Here’s a link to the repo, in case you’re wondering what my code looks like or would like to comment/contribute.
My Experience with React
Going to do bullet points here
It didn’t take too long to gain some level of proficiency
To my utter surprise, I absolutely enjoyed working with JavaScript and React. The only thing I missed was the presence of a robust standard library like we have on Kotlin and Java, but lodash came to the rescue here.
Developing with React is blazingly fast compared to working with native Android where you have to wait for builds to compile and install on a device just to view changes. Super green with envy about this one!
Another thing that surprised me was how much I enjoyed working without strong types. The flexibility was somewhat refreshing. Or could it be that I didn’t miss types because it was a small project? 🤔
There are lots of similarities between modern native app development and web app development with React. That helped me a lot. For example, even though I didn’t use Redux, I immediately understood it when I came across it.
The docs are amazing especially Mozilla’s MDN and the official React docs.
The tooling is also great. Shout out to the Chrome React Dev Tools and IntelliJ React Plugin