Using Font Files Downloaded From Google Font

When you download a font family from Google Fonts, it contains multiple files, each corresponding to a different style. It is common to just import a regular 400 with the font face declaration.

The better practice is to use the method called style linking. In @font-face, we can use the same font-family name for all the styles that you want to use. Then, you set the weight and style for each as the same as the style itself.

CSS will access each font file by matching the style and weight. This is called style linking. The important thing here is that the order of the css properties has to match with the exact same order as in the font-face declaration.

Font can be confusing because there are a few different ways to achieve this. Style linking is probably the best way because it is supported by most browsers. Generally speaking, the best practice is to have font files for all the weights that you use in your design system and link them by using style linking. Then, each font will use the specific files. Google Font only gives you the truetype format. If you want to support all the browsers, you need to have different file formats, too. If you need further information about the file types, this CSS-Tricks blog is great.

Front-End
TypeScript: type aliases to check type equality

This post is to analyse how the type equality check by using type aliases proposed by Matt Pocock in his twitter post. These type aliases allow us to elegantly express type equality checks in unit tests. All we need to do is to pass the output and expected types in …

Front-End
Fixing it.only type error in Jest

If you are getting a type error with it.only in Jest, it could be due to incorrect TypeScript typings or incompatible versions of Jest and TypeScript. To resolve this issue, you can try the following steps: Make sure you have the latest versions of Jest and its TypeScript typings installed …

Front-End
yup conditional validation example

Here’s an example of a Yup validation logic where the first input field is optional but, if filled, it must contain only alphabetic characters, and the second input field is required: import * as Yup from “yup”; const validationSchema = Yup.object().shape({ firstField: Yup.string().matches(/^[A-Za-z]*$/, { message: “First field must contain only …