From 4173b56b6363be1fdfe9d34e7320656a82483172 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:03:36 -0400 Subject: [PATCH] docs(tips-and-tricks): improve image theming tips (#1152) --- docs/tips-and-tricks.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/tips-and-tricks.md b/docs/tips-and-tricks.md index 50fe0f92..d58475fe 100644 --- a/docs/tips-and-tricks.md +++ b/docs/tips-and-tricks.md @@ -72,9 +72,9 @@ The command above is converting the input image `old-image.png` to the output fi ### How do I theme images and SVGs? -#### SVG background images +#### SVGs as `background-image`s -Often, websites will use a CSS rule to apply an SVG as a `background-image` (typically for icons). We will refer to these as "external SVGs" throughout the rest of this guide. Below is an example of what a rule for an external SVG could look like. +Websites will sometimes use the `background-image` CSS property to apply an SVG, often for icons. We will refer to these as "external SVGs" throughout the rest of this guide, as the SVGs are usually at a different URL and linked to with [`url()`](https://developer.mozilla.org/en-US/docs/Web/CSS/url). Below is an example of what a rule for an external SVG could look like. ```css .xyz { @@ -91,13 +91,16 @@ The easiest way to theme external SVGs is to visit the URL of the SVG and paste } ``` +> [!NOTE] +> The `Invalid % without number` error may appear if you have not done the following step. Make sure to add/replace an interpolated color in the SVG contents (as is detailed below) for this error to go away. + Now, replace any colors in the SVG with their respective Catppuccin variants. For example, take the following SVG icon for Twitter: ```xml ``` -There is only one color used, `fill="#1D9BF0"`. That hex code is a shade of blue, so we can replace it with the `@blue` color using the `fill="@{}"` syntax. +There is only one color used, `fill="#1D9BF0"`. That hex code is a shade of blue, so we can replace it with the `@blue` color using the `fill="@{}"` syntax ([variable interpolation](https://lesscss.org/features/#variables-feature-variable-interpolation)). ```less .twitter-icon { @@ -110,7 +113,7 @@ There is only one color used, `fill="#1D9BF0"`. That hex code is a shade of blue #### `` elements -Theming an inline image is similar, but we use `content` to cover up the original image with our new one. You only need to update the SVG inside of the `escape('')` and you're all set. +Theming an inline image is similar, but `content` is used instead of `background-image` to cover up the original image with our new one. As with the previous tip for `background-image`, you only need to update the SVG inside of the `escape('')` (see above for details). ```less img.xyz {