Skip to content

Conversation

@AlexeyBarabash
Copy link
Collaborator

This repository has all icons set in svg format.
Now there is already android-icons command which is applied during build command and it generates Android xml drawable.

The moment here that Chromium still has bunch of icons which are still png bitmaps. If we need to replace them with own images, we should use also the same format to avoid bunch of direct gn/gni patches.

This PR adds command android-png-icons which converts svg into pngs of xxxhdpi/xxhdpi/xhdpi/hdpi/mdpi resolutions.

Usage: npm run android-png-icons -- <icon_name.svg> [new_color] [new_file_base_name]

Example

npm run android-png-icons -- product-private-window.svg   454746   incognito_simple.png

generates these files ready to replace the Chromium's pngs

drawable-hdpi/incognito_simple.png
drawable-mdpi/incognito_simple.png
drawable-xhdpi/incognito_simple.png
drawable-xxhdpi/incognito_simple.png
drawable-xxxhdpi/incognito_simple.png

@bsclifton
Copy link
Member

cc: @Olipro

Copy link
Collaborator

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great - once security has okay'd sharp lets land it!

@AlexeyBarabash AlexeyBarabash marked this pull request as draft September 10, 2025 10:21
@AlexeyBarabash AlexeyBarabash force-pushed the android-png-icons-command branch from 8ce6d41 to 7865dff Compare September 10, 2025 12:02
@github-actions
Copy link
Contributor

👋 Thanks for Submitting! This PR is available for preview at the link below.

✅ PR tip preview: https://1184.pr.nala.bravesoftware.com/
✅ Commit preview: https://1184.pr.nala.bravesoftware.com/commit-7865dff8a6c2409253dd62a3c945b76134006ac8/

- ./tokens/css/variables-android.old.css: 7390 bytes
+ ./tokens/css/variables-android.css: 7390 bytes
---
- ./tokens/css/variables-browser.old.css: 6644 bytes
+ ./tokens/css/variables-browser.css: 6644 bytes
---
- ./tokens/css/variables-ios.old.css: 8180 bytes
+ ./tokens/css/variables-ios.css: 8180 bytes
---
- ./tokens/css/variables-marketing.old.css: 13501 bytes
+ ./tokens/css/variables-marketing.css: 13501 bytes
---
- ./tokens/css/variables-news.old.css: 526 bytes
+ ./tokens/css/variables-news.css: 526 bytes
---
- ./tokens/css/variables-newtab.old.css: 1933 bytes
+ ./tokens/css/variables-newtab.css: 1933 bytes
---
- ./tokens/css/variables-search.old.css: 2409 bytes
+ ./tokens/css/variables-search.css: 2409 bytes
---
- ./tokens/css/variables-web3.old.css: 893 bytes
+ ./tokens/css/variables-web3.css: 893 bytes
---
- ./tokens/css/variables.old.css: 124825 bytes
+ ./tokens/css/variables.css: 124825 bytes
Variables Diff: variables-android.diff
--- ./tokens/css/variables-android.old.css	2025-09-10 12:03:15.177357019 +0000
+++ ./tokens/css/variables-android.css	2025-09-10 12:02:38.317892103 +0000
@@ -1,6 +1,6 @@
 /**
  * Do not edit directly
- * Generated on Mon Sep 08 2025 21:39:49 GMT+0000 (Coordinated Universal Time)
+ * Generated on Wed Sep 10 2025 12:02:38 GMT+0000 (Coordinated Universal Time)
  */
 
 :root {
Variables Diff: variables-browser.diff
--- ./tokens/css/variables-browser.old.css	2025-09-10 12:03:15.588362169 +0000
+++ ./tokens/css/variables-browser.css	2025-09-10 12:02:38.306891960 +0000
@@ -1,6 +1,6 @@
 /**
  * Do not edit directly
- * Generated on Mon Sep 08 2025 21:39:49 GMT+0000 (Coordinated Universal Time)
+ * Generated on Wed Sep 10 2025 12:02:38 GMT+0000 (Coordinated Universal Time)
  */
 
 :root {
Variables Diff: variables-ios.diff
--- ./tokens/css/variables-ios.old.css	2025-09-10 12:03:15.821365084 +0000
+++ ./tokens/css/variables-ios.css	2025-09-10 12:02:38.332892299 +0000
@@ -1,6 +1,6 @@
 /**
  * Do not edit directly
- * Generated on Mon Sep 08 2025 21:39:49 GMT+0000 (Coordinated Universal Time)
+ * Generated on Wed Sep 10 2025 12:02:38 GMT+0000 (Coordinated Universal Time)
  */
 
 :root {
Variables Diff: variables-marketing.diff
--- ./tokens/css/variables-marketing.old.css	2025-09-10 12:03:16.067368167 +0000
+++ ./tokens/css/variables-marketing.css	2025-09-10 12:02:38.349892520 +0000
@@ -1,6 +1,6 @@
 /**
  * Do not edit directly
- * Generated on Mon Sep 08 2025 21:39:49 GMT+0000 (Coordinated Universal Time)
+ * Generated on Wed Sep 10 2025 12:02:38 GMT+0000 (Coordinated Universal Time)
  */
 
 :root {
Variables Diff: variables-news.diff
--- ./tokens/css/variables-news.old.css	2025-09-10 12:03:16.307371174 +0000
+++ ./tokens/css/variables-news.css	2025-09-10 12:02:38.382892951 +0000
@@ -1,6 +1,6 @@
 /**
  * Do not edit directly
- * Generated on Mon Sep 08 2025 21:39:49 GMT+0000 (Coordinated Universal Time)
+ * Generated on Wed Sep 10 2025 12:02:38 GMT+0000 (Coordinated Universal Time)
  */
 
 :root {
Variables Diff: variables-newtab.diff
--- ./tokens/css/variables-newtab.old.css	2025-09-10 12:03:16.522373868 +0000
+++ ./tokens/css/variables-newtab.css	2025-09-10 12:02:38.389893042 +0000
@@ -1,6 +1,6 @@
 /**
  * Do not edit directly
- * Generated on Mon Sep 08 2025 21:39:49 GMT+0000 (Coordinated Universal Time)
+ * Generated on Wed Sep 10 2025 12:02:38 GMT+0000 (Coordinated Universal Time)
  */
 
 :root {
Variables Diff: variables-search.diff
--- ./tokens/css/variables-search.old.css	2025-09-10 12:03:16.729376459 +0000
+++ ./tokens/css/variables-search.css	2025-09-10 12:02:38.377892886 +0000
@@ -1,6 +1,6 @@
 /**
  * Do not edit directly
- * Generated on Mon Sep 08 2025 21:39:49 GMT+0000 (Coordinated Universal Time)
+ * Generated on Wed Sep 10 2025 12:02:38 GMT+0000 (Coordinated Universal Time)
  */
 
 :root {
Variables Diff: variables-web3.diff
--- ./tokens/css/variables-web3.old.css	2025-09-10 12:03:16.842377876 +0000
+++ ./tokens/css/variables-web3.css	2025-09-10 12:02:38.393893094 +0000
@@ -1,6 +1,6 @@
 /**
  * Do not edit directly
- * Generated on Mon Sep 08 2025 21:39:49 GMT+0000 (Coordinated Universal Time)
+ * Generated on Wed Sep 10 2025 12:02:38 GMT+0000 (Coordinated Universal Time)
  */
 
 @media (prefers-color-scheme: light) {
Variables Diff: variables.diff
--- ./tokens/css/variables.old.css	2025-09-10 12:03:17.181382124 +0000
+++ ./tokens/css/variables.css	2025-09-10 12:02:38.177890277 +0000
@@ -1,6 +1,6 @@
 /**
  * Do not edit directly
- * Generated on Mon Sep 08 2025 21:39:49 GMT+0000 (Coordinated Universal Time)
+ * Generated on Wed Sep 10 2025 12:02:38 GMT+0000 (Coordinated Universal Time)
  */
 
 :root {

@AlexeyBarabash AlexeyBarabash marked this pull request as ready for review September 10, 2025 15:16
import path from 'path'
import sharp from 'sharp'

const ICONS_FOLDER = 'icons/'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, so this will only resolve when the script is run from the root dir of leo - I think the other scripts get away with this 'cause they're always run as part of the prepare script, but yours will end up being run by a target in brave-core.

We should make sure this path is relative to this script, rather than the CWD:

// something like this, I think
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
const iconsFolder = path.join(dirname, '..', '..', 'icons')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants