Skip to content

Conversation

@fortesp
Copy link
Collaborator

@fortesp fortesp commented Nov 19, 2025

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

#425

πŸ“ Checklist

  • I have linked an issue or discussion.
  • It's submitted to the main branch
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • I have updated the documentation accordingly.
  • All tests are passing
  • New/updated tests are included
  • I have updated the "upcoming" section inside docs/changelog.md explaining the changes I contributed

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

@fortesp fortesp linked an issue Nov 19, 2025 that may be closed by this pull request
@fortesp fortesp self-assigned this Nov 19, 2025
@fortesp fortesp requested a review from pennal November 19, 2025 10:52
@pennal pennal added this to the v5.2.0 milestone Nov 19, 2025

/**
* @since 1.0
* @since 5.2
Copy link
Collaborator

Choose a reason for hiding this comment

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

THe since indicates since when the component has been available. Pleas revert

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please check

*
* Icon library for this instance. Overrides the global default.
* - "material-icons" β†’ Material Icons
* - "material-icons" β†’ Material Icons
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove space

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please check

})
export class SixIcon {
/** Name of the icon, path to SVG file or a data image */
@Prop() src?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I already mentioned in #425 (comment)

Using src as the prop name for the input, in case when we are passing an icon name, makes no sense to me. I would separate the different types, meaning

  • src: SVG File or Data URL
  • name: Name of the icon => you can introduce this already, but keep the slot

If I put myself in the user's shoes, I find this to be a lot easier to understand.

You can then define a hierarchy, like src > name > slot

Copy link
Collaborator Author

@fortesp fortesp Nov 26, 2025

Choose a reason for hiding this comment

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

Well, i think it makes more sense than having prop name and prop src... how the users know which one takes priority? ... Just makes things more complicated than they should be. I will change it anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please check

* - <svg><use/></svg> is better for styling (e.g. fill: red), but slower at rendering.
* - <img> is better for HTTP caching, but you cannot style the internal SVG elements.
*/
@Prop({ reflect: true }) inlineSvg: boolean = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this really needed? What performance hit are talking about?

I would simply default to the <svg><use/></svg> since, as you mention, its better for styling

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As you can see there img is good for HTTP caching... you can in some instances visually see the difference rendering/loading the icons...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is however a caveat which you have to put id="img" inside your svg for it to work and properties inside svg have precedence i.e. if you have fill in some vector you cannot override it from outside.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure if there is a more elegant way to approach this... this is what i have at the moment.

Comment on lines 79 to 92
if (this.src !== undefined) {
if (isSvg) {
if (this.inlineSvg) {
return (
<svg part="svg">
<use href={`${this.src}#img`} />
</svg>
);
}
return <img src={this.src} />;
}
return this.src;
}
return <slot />;
Copy link
Collaborator

Choose a reason for hiding this comment

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

if (this.src === undefined) {
  return <slot />;
}

if (!isSvg) {
  return this.src;
}

if (!this.inlineSvg) {
  return <img src={this.src} />;
}

return (
  <svg part="svg">
    <use href={`${this.src}#img`} />
  </svg>
);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Your solution does not work if you want to have name prop... i will adjust it..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please check

};

private renderContent(isSvg: boolean) {
if (this.src !== undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

So the svg here has precedence over the slot?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why not? When you explitly place a path to a SVG you are showing a more clear intention to use svg over anything else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please check

<six-icon>sick</six-icon>
<six-icon>fort</six-icon>
<six-icon>castle</six-icon>
<six-icon src="fort"></six-icon>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add a comment explaining the two possible ways to do this => slot and prop

}

/* ==========================================================================
Size helpers (unchanged API, a bit more explicit)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the content inside the brackets

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please check

@colinscz colinscz modified the milestones: v5.2.0, v5.3.0 Nov 28, 2025
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.

six-icon with SVG support

4 participants