c2r0b / tauri-plugin-context-menu

Native Context Menu in Tauri
https://crates.io/crates/tauri-plugin-context-menu
MIT License
117 stars 6 forks source link

[feat] Support for dynamic themes #25

Open ayangweb opened 1 month ago

ayangweb commented 1 month ago

Hey, thanks for such a great plugin, I'm currently using tauri-plugin-theme for dynamic theme switching, is it possible to provide a theme parameter to dynamically change the theme color of the menu?

c2r0b commented 1 month ago

Yes, that should be doable. I am going to work on it

ayangweb commented 1 month ago

Yes, that should be doable. I am going to work on it

Thank you, it's really great and I'm already looking forward to it!

c2r0b commented 1 month ago

The themes implementation for macOS should work now in the dev branch. I am trying to find a way to support Linux and Windows too.

To try out the macOS version you can import the plugin like this:

tauri-plugin-context-menu = { git = "https://github.com/c2r0b/tauri-plugin-context-menu", branch = "dev" }

You can then pass the option theme that is either light or dark to the plugin (updated docs here).

ayangweb commented 1 month ago

The themes implementation for macOS should work now in the dev branch. I am trying to find a way to support Linux and Windows too.

To try out the macOS version you can import the plugin like this:

tauri-plugin-context-menu = { git = "https://github.com/c2r0b/tauri-plugin-context-menu", branch = "dev" }

You can then pass the option theme that is either light or dark to the plugin (updated docs here).

Okay, thanks, that's really great!

ayangweb commented 1 month ago

The themes implementation for macOS should work now in the dev branch. I am trying to find a way to support Linux and Windows too.

To try out the macOS version you can import the plugin like this:

tauri-plugin-context-menu = { git = "https://github.com/c2r0b/tauri-plugin-context-menu", branch = "dev" }

You can then pass the option theme that is either light or dark to the plugin (updated docs here).

Works fine on MacOS 🥰

c2r0b commented 1 month ago

I went ahead and published v0.8 with MacOS theme option support.

Unfortunately, both Windows and Linux (Gtk) do not seem to have a way to handle theme changes for a single widget 😓 Instead, they always fall back to the global window theme.

tauri-plugin-theme changes the window theme, therefore it should change the menu theme automatically (on Windows and Linux). Please let me know if you have time to confirm this.

ayangweb commented 1 month ago

I went ahead and published v0.8 with MacOS theme option support.

Unfortunately, both Windows and Linux (Gtk) do not seem to have a way to handle theme changes for a single widget 😓 Instead, they always fall back to the global window theme.

tauri-plugin-theme changes the window theme, therefore it should change the menu theme automatically (on Windows and Linux). Please let me know if you have time to confirm this.

Windows:

image

Windows tests are not following the window theme, and Linux I don't have a test machine at the moment!

c2r0b commented 1 month ago

Thank you for the test. I am going to look into the Windows issue and update this thread

ayangweb commented 1 month ago

Thank you for the test. I am going to look into the Windows issue and update this thread

Well, thank you! 😁