-
Notifications
You must be signed in to change notification settings - Fork 26
Add values for all border corners #10
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
Conversation
src/FocusRingContext.tsx
Outdated
|
||
if (!topLeft || !topRight || !bottomRight || !bottomLeft) { | ||
return undefined; | ||
} |
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.
hello! I am not sure if it's okay for anyone to comment on PR's? if it's not, I'm sorry 😔
just an ideia: maybe it would be nice to support elements that do not have all the corners rounded.
example: border-radius: 10px 10px 0 0
(only top borders are rounded).
I believe this would be the default behaviour for browsers that can get the full border-radius string.
and, if there are no borders at all, we return undefined
. what do you think?
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.
It's absolutely welcomed for anyone to comment! Thanks for point this out, too.
I agree that we should allow any subset of sides to have a border radius. I can specifically think of examples like the start and ends of "button groups" that might want smaller/larger radiuses on the outer sides than the inners, or things like partially-rounded shapes (a square with one rounded corner, for example).
This code can just default to 0
for corners that don't have a defined radius value, and that should cover it.
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.
Thank you for the comments! I was thinking about this use case as well, but wasn't sure if we should default it to 0. Will fix it!
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.
Thanks for implementing this!
I agree with the comment above; once that's resolved, I think this looks good and pretty much ready to go.
src/FocusRingContext.tsx
Outdated
|
||
if (!topLeft || !topRight || !bottomRight || !bottomLeft) { | ||
return undefined; | ||
} |
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.
It's absolutely welcomed for anyone to comment! Thanks for point this out, too.
I agree that we should allow any subset of sides to have a border radius. I can specifically think of examples like the start and ends of "button groups" that might want smaller/larger radiuses on the outer sides than the inners, or things like partially-rounded shapes (a square with one rounded corner, for example).
This code can just default to 0
for corners that don't have a defined radius value, and that should cover it.
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.
Sorry this took so long to get to. One quick note and then I'll be ready to merge very soon.
src/FocusRingContext.tsx
Outdated
@@ -24,6 +24,10 @@ function setActiveRingContextManager(manager: FocusRingContextManager) { | |||
} | |||
} | |||
|
|||
function parseBorderRadius(radius: string) { |
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.
Since this function is called with an optional property chain (styles[0]?.property
), this could actually be an undefined value, so radius: string | undefined
. I'd leave it in the long-hand rather than radius?: string
since the argument is still required, it may just be undefined.
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.
Good point! Fixed it.
Fixes #7.
Screenshot:
