Skip to main content

font-feature-settings vs font-variant

· 3 min read
Filip Tammergård
Software Engineer at Frilans Finans

We recently did some font feature tweaks at work. For one thing, we changed the appearance of 0 (number zero) to include a slash (like 0), to make it easier to differentiate from capital letter O. I learned a few things in the process that I'd like to share!

Slashed zeros

There are two main ways to configure slashed zeros.

  1. font-feature-settings: "zero" 1;
  2. font-variant: slashed-zero;

Physical properties to logical properties

· 9 min read
Filip Tammergård
Software Engineer at Frilans Finans

In the last months, I have been diving into the beautiful world of logical properties. The CSS spec has one sentence that I think describes what logical properties are in a nice way:

[Logical] properties are writing-mode relative equivalents of their corresponding physical properties.

Physical properties are simple to reason about, since they represent physical directions. Top, right, bottom and left are absolute directions. Left is always left—simple as that. Logical properties, on the other hand, are relative—the physical direction they correspond to varies.

As mentioned, the absolute nature of physical properties makes them simple to reason about. However, the absolute nature is also a limitation.

Building a generic table in React and TypeScript

· 4 min read
Filip Tammergård
Software Engineer at Frilans Finans

I want to take you with me on a journey of creating a table component that is generic and statically typed. Instead of just showing an end result, I want to try out different approaches that have different pitfalls, and find the solution that seems to be the best one.

As a starting point, we want to render a table with some country data:

CountryCapitalDate formatInternet TLD
SwedenStockholmYYYY-MM-DD.se
GermanyBerlinDD.MM.YYYY.de
BrazilBrasíliaDD/MM/YYYY.br

|| vs ??

· 2 min read
Filip Tammergård
Software Engineer at Frilans Finans

|| and ?? are similar, but there's some very important nuance. Take a look at this example:

const a = "" || "default value"
// > "default value"

const b = "" ?? "default value"
// > ""

Let me explain.

IP Location

· One min read
Filip Tammergård
Software Engineer at Frilans Finans

You live close to , right?

How did I know that? I used Ipapi! A neat API for getting the location of IP addresses, with 30,000 free lookups per month.

Custom hook: useClipboard

· One min read
Filip Tammergård
Software Engineer at Frilans Finans

Some time ago I wrote a blog post on how to access the clipboard with the navigator API. I decided to make it a custom hook to make it super easy to use. Before we go into code, let's try it out — click the button to read your clipboard:

Nothing to show...

Utility function: getRandomColor

· One min read
Filip Tammergård
Software Engineer at Frilans Finans

I've had some fun with random colors lately! To speed up development, I made a utility function for getting a random color. It's really simple:

export const getRandomColor = () => {
const red = Math.floor(Math.random() * 256)
const green = Math.floor(Math.random() * 256)
const blue = Math.floor(Math.random() * 256)

const color = `rgb(${red}, ${green}, ${blue})`

return color
}