-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
[ToggleButton][ToggleButtonGroup] Create ToggleButton
and ToggleButtonGroup
#763
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy preview |
6c0fe92
to
6e04229
Compare
e07b2ef
to
f23c6df
Compare
9bcba83
to
3a74374
Compare
ToggleButton
ToggleButton
and ToggleButtonGroup
7cc24fd
to
b06a97d
Compare
bcdd1cc
to
7c449d8
Compare
26c97cd
to
54310b3
Compare
if (textDirectionRef?.current == null) { | ||
textDirectionRef.current = getTextDirection(element); | ||
} | ||
const isRtl = textDirectionRef.current === 'rtl'; |
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.
Caching this in a ref to mitigate against spamming the keys raised in #831 (comment)
54310b3
to
f4c3c04
Compare
f4c3c04
to
f1e3786
Compare
This PR is up to date again with all the library changes since it was opened, pinging @colmtuite again for a review 🙏 |
* | ||
* - [ToggleButtonGroupItem API](https://base-ui.com/components/react-toggle-button-group/#api-reference-ToggleButtonGroupItem) | ||
*/ | ||
const ToggleButtonGroupItem = React.forwardRef(function ToggleButtonGroupItem( |
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.
We should make the API consistent with RadioGroup and CheckboxGroup - they don't have the .Item part but use Radio.Root and Checkbox.Root
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.
I started off doing that but in the end it was more practical to have this Item
subcomponent, let me look up what the actual problem was
@colmtuite is this an issue for you?
} | ||
|
||
export namespace useToggleButtonRoot { | ||
export interface Parameters { |
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.
Make the hook parameters mandatory (per #856). Defaults should be set on the component level.
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.
Updated ~ f715087
* The value of the ToggleButtonGroup represented by an array of values | ||
* of the items that are pressed | ||
*/ | ||
value: readonly 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.
It might be better DX if the type of the value was an array only when toggleMultiple
is set.
For parity with RadioGroup, we should allow any type of value.
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.
For the value, I think it might be easier to remember (or harder to do something wrong) if it was always an array, if not we'd have to do a warning or something if you get the type wrong here
What do you think @atomiks @vladmoroz ?
Closes #11
Closes #31
Docs: