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

docs(examples): simplify docs using new layout methods #731

Merged
merged 2 commits into from
Jan 5, 2024

Conversation

joshka
Copy link
Member

@joshka joshka commented Jan 3, 2024

Use the new Layout::horizontal and vertical constructors and
Rect::split_array through all the examples.

Copy link

codecov bot commented Jan 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (23f6938) 92.3% compared to head (48b5ffa) 92.3%.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #731     +/-   ##
=======================================
- Coverage   92.3%   92.3%   -0.1%     
=======================================
  Files         55      55             
  Lines      14840   14836      -4     
=======================================
- Hits       13703   13699      -4     
  Misses      1137    1137             

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joshka joshka marked this pull request as draft January 3, 2024 00:59
@joshka
Copy link
Member Author

joshka commented Jan 3, 2024

Waiting on #729 to be finalized for naming.
Rebase after.

@joshka joshka force-pushed the layout-simplify-examples branch from 4d2a04a to 40e1d40 Compare January 4, 2024 07:03
@joshka
Copy link
Member Author

joshka commented Jan 4, 2024

Removed the helper methods. They don't make things particularly clearer and have problems with polluting the imports. They're tough to put in the prelude due to the common names (min/max/length), which overall suggests that we're better without them. Diff when removed was 254 lines added, 258 removed, so the benefit on LoC is negligible.

@joshka joshka force-pushed the layout-simplify-examples branch from 5df3a23 to 0d1daaf Compare January 5, 2024 07:07
@joshka
Copy link
Member Author

joshka commented Jan 5, 2024

Rebased on the current version of main with Rect:split()

@joshka joshka force-pushed the layout-simplify-examples branch from 0d1daaf to 4d84bc5 Compare January 5, 2024 07:09
@joshka joshka marked this pull request as ready for review January 5, 2024 07:10
@joshka
Copy link
Member Author

joshka commented Jan 5, 2024

Regarding testing this, the easiest way is to run makers run-examples which runs each example one after the other. All still work fine.

Use the new `Layout::horizontal` and `vertical` constructors and
`Rect::split_array` through all the examples.
@joshka joshka force-pushed the layout-simplify-examples branch from 4d84bc5 to 350cf68 Compare January 5, 2024 11:26
@joshka
Copy link
Member Author

joshka commented Jan 5, 2024

Rebased now that #729 is merged.

Copy link
Member

@Valentin271 Valentin271 left a comment

Choose a reason for hiding this comment

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

Looks good, I can confirm all examples are working and layouts are visually ok.

Co-authored-by: Valentin271 <[email protected]>
@kdheepak
Copy link
Collaborator

kdheepak commented Jan 5, 2024

I think it is a little confusing that we have

let rects = layout.split(area);

and we also have

let [rect1, rect2] = area.split(layout);

Is there a reason we couldn't always use the second form?
If there is a good reason for choosing the first form, I think at the very least it should be documented on the website.

@joshka
Copy link
Member Author

joshka commented Jan 5, 2024

Is there a reason we couldn't always use the second form? If there is a good reason for choosing the first form, I think at the very least it should be documented on the website.

The area.split(layout) form requires knowing the number of rects that will be returned beforehand. The layout.split(area) form does not. The places where I've left that are places where there are a dynamic number of areas in which to split to.

I also left a couple of more complex examples alone (IIRC it was in the old demo).

You're right - this could do with some docs in Layout::split - another PR perhaps?

@joshka joshka merged commit fb93db0 into main Jan 5, 2024
@joshka joshka deleted the layout-simplify-examples branch January 5, 2024 15:45
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.

3 participants