-
Notifications
You must be signed in to change notification settings - Fork 525
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
Accept higher value in border-radius to be able to render a pill shaped rectangle #1006
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Poivey it should follow CSS conventions as much as possible: https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius
you might need to introduce ry
to rects too.
so that 0.25
would be 25% of x axis for rx and 25% of y axis for ry. at least i think that's how CSS is doing it
…ew rx and ry compute method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm yeah these just look weird, i don't think anyone would want to use that. i guess what i really wanted was a way to create the "pill" shape effect. sorry about this dragged-out experience @Poivey . i rly appreciate this high quality investigating and work and how thorough you've been in describing the issues, but i think the end result just didn't turn out to be something desirable, aesthetically.
i also don't want to have a separate pill: true
, or shape: pill
though. i kind of wish the border-radius: 999
would work, like it does in CSS. up to you if you want to keep going to find the implementation for that, otherwise i can just create an issue for it separately.
oh, what if % only applies to rx then, and just not affect the ry? that'd be a clear use case for %, and i think we don't lose anything since % just doesn't look good when applied to both rx and ry |
Sure I would like to continue, I'll have time to work on it next week. As I understand : the goal is to have a rectangle ressemble a pill shape if given a Can you confirm this is what needs to be done ?
Yes, from what I saw when I experimented, it's possible to have a pill shape like this. For example, if a rectangle has a It's not the same as setting |
No I think we want to just emulate CSS's handling. Users can specify a large value for "pill". you'll probably have to increase the allowed value, which is a todo anyway (#948) https://stackoverflow.com/questions/71023962/how-to-make-a-pill-shape-button-with-html-and-css https://stackoverflow.com/questions/31617136/avoid-elliptical-shape-in-css-border-radius |
…lue and limit it to half of the smaller shape side to be rendered as a pill
I updated this PR title and description with new examples. Now the renders behaves like CSS does when passing a high
Now that we dropped the idea of percentage border-radius as it did not render as expected, do you think #947 should be closed, and #948 should be assigned to me through this PR, or closed and create a new issue for pill render for this PR ? |
3b0a5ea
to
b2d0a44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 beautiful docs, tests, and code. minor nitpicks, but other than that + merge conflicts, good to go!
friendly ping @Poivey , would love to get this in |
Thanks for the review, I'll make the change and resolve conflicts in a few hours, it should be good to go very soon |
@alixander It's ready :) |
thanks again! |
Summary
Remove the higher limit of
border-radius
, to be able to render rectangle shape as "pill".Details
rx
andry
from the shapewidth
andheight
to render the same way CSS doesrx
andry
values to half of the minumum value betweenwidth
andheight
to mimic CSS (see 1st and 2nd example)Examples
CSS example for reference
Screen.Recording.2023-04-13.at.16.21.36.mov
^ Note that
border-radius: 50px
is the same render asborder-radius: 999px
Rendered SVG example
Screen.Recording.2023-04-13.at.16.22.08.mov
^ Note that
rx="50"
is NOT the same render asrx="999"
-> This is why we need the methodcalculateAxisRadius
to limit the valuerx
andry
can have.Also works vertically
^ When only
rx
is set, it the same as ifry
had the same value.Does not need
width
andheight
to be set manually to workTODO
[Deprecated] Old description percentage border-radius solution
Summary
Considers
border-radius
value between (0,1) as a percentage, applied torx
andry
shape attributes.Details
rx
andry
from the shapewidth
andheight
to rendre the same way CSS doesborder-radius
value validationry
was added to shape having arx
. The rendesr are the same.rx
andry
will have the same value if a "number" value is given toborder-radius
, and might have a different one if a "percent" value is given.Examples
[Deprecated] Old description with first questions
Here are example of how it renders, shaped are named according the the applied





border-radius
value (eg.Example0,05
hasborder-radius: 0.05
,rx
will be"5%"
)Question
I feel like the first 4 examples are rendering as expected, but the last one highlight an issue present when the image is too wide -> small percentages are rendering a more rounded border radius as expected. The difference is easily visible on both
Element0,05
andElementWithALongerName0,05
in exemple 2 and 5.So I think the percentage value might depend on the image width. I'm not used to this so I plan to look for a solution next time I can focus on this issue (likely next week).
Do you have an idea about how I could fix this issue ? Maybe compute an integer
rx
value from the percentage value and the shape width instead of setting with the percentage value directly ?FIX #947-> Canceled as render renders were not satisfyingFIX #948