Skip to content
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

feat: add getters for used Unit to HasSize #9824

Merged
merged 9 commits into from Feb 18, 2021
Merged

feat: add getters for used Unit to HasSize #9824

merged 9 commits into from Feb 18, 2021

Conversation

knoobie
Copy link
Contributor

@knoobie knoobie commented Jan 17, 2021

Improves the addition to HasSize for Unit.

  • adds getWidthUnit and getHeightUnit for better discoverability
    • Open Questions:
      • Optional vs. null vs. Unit.PIXELS as default?
      • Adding those APIs for Min/Max as well? This would increase the amount of methods quite a lot with less gain
  • improve performance of Unit
    • change streaming to simple for-each
    • change ordering of enum values, most used (% > px > others)
    • Open Questions:
      • Should I replace the streaming API in getSize as well?
  • adds missing units vw, vh, vmin and vmax

@taefi
Copy link
Contributor

taefi commented Jan 26, 2021

Hi and thanks for the contribution.

My opinion about some of the questions:

Optional vs. null vs. Unit.PIXELS as default?

  • I would avoid Unit.PIXELS as default since IMO it creates more confusion. Between, null and Optional.empty I vote for the current implementation.

Adding those APIs for Min/Max as well? This would increase the amount of methods quite a lot with less gain

  • To be honest, the already added APIs feels like double edge sword! It feels right to get Unit of the size from the same API that we can get the size itself. One the other hand, these methods are also seems like on-liner utility methods that we can define a lot of them. Since this is a base interface, we need to be cautious about adding so many methods to it.

@knoobie
Copy link
Contributor Author

knoobie commented Jan 26, 2021

@taefi Thanks for your opinion!

I would avoid Unit.PIXELS...

The idea was based on the default implementation of V8 where PIXELS was the default instead of null. Personally I'm not a huge fan of Optional (until java 9) but I used it because it's often used in flow for optional values.

To be honest, the already added APIs feels like double edge sword...

The whole addition was based on the comment of Ben in #8533 (comment) - meaning having a "official" API inside the interface is easier to find for the developer and probably working ;)

Additionally, the HasSize interface is probably going to be cleaned up in the future once #5854 is done.

@taefi taefi requested a review from pleku January 27, 2021 08:20
Copy link
Contributor

@pleku pleku left a comment

Choose a reason for hiding this comment

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

Sorry that it has taken a while. Only two clarifications for the javadocs would be required

pleku
pleku previously approved these changes Feb 17, 2021
@pleku pleku removed the +1.0.0 label Feb 17, 2021
@pleku pleku changed the title feat: improve HasSize feat: add getters for Unit to HasSize Feb 17, 2021
@pleku pleku changed the title feat: add getters for Unit to HasSize feat: add getters for used Unit to HasSize Feb 17, 2021
taefi
taefi previously approved these changes Feb 17, 2021
@pleku
Copy link
Contributor

pleku commented Feb 17, 2021

Sigh, test failure should not be related in any way, restarted the build.

@knoobie
Copy link
Contributor Author

knoobie commented Feb 17, 2021

@pleku I'm not sure about the target/2.5 and target/2.6 label because the original PR for this isn't backported or? (#8533)

@pleku
Copy link
Contributor

pleku commented Feb 17, 2021

@pleku I'm not sure about the target/2.5 and target/2.6 label because the original PR for this isn't backported or? (#8533)

It is now as the manual cherry-pick PRs will be merged before this, then the bot will backport this too.

But @knoobie can you please rebase this on top of the master as it now failed for the silly Chrome version test.

@knoobie knoobie dismissed stale reviews from taefi and pleku via 00d1693 February 17, 2021 12:09
@knoobie
Copy link
Contributor Author

knoobie commented Feb 17, 2021

@pleku thanks! Rebased and waiting for the build process to do it's job :)

Edit: Looks like the build process doesn't wanna do it's job today "Caused by: java.lang.AssertionError: startup time expected <= 15000 but was 60409"

@fluorumlabs
Copy link
Contributor

Unit ch is missing from the unit list. While rarely used, I believe it's more popular than, let's say, centimeters :)

@knoobie
Copy link
Contributor Author

knoobie commented Feb 18, 2021

@fluorumlabs Thanks! Found a reason to trigger a build restart :)

@pleku pleku added +0.1.0 and removed +1.0.0 labels Feb 18, 2021
@pleku pleku merged commit 4c7cdf8 into vaadin:master Feb 18, 2021
OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from Iteration Reviews to Done - pending release Feb 18, 2021
vaadin-bot pushed a commit that referenced this pull request Feb 18, 2021
vaadin-bot pushed a commit that referenced this pull request Feb 18, 2021
pleku pushed a commit that referenced this pull request Feb 19, 2021
Related to #8533 (comment)

Co-authored-by: Knoobie <Knoobie@gmx.de>
pleku pushed a commit that referenced this pull request Feb 19, 2021
Related to #8533 (comment)

Co-authored-by: Knoobie <Knoobie@gmx.de>
@vaadin vaadin deleted a comment from vaadin-bot Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
OLD Vaadin Flow ongoing work (Vaadin ...
  
Done - pending release
Development

Successfully merging this pull request may close these issues.

None yet

6 participants