Skip to content

Add more consistent padding config to components #985

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

Closed
rreusser opened this issue Sep 28, 2016 · 2 comments
Closed

Add more consistent padding config to components #985

rreusser opened this issue Sep 28, 2016 · 2 comments
Labels
feature something new

Comments

@rreusser
Copy link
Contributor

rreusser commented Sep 28, 2016

The problem: components are positioned in fractional coordinates, but axis labels take up a fixed amount of space relative to the screen. This makes it effectively impossible to create a consistent amount of padding between the plot and the labels when the plot size is changed. At the moment there seems to be some xpad and ypad attributes, but I think it needs to be more complete and consistent.

A solution: I propose adding a common padding: {t: ..., r: ..., b: ..., l: ...} attribute to most components. Ideally the logic could be hoisted up a level and DRYd up, but realistically, I feel like all components might just have to implement this positioning themselves. The result though is that it would be possible to carefully and precisely align components. This approach is consistent with what most people would probably expect based on html experience and is backward compatible if it defaults to zeros. Together with fractional positioning, I feel like you could at least get way closer to a satisfying layout.

Note: I'm running into this quite a bit as I try to align multiple components in an aesthetically pleasing way and trying to line up a slider with buttons is turning out to be particularly painful. Padding would instantly solve this.

Example: With identical config (apart from the size) that uses fractional padding to clear the axis labels, the small plot has a nice amount of space between the axis and the controls; the large plot has way too much space. http://codepen.io/rsreusser/pen/NRgbJy?editors=0010

screen shot 2016-09-27 at 23 28 13

@rreusser
Copy link
Contributor Author

As discussed with @etpinard, the solution sounds like:

  • components receive pad: {t, r, b, l}
  • components are responsible for accounting for their own padding and including it in the pushmargin'd sizes
  • cleanLayout/cleanData takes previous properties like xpad/ypad and applies backward compatibility

@rreusser
Copy link
Contributor Author

rreusser commented Sep 29, 2016

Dupe of #997. I'm fine keeping that one open :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

No branches or pull requests

1 participant