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

Add horizontal and vertical padding methods. #2655

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hydra
Copy link

@hydra hydra commented Oct 31, 2024

e.g.

let status_bar = container(text("status bar area"))
    .padding(padding::horizontal(3));

the point of this PR is:

  • to improve the API for everyone.
  • to make is so that the number, 3 in the example above, is only specified once.
  • so that default values do not have to be specified or overridden.

currently the alternatives are as follows:

1 - specification of vertical and horizontal

let status_bar = container(text("status bar area"))
    .padding([0, 3]);
  • the reader does know the order and has to refer to the API docs,
  • the intention is not clear, is the intention to override the default top/bottom to 0 and set the left/right to 3, or is the intention just to add horizontal padding?

2 - use the struct

let status_bar = container(text("status bar area"))
    .padding(Padding { left: 3, right: 3, ..padding::default() });
  • way to verbose
  • not readable
  • used the word 'padding' 3 times on the same line.
  • duplicates the 3 value.

there may be more alternatives, but hopefully the above goes some way to understanding why i feel horizontal and vertical methods are useful.

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.

1 participant