stretch icon indicating copy to clipboard operation
stretch copied to clipboard

Dimensions with percentages not working in JavaScript port

Open zamotany opened this issue 4 years ago • 3 comments

First of all, this is an awesome project and I really appreciate everyone putting their effort into it.

While working on react-slate (a React renderer for terminal in Node JS), which is based on Stretch, I noticed that, when setting width/height, basically any Dimension property as a percentage, it is converted to plain Points:

setting width to 100% will result in Points(100) being used in layout calculations.

I've done some digging and found one line of code, which might be causing that in get_dimension function in bindings/js: https://github.com/vislyhq/stretch/blob/a7e2c07bc343a1f16e1d651ea9f0c17fb0fbd098/bindings/js/src/lib.rs#L608-L613

Shouldn't this if let return return stretch::style::Dimension::Percent(number / 100);?

I'm happy to do a PR to fix that, but wanted a feedback before doing so.

zamotany avatar Aug 21 '19 20:08 zamotany

@zamotany You are totally right. My bad. Yeah if you would like to make a PR (and add a test for it so I don't mess up again ^^) that would be awesome. Let me know, otherwise I'll write a fix for it when I have some downtime.

btw react-slate looks awesome! Congrats on a successful project 💯

Also sorry for the delay in getting back to you on this.

emilsjolander avatar Sep 03 '19 22:09 emilsjolander

@emilsjolander Sure, I'll make a PR

zamotany avatar Sep 09 '19 08:09 zamotany

Any chance we can get this fix merged ? I'm looking into replacing yoga-layout in my own project with stretch-layout but the broken percentage dimensions is a showstopper.

heswell avatar Nov 03 '19 16:11 heswell