Skip to content

feat: add support for .svg file paths as Action icon#219

Merged
tlambert03 merged 9 commits intopyapp-kit:mainfrom
dalthviz:issue_217
Sep 12, 2024
Merged

feat: add support for .svg file paths as Action icon#219
tlambert03 merged 9 commits intopyapp-kit:mainfrom
dalthviz:issue_217

Conversation

@dalthviz
Copy link
Copy Markdown
Collaborator

@dalthviz dalthviz commented Aug 15, 2024

Closes #217
Related to napari/napari#7133

A preview from the demo modification:

about_icon_svg

@dalthviz dalthviz changed the title feat: add support for '.svg' file paths as action icons feat: add support for .svg file paths as action icons Aug 15, 2024
@dalthviz dalthviz changed the title feat: add support for .svg file paths as action icons feat: add support for .svg file paths as Action icon Aug 15, 2024
@dalthviz dalthviz changed the title feat: add support for .svg file paths as Action icon feat: add support for .svg file paths as Action icon [WIP] Aug 15, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ce15a34) to head (adffa9b).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #219   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           31        31           
  Lines         1875      1878    +3     
=========================================
+ Hits          1875      1878    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dalthviz dalthviz changed the title feat: add support for .svg file paths as Action icon [WIP] feat: add support for .svg file paths as Action icon Aug 16, 2024
@dalthviz dalthviz marked this pull request as ready for review August 16, 2024 16:40
@DragaDoncila
Copy link
Copy Markdown
Contributor

@tlambert03 what do you think of this PR?

@tlambert03
Copy link
Copy Markdown
Member

I'm out of the country for another few days, sorry for the delay

@DragaDoncila
Copy link
Copy Markdown
Contributor

I'm out of the country for another few days, sorry for the delay

no worries at all! Just wanted to ping in case it got forgotten 😊

),
types.Action(
id="about",
icon=f"file://{ABOUT_ICON_PATH}",
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hi there, thank you for pushing foward this! Quick comment, I think there is a need (at least on Windows) to put three slashes here (///) otherwise no icon is shown:

imagen

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i see, apologies for changing that! I thought the third slash was an oversight (since there's also a preceding slash for posix systems in ABOUT_ICON_PATH).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh I see, maybe we should show over the example the need to handle the slashes for file: depending on the platform? Checking https://en.wikipedia.org/wiki/File_URI_scheme I see that on Unix the preceding slash is taken into account for the three slashes the URI has before the actual file path 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Based on the fact that your previous version was working fine (and tests are passing again after reverting it), it appears to be fine for posix systems to have four slashes (file:////Users...). So I'm fine leaving it as is and not doing anything platform specific. But I suppose we could add a note somewhere? Your call, I'm fine just merging

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Woah I said "fine" a lot in there 😅

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Over the last commit adffa9b I added some info about the possibility to use a .svg file path over the Action icon field with a note just in case. Seems like an approapiate place but let me know what you think!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

perfect!

@tlambert03
Copy link
Copy Markdown
Member

all set for merge?

@dalthviz
Copy link
Copy Markdown
Collaborator Author

Yep 👍

@tlambert03 tlambert03 merged commit 934c56a into pyapp-kit:main Sep 12, 2024
@tlambert03 tlambert03 added the enhancement New feature or request label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

feat/question: usage of .svg sources directly as Actions icons and how to customize Action's icon color?

3 participants