With GitHub Actions, I cut down CI runtimes for work projects to 3-4 minutes (with lower variance and more tests since March). I also noticed more and more Ember projects switching to GitHub Actions so I felt like a pioneer.
Today, I want to patch my original post and cover 3 new topics:
Hacktoberfest is coming up. If you’re new to open source contribution and unsure how to help, may I suggest refactoring code? You can provide a fresh perspective to unclear code and discover ways to leave it better than you found.
There are 3 refactoring techniques that I often practice:
Knowing how to apply just these 3 can get you far. I’ll explain what they mean and how I used them (or should have used them) in projects.
A few months ago, my team and I introduced ember-fill-up to our apps. It worked well but we noticed something strange. Percy snapshots that were taken at a mobile width would show ember-fill-up using the desktop breakpoint. They didn’t match what we were seeing on our browsers.
For a while, we ignored this issue because our CSS wasn’t great. We performed some tricks with flex and position that could have affected Percy snapshots. Guess what happened when we switched to grid and improved the document flow. We still saw incorrect Percy snapshots.
A powerful application of container queries is adaptive images. It’s about striking the balance between displaying an image that looks good (the larger the better) and one that loads fast (the smaller the better).
Currently, we are limited to srcset, which selects the optimal image based on the global screen size. This may work for splash images that cover the whole width, but what about images that we show in a partial area?
On Friday, I published my first addon. It’s called ember-container-query. Becoming an addon author was one of my goals for 2020, so I’m especially proud of it and hope that you will find a good use.
Container queries aren’t new in Ember. My addon is based on Chad Carbert’s ember-fill-up from 2019. That, in turn, credits Andrey Mikhaylov’s ember-element-query from 2017. I even found a blog post from 2015, by Greg Babiars!
Simplicity is what makes ember-container-query different from the previous tries. I combined 2 atomic solutions (modifiers, introduced in Ember Octane) to arrive at the atomic solution to container queries.
Because I practiced code composition and provided the minimum necessary API, the benefits are twofold. I have fewer code to maintain, while you have a choice to build your code on top of my addon or another with a similar API.
Testing is the second differentiator. With every code change, the CI checks that my addon and demo app work no matter the window size. Testing multiple windows is kinda important for container queries.
To my knowledge, no Ember app or addon has tried testing multiple windows and publicly released their solution. In the next article, I will go over how you can update the default test setup to achieve this feat.