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

Fixing RadioButton layout #227

Open
sebpiq opened this issue Mar 7, 2023 · 0 comments
Open

Fixing RadioButton layout #227

sebpiq opened this issue Mar 7, 2023 · 0 comments

Comments

@sebpiq
Copy link
Contributor

sebpiq commented Mar 7, 2023

Hey !

I am working with nexusUI these days and still loving it after all these years (thanks @taylorbf ;) )

The RadioButton introduces some undesired horizontal padding when the width is not a multiple of the height.

Screenshot from 2023-03-07 13-01-19

This is because the button's dimensions are configured like so :

var buttonWidth = this.width / (orientation === "vertical" ? 1 : this._numberOfButtons);
var buttonHeight = this.height / (orientation === "vertical" ? this._numberOfButtons : 1);

for (var i = 0; i < this._numberOfButtons; i++) {
	this.buttons[i].resize(buttonWidth, buttonHeight);
}

I'd suggest taking the min of (width, height) instead :

var buttonWidth = this.width / (orientation === "vertical" ? 1 : this._numberOfButtons);
var buttonHeight = this.height / (orientation === "vertical" ? this._numberOfButtons : 1);
var buttonSize = Math.min(buttonWidth, buttonHeight)

for (var i = 0; i < this._numberOfButtons; i++) {
         this.buttons[i].resize(buttonSize, buttonSize);
}

And then, setting the container's display to flex :

buildFrame: {
        value: function buildFrame() {
                this.element = document.createElement("div");
                this.element.style.display = 'flex'
                this.element.style.flexDirection = 'row' // or 'column' if vertical
                this.element.style.justifyContent = 'space-between'
                this.parent.appendChild(this.element);
        }
},

Then it looks like this :

Screenshot from 2023-03-07 13-06-01

I'd submit a pull request, but don't know the lib so well, and wanted to submit the idea first anyways ;)

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

No branches or pull requests

1 participant