MarginInfo convenience builder methods
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
Vaadin version: 8.0.0.beta2
I just checked out Vaadin 8 and it looks pretty nice, good work!
I have noticed, that the default setting of spacing/margin was changed to true. This is a good thing, but it will cause a lot of refactoring for layouts created with Vaadin 7 when migrating.
This would maybe be a good time to introduce convenience builder methods for the MarginInfo.
Status quo
layout.setMargin(false);
layout.setMargin(new MarginInfo(false));
layout.setMargin(new MarginInfo(false, true));
layout.setMargin(new MarginInfo(false, true, true, false));
Although this is similar to css, it's just not really readable. I have to double check every time.
I propose static methods, which would be usable like this:
layout.setMargin(MarginInfo.none());
layout.setMargin(MarginInfo.vertical());
layout.setMargin(MarginInfo.horizontal());
layout.setMargin(MarginInfo.all());
layout.setMargin(MarginInfo.of(false, true, true, false));
I think especially the vertical/horizontal methods would be useful. Maybe there is a better way, to set all 4 values, all I could think of right now is of(..).
The implementations would be trivial:
public static MarginInfo vertical() {
return new MarginInfo(true, false);
}
A builder or fluent setters would probably be overkill I guess.
Thanks
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the MarginInfo class and any existing tests or usages for setMargin. Review how its boolean constructors represent sides, then add the proposed named margin options and verify that each maps to the intended values. Done means the convenience methods are available and their behavior is covered by the relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100