-
Notifications
You must be signed in to change notification settings - Fork 378
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
Implemented Icon.WithSize(int? size) enabling Icons to be resized... #1136
Conversation
@microsoft-github-policy-service agree |
Thanks. Very cool improvement :-) We did not have time to put in all the unit tests at the start of the project, but we try to add them with each component modification. So I'm going to add a few unit tests to Dev. This will allow you to add a new one for this method :-) |
/// </summary> | ||
/// <param name="size"></param> | ||
/// <returns></returns> | ||
public virtual Icon WithSize(int? size) |
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.
I think it would be possible to have a string
argument: WithSize(string ? size)
as in the ToMarkup method. This could be interesting for using %
or other unit types. What do you think?
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.
Certainly, it would minimally require changes in the FluentIcon component and that exact ToMarkup method where "px" is hardcoded. It might also require changes in the way Width and Size are delt with (mostly Width which is a protected in an unsealed class). And that's where I decided to play it safe due to my limited knowledge of the ripple effects.
That said, if you're ok with pushing this a little further, I can spend some more time on this.
I would also be a bit more comfortable if we had some tests coverage here. Looks like we'll have to synch our changes to move forwardπ
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.
I added a PR #1136 to include Unit Tests
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.
I think you meant #1140
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.
Why not have both WithSize(int? size)
and WithSize(string? size)
?
And why are these parameters nullable? What would be the outcome of sending in a null value? I think we may expect people to supply a valid input value.
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.
We could have both, with WithSize(int? size) => WithSize(size is null ? null : $"{size}px");
The advantage of having a null value is to "reset" another specified size.
@dvoituron @vnbaaij I've added a new commit this morning that includes the changes to the generator so you can have a look at this code too. |
@EricOnGit, please revert that last commit and create a new PR for it. I'm fairly certain we will mergi in the |
β¦e icons." This reverts commit 3c8227d.
Hold off a bit on creating the new PR please |
Ok, let's add the sting variant and get this merged in. |
@vnbaaij there is a catch to bringing the string variant. The Width property of the Icon class is exposes as "protected internal". I'll admit I had to look it up to be sure. It turns out those modifiers are acting as OR. Old reference here Which means that if we implement WithSize(string?) we will either have a messy meaning for Width (only the int part or something like "1.3rem"?) or have to expose Width as string which would break any derived class π£ I thought of it for a moment and I see a couple options (none are perfect tho)
It's probably inevitable that this will have to break at some point but is this PR the right one? I rarely advise for caution but you mentioned earlier that you rather not introduce a breaking change. |
β¦ to any dimensions.
Pull Request
π Description
This is the quick and easy implementation that was discussed in issue #1124.
It offers a new WithSize() function that enables the dev to override the width of the Icon to any size.
This is compatible with previous version since the OverriddenWidth value is initialized to null and then tested against at render time so it's only used if the value was changed.
π« Issues #1124
π©βπ» Reviewer Notes
Comments were added directly in the Icon.cs file to better explain the change.
π Test Plan
There are currently no test on Icons. But I did test the component in my current project using both a FluentIcon and a FluentButton without any adverse effect.
β Checklist
General
β Next Steps
none to my knowledge