Giter VIP home page Giter VIP logo

Comments (10)

AlexTorresDev avatar AlexTorresDev commented on May 12, 2024 1

The icon view is based on the new Microsoft Edge (Chromium), so you cannot remove the extra space left on the left side of the menu item. If you use a checkbox item, the icon is check.

Example

It is not possible to add fontawesome icons, as the variable for icon that provides electron is used. In any case, I'll check it out and be reporting the progress right here.

from custom-electron-titlebar.

yafp avatar yafp commented on May 12, 2024 1

It is not possible to add fontawesome icons, as the variable for icon that provides electron is used.

Thanks - so i was guessing right.

Having access to fontawesome would it make much easier to fill all those icons needed for a complex menu ... but i understand if that's not the project target.

In any case, I'll check it out and be reporting the progress right here.

So should i keep the issue open as you consider supporting it?

from custom-electron-titlebar.

janvorisek avatar janvorisek commented on May 12, 2024 1

I haven't tried it yet but you should be able to use fontawesome icons directly using their SVGs.

See: https://github.com/FortAwesome/Font-Awesome/tree/master/svgs

from custom-electron-titlebar.

yafp avatar yafp commented on May 12, 2024

Hi @janvorisek

I haven't tried it yet but you should be able to use fontawesome icons directly using their SVGs.

Seems like it doesnt work.

I did try with a classic image like in the example - that works

icon: __dirname + '/app/img/icon/icon.png',

Then i tried applying that to an fontawesome svg like that

icon: __dirname + '/node_modules/@fortawesome/fontawesome-free/svgs/regular/address-book.svg',

This throws no error, but the entire submenu entry is missing

So while my file menu containes

  • Settings
  • Separator
  • Exit

it then only showed

  • Separator
  • Exit

from custom-electron-titlebar.

janvorisek avatar janvorisek commented on May 12, 2024

@yafp That's strange. Can you check if SVGs are loading correctly in your app (webpack/rollup config)? It's still strange that the item is missing. I'd expect an error/empty image instead.

from custom-electron-titlebar.

janvorisek avatar janvorisek commented on May 12, 2024

@yafp Converting the icons you want into PNGs and including them in your app may be possible too. Brutal but could be a temporary solution 😄

from custom-electron-titlebar.

yafp avatar yafp commented on May 12, 2024

Oh, i have to correct myself.

Not only the 1 item is missing - instead it seems like my app is falling back to the electron default menu entries.

from custom-electron-titlebar.

janvorisek avatar janvorisek commented on May 12, 2024

I have to correct myself as well. I investigated electron menu a bit and the icon accepts NativeImage which cant be SVG according to the electron docs.

My current idea is to load the SVGs in my app main.ts using webpack and manually converting each into a NativeImage which can then be supplied directly to the MenuItem item prop. I'll share some sample code if I am successful 😄. I am also curious for any simpler solutions/examples.

from custom-electron-titlebar.

yafp avatar yafp commented on May 12, 2024

I have to correct myself as well. I investigated electron menu a bit and the icon accepts NativeImage which cant be SVG according to the electron docs.

Good catch, thanks @janvorisek

for the sake of completeness

While trying to use the .svg my error reporting using Sentry game me the following:

TypeError
Error processing argument at index 1, conversion failure from /home/foo/bar/app/img/address-book.svg

Array.forEach
Called from: electron/js2c/browser_init.js in Function../lib/browser/api/menu.js.Menu.buildFromTemplate
Array.forEach
Called from: electron/js2c/browser_init.js in Function../lib/browser/api/menu.js.Menu.buildFromTemplate
app:///main.js in createMenu at line 239:21

While i noticed no error output in the console.

No idea if it's possible to handle that better to prevent falling back to the default menu.

from custom-electron-titlebar.

yafp avatar yafp commented on May 12, 2024

to sum it up:

  • Using FontAwesome is not possible
  • Menu Icons (introduced with #43) can't be disabled

from custom-electron-titlebar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.