From 1a1c19e26a8eb28969c26ffecd49d08053654840 Mon Sep 17 00:00:00 2001
From: uncenter <47499684+uncenter@users.noreply.github.com>
Date: Mon, 15 Apr 2024 19:43:57 -0400
Subject: [PATCH] refactor(tree-wide): prefer simpler method for theming
`
` elements (#820)
Co-authored-by: Gen <29279972+GenShibe@users.noreply.github.com>
---
docs/tips-and-tricks.md | 14 +++--------
styles/chatgpt/catppuccin.user.css | 20 +++------------
styles/duckduckgo/catppuccin.user.css | 19 +++------------
styles/github/catppuccin.user.css | 15 ++----------
styles/instagram/catppuccin.user.css | 13 ++--------
styles/nextjs/catppuccin.user.css | 12 ++-------
styles/npm/catppuccin.user.css | 35 +++++----------------------
styles/pypi/catppuccin.user.css | 32 +++---------------------
styles/trinket/catppuccin.user.css | 15 ++----------
styles/youtube/catppuccin.user.css | 6 +----
10 files changed, 29 insertions(+), 152 deletions(-)
diff --git a/docs/tips-and-tricks.md b/docs/tips-and-tricks.md
index 54668072..080fcda7 100644
--- a/docs/tips-and-tricks.md
+++ b/docs/tips-and-tricks.md
@@ -109,16 +109,12 @@ There is only one color used, `fill="#1D9BF0"`. That hex code is a shade of blue
#### `
` elements
-Theming an inline image is a bit tricky. We have to first hide the original image with `height: 0 !important;` and `width: 0 !important;`, after which we can apply our own background image. Importantly, you must determine the height and width of the original image. You will need the width and height to A) adjust the SVG to that size (you can use https://www.svgviewer.dev/ for this), and B) the `padding-left: _px !important;` and `padding-right: _px !important` also need to use those dimensions. You can use the template below for this.
+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.
```less
img.xyz {
@svg: escape("");
- height: 0 !important;
- width: 0 !important;
- padding-left: px !important;
- padding-top: px !important;
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
```
@@ -129,11 +125,7 @@ img.twitter-icon {
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 24px !important;
- padding-top: 24px !important;
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
```
diff --git a/styles/chatgpt/catppuccin.user.css b/styles/chatgpt/catppuccin.user.css
index 63062037..ea491018 100644
--- a/styles/chatgpt/catppuccin.user.css
+++ b/styles/chatgpt/catppuccin.user.css
@@ -1001,12 +1001,7 @@
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 32px !important;
- padding-top: 32px !important;
- margin-top: 32px;
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
.title {
@@ -1053,31 +1048,24 @@
@orange: mix(@red, @yellow);
- .social-logo {
- height: 0 !important;
- width: 0 !important;
- padding-left: 20px !important;
- padding-top: 20px !important;
- }
-
img[alt="Google logo"] {
@svg: escape(
''
);
- background-image: url("data:image/svg+xml;charset=utf-8,@{svg}");
+ content: url("data:image/svg+xml,@{svg}");
}
img[alt="Microsoft logo"] {
@svg: escape(
''
);
- background-image: url("data:image/svg+xml;charset=utf-8,@{svg}");
+ content: url("data:image/svg+xml,@{svg}");
}
img[alt="Apple logo"] {
@svg: escape(
''
);
- background-image: url("data:image/svg+xml;charset=utf-8,@{svg}");
+ content: url("data:image/svg+xml,@{svg}");
}
}
}
diff --git a/styles/duckduckgo/catppuccin.user.css b/styles/duckduckgo/catppuccin.user.css
index 08dedbbf..50b07f29 100644
--- a/styles/duckduckgo/catppuccin.user.css
+++ b/styles/duckduckgo/catppuccin.user.css
@@ -348,11 +348,7 @@
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 10px !important;
- padding-top: 10px !important;
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
//calculator
@@ -786,11 +782,7 @@
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 32px !important;
- padding-top: 32px !important;
- background-image: url("data:image/svg+xml,@{svg}") !important;
+ content: url("data:image/svg+xml,@{svg}");
}
//duckduckgo search too long icon
@@ -810,16 +802,11 @@
}
// ddg header logo
- .header_headerLeft__gTUAg,
.header_logoImg__PFezv {
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 157px !important;
- padding-top: 44px !important;
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
}
}
diff --git a/styles/github/catppuccin.user.css b/styles/github/catppuccin.user.css
index 5d6d86e0..d26d37cd 100644
--- a/styles/github/catppuccin.user.css
+++ b/styles/github/catppuccin.user.css
@@ -515,20 +515,9 @@
background-image: url("data:image/svg+xml,@{svg}");
}
- picture:has(img[src="https://github.githubassets.com/assets/mona-loading-default-c3c7aad1282f.gif"])
+ img[src="https://github.githubassets.com/assets/mona-loading-default-c3c7aad1282f.gif"]
{
- justify-content: center;
- display: flex;
-
- img {
- display: block;
- box-sizing: border-box;
- background: url("https://giscus.catppuccin.com/assets/loading_48x48.gif")
- no-repeat;
- width: 48px;
- height: 48px;
- padding-left: 48px;
- }
+ content: url("https://giscus.catppuccin.com/assets/loading_48x48.gif");
}
/* Header when logged out */
diff --git a/styles/instagram/catppuccin.user.css b/styles/instagram/catppuccin.user.css
index 37abe517..b9b43e20 100644
--- a/styles/instagram/catppuccin.user.css
+++ b/styles/instagram/catppuccin.user.css
@@ -552,23 +552,14 @@
@svg: escape(
''
);
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
- height: 0 !important;
- width: 0 !important;
- padding-left: 76px !important;
- padding-top: 76px !important;
- background-size: unset !important;
+ content: url("data:image/svg+xml,@{svg}");
}
/* "All caught up" icon */
img[src="/images/instagram/xig/web/illo-confirm-refresh-light.png"] {
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 96px !important;
- padding-top: 96px !important;
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
[style*='background-image: url("https://static.cdninstagram.com/rsrc.php/v3/y4/r/ewSyA8IItw_.png")']
diff --git a/styles/nextjs/catppuccin.user.css b/styles/nextjs/catppuccin.user.css
index 404e07ee..ea3b50e4 100644
--- a/styles/nextjs/catppuccin.user.css
+++ b/styles/nextjs/catppuccin.user.css
@@ -245,21 +245,13 @@
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 16px !important;
- padding-top: 16px !important;
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
img[alt="X Logo"] {
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 16px !important;
- padding-top: 16px !important;
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
}
}
diff --git a/styles/npm/catppuccin.user.css b/styles/npm/catppuccin.user.css
index 49b82c7f..96a7cbc8 100644
--- a/styles/npm/catppuccin.user.css
+++ b/styles/npm/catppuccin.user.css
@@ -375,12 +375,7 @@
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 20px;
- margin-left: 1rem;
- padding-top: 20px;
- background: url("data:image/svg+xml,@{svg}") no-repeat;
+ content: url("data:image/svg+xml,@{svg}");
}
/* Navigation tabs */
@@ -538,14 +533,10 @@
/* Back button inside file */
._450b46e9 {
- height: 0 !important;
- width: 0 !important;
- padding-top: 16px;
- padding-left: 12px;
@svg: escape(
''
);
- background: url("data:image/svg+xml,@{svg}") no-repeat;
+ content: url("data:image/svg+xml,@{svg}");
}
ul li {
@@ -556,8 +547,6 @@
}
img {
- height: 0 !important;
- width: 0 !important;
@folder: escape(
''
);
@@ -565,14 +554,10 @@
''
);
&._1528cda6 {
- padding-top: 25px;
- padding-left: 20px;
- background: url("data:image/svg+xml,@{folder}") no-repeat;
+ content: url("data:image/svg+xml,@{folder}");
}
&._7ec1ed32 {
- padding-top: 22.5px;
- padding-left: 18px;
- background: url("data:image/svg+xml,@{file}") no-repeat;
+ content: url("data:image/svg+xml,@{file}");
}
}
}
@@ -889,11 +874,7 @@
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 42px;
- padding-top: 42px;
- background: url("data:image/svg+xml,@{svg}") no-repeat;
+ content: url("data:image/svg+xml,@{svg}");
}
/* Step 2: invite members */
img[src="https://static-production.npmjs.com/d6654c911c7cf2159948148754c95bb6.svg"]
@@ -901,11 +882,7 @@
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 42px;
- padding-top: 42px;
- background: url("data:image/svg+xml,@{svg}") no-repeat;
+ content: url("data:image/svg+xml,@{svg}");
}
div:has(> form[action="/org/create"]) {
color: @text;
diff --git a/styles/pypi/catppuccin.user.css b/styles/pypi/catppuccin.user.css
index 6f29afe6..1ebfec9f 100644
--- a/styles/pypi/catppuccin.user.css
+++ b/styles/pypi/catppuccin.user.css
@@ -945,26 +945,14 @@
@svg: escape(
''
);
-
- height: 0 !important;
- width: 0 !important;
- padding-left: 66px !important;
- padding-top: 58px !important;
- background-image: url("data:image/svg+xml;utf8,@{svg}") !important;
- background-repeat: no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
.about-pypi__logo img {
@svg: escape(
''
);
-
- height: 0 !important;
- width: 0 !important;
- padding-left: 248px !important;
- padding-top: 186px !important;
- background-image: url("data:image/svg+xml;utf8,@{svg}") !important;
- background-repeat: no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
.-js-white-cube,
@@ -972,27 +960,15 @@
@svg: escape(
''
);
-
- height: 0 !important;
- padding-left: 34px !important;
- padding-top: 32px !important;
- background-image: url("data:image/svg+xml;utf8,@{svg}") !important;
- background-repeat: no-repeat !important;
- background-position: center !important;
+ content: url("data:image/svg+xml,@{svg}");
}
.release__node[src*="blue"] {
@svg: escape(
''
);
-
- height: 0 !important;
- padding-left: 34px !important;
- padding-top: 32px !important;
+ content: url("data:image/svg+xml,@{svg}");
background-color: @mantle !important;
- background-image: url("data:image/svg+xml;utf8,@{svg}") !important;
- background-repeat: no-repeat !important;
- background-position: center !important;
}
}
}
diff --git a/styles/trinket/catppuccin.user.css b/styles/trinket/catppuccin.user.css
index 684776f6..7dc82549 100644
--- a/styles/trinket/catppuccin.user.css
+++ b/styles/trinket/catppuccin.user.css
@@ -1362,11 +1362,7 @@
@svg: escape(
''
);
-
- width: 0 !important;
- height: 0 !important;
- background-image: url("data:image/svg+xml;utf8,@{svg}") !important;
- background-repeat: no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
img[src$="trinket-logo.png"] {
@@ -1383,14 +1379,7 @@
@svg: escape(
''
);
-
- width: 0 !important;
- height: 0 !important;
- padding-left: 1.5em !important;
- padding-top: 1.5em !important;
- background-image: url("data:image/svg+xml;utf8,@{svg}") !important;
- background-repeat: no-repeat !important;
- background-position-y: center;
+ content: url("data:image/svg+xml,@{svg}");
}
#dragbar {
diff --git a/styles/youtube/catppuccin.user.css b/styles/youtube/catppuccin.user.css
index 65e5621a..d89c71bd 100644
--- a/styles/youtube/catppuccin.user.css
+++ b/styles/youtube/catppuccin.user.css
@@ -978,11 +978,7 @@
@svg: escape(
''
);
- height: 0 !important;
- width: 0 !important;
- padding-left: 98px !important;
- padding-top: 24px !important;
- background: url("data:image/svg+xml,@{svg}") no-repeat !important;
+ content: url("data:image/svg+xml,@{svg}");
}
&,