Container Queries: Reimagined

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.

In the meantime, I encourage you to learn what container queries can do for you and get inspiration from my demo app. The code is publicly available on GitHub.

CI with GitHub Actions for Ember Apps

Lately I’ve been working on Ember Music, an app that I can use as a playground to test addons and ideas in Ember. When I need to write a blog post, I can reach for this app instead of designing a new one each time. Since the app will grow over time, I wanted to introduce continuous integration (CI) and continuous deployment early.

Heroku Dashboard makes deploying code on GitHub simple. From the Deploy tab, you select GitHub, find your repo, then check “Wait for CI to pass before deploy.”

Heroku makes deploying code on GitHub simple.
Heroku makes deploying code on GitHub simple.

For continuous integration, I tried out GitHub Actions since it is free (there are limits to minutes and storage for private repos) and my code is on GitHub. I also wanted to find an alternative to Codeship Pro that I use for work. One app has about 150 tests, but CI time wildly varies between 3 and 15 minutes. Because ten minutes is how long CI took for a larger app that I had worked on, I haven’t been content.

With GitHub Actions, I was able to make a workflow that did everything I want:

  • Set operating system and Node version
  • Cache ​dependencies (avoid yarn install)
  • Lint files and dependencies
  • Run tests separately from linting
  • Split tests and run in parallel
  • Take Percy snapshots in parallel
  • Be cost effective

In this blog post, I will share my workflow because there is a high chance that you, too, want to solve the problems listed above. Rather than dumping the entire workflow on you, I will start with a simple one and let it organically grow. Throughout, I will assume that you use yarn to manage packages. If you use npm, please check the GitHub Gist at the end to see the differences.

Continue reading “CI with GitHub Actions for Ember Apps”

Prototyping Apps with Ember Octane: Behind the Scenes

On Saturday, I presented Ember Octane to Austin Code Mentorship. I had been hesitant about organizing the workshop (what if no one shows up?). Thankfully, 6 people joined for the whole session, while some more stopped by. In one hour, we prototyped an e-commerce app where a user can view products before making a purchase decision.

Products page for an e-commerce app

This post primarily serves as a retro doc for myself, but also welcomes two audiences. If you are new to Ember and can follow a tutorial without guidance, you can skip to the end. There, you will find instructions and links to the base and finished projects. If you want to run a workshop or onboard a developer, what follows next is for you.

Continue reading “Prototyping Apps with Ember Octane: Behind the Scenes”

Finding Books for Prisoners

I had an interesting night from volunteering at Inside Books Project, the only books-to-prisoners program in Texas. Every month, the volunteers receive about 2,000 letters. For each letter, they find books that the person would enjoy and write a reply.

I started seeing parallels with what I do for work and became intrigued by 3 things: the abundance of math in finding books for prisoners, the absence of order and technology to help me find books, and the heuristics that I ended up using instead.

Continue reading “Finding Books for Prisoners”

Rewriting Apps in Ember Octane

Last Friday, Ember 3.15 was dubbed the Octane edition. To see how easy (and fun) writing an Octane app is, I spent the weekend rewriting my apps Ember Animated (v3.8) and Lights Out (v2.18). Let me share what I learned.

If you have tutorials and demo apps, I encourage you to rewrite them in Octane. You can publish both versions to help everyone understand how the programming model in Ember has evolved over time.

Continue reading “Rewriting Apps in Ember Octane”