-
Notifications
You must be signed in to change notification settings - Fork 697
Add support for custom icons in resources beyond FluentUI icon names #11863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: adamint <[email protected]>
Co-authored-by: adamint <[email protected]>
{ | ||
ArgumentException.ThrowIfNullOrWhiteSpace(customIconData); | ||
CustomIconData = customIconData; | ||
IconName = iconName ?? "CustomIcon"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to empty string in commit 6ce6e93.
/// - Raw SVG content (e.g., "<svg...>...</svg>") | ||
/// - A data URI (e.g., "data:image/png;base64,...") | ||
/// </remarks> | ||
public string? CustomIconData { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure this supports svgs, and update to include an svg example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated documentation with SVG example in commit 6ce6e93.
/// </code> | ||
/// </example> | ||
/// </remarks> | ||
public static IResourceBuilder<T> WithResourceIcon<T>(this IResourceBuilder<T> builder, string iconPath) where T : IResource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a function WithIconName already exists, don't duplicate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you must get rid of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the duplicate method in commit 6ce6e93.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in commit 6ce6e93.
/// </code> | ||
/// </example> | ||
/// </remarks> | ||
public static IResourceBuilder<T> WithResourceIcon<T>(this IResourceBuilder<T> builder, string iconData, string? iconName) where T : IResource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should also be named WithIconName and placed next to the existing method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you must rename this and move to the correct location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to WithIconName and moved next to existing method in commit 6ce6e93.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to WithIconName and moved in commit 6ce6e93.
/// <summary> | ||
/// Represents a custom icon using SVG content or data URI. | ||
/// </summary> | ||
internal sealed class CustomDataIcon : Icon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, you should use the CustomIcon
class that already exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you must use the existing custom icon class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created CustomResourceIcon class extending Icon base class in commit 6ce6e93.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created CustomResourceIcon class extending Icon base class in commit 6ce6e93. Named it CustomResourceIcon to avoid conflict with FluentUI's existing CustomIcon class.
/// <summary> | ||
/// Represents a custom icon using SVG content or data URI. | ||
/// </summary> | ||
internal sealed class CustomDataIcon : Icon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you must use the existing custom icon class
/// </code> | ||
/// </example> | ||
/// </remarks> | ||
public static IResourceBuilder<T> WithResourceIcon<T>(this IResourceBuilder<T> builder, string iconPath) where T : IResource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you must get rid of this
/// </code> | ||
/// </example> | ||
/// </remarks> | ||
public static IResourceBuilder<T> WithResourceIcon<T>(this IResourceBuilder<T> builder, string iconData, string? iconName) where T : IResource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you must rename this and move to the correct location
@copilot you need to make new changes based on the comments |
Co-authored-by: adamint <[email protected]>
Adding Custom Icon Support for Resources
Implements support for custom icons in Aspire resources, allowing hosting integrations to specify SVG content, data URIs, or file-based icons for display in the dashboard.
Implementation Complete ✅
ResourceIconAnnotation
to support custom icon data (SVG content or data URIs)ResourceSnapshot
to include custom icon dataResourceIconHelpers
to use custom icons when availableAPI Surface
Two methods for setting icons:
Changes from Feedback
WithResourceIcon(iconName, iconVariant)
- use existingWithIconName
insteadWithResourceIcon(iconData, iconName)
toWithIconName
and moved next to existing methodCustomResourceIcon
class extendingIcon
base class (FluentUI's CustomIcon caused conflict)WithResourceIcon(iconPath)
for file-based loadingBuild Status
✅ Aspire.Hosting builds successfully
✅ Aspire.Dashboard builds successfully
✅ Aspire.Hosting.Tests builds successfully
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.