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

[ToggleButtons] Add toggle buttons #10144

Merged
merged 14 commits into from
Jul 4, 2018

Conversation

phallguy
Copy link
Contributor

@phallguy phallguy commented Feb 2, 2018

screen shot 2018-02-06 at 8 06 48 pm

Adding support for toggle buttons.

@phallguy
Copy link
Contributor Author

phallguy commented Feb 2, 2018

This is still WIP but wanted to give y'all a chance to make some early comments. Still need to flesh out the docs and specs.

I have a much better appreciation for how hard it is to build 'on spec'. So much of the spec is left undefined and open to interpretation. I tried to follow general style and spacing guidelines I've seen in the other components in the spec but this one specifically does not have redlines or text opacity guidelines.

Right now the behavior is completely controlled - it is incumbent on the developer to manage the selected state of both the buttons and the group. I want to add 'auto' support on the group to show selected if any of the child buttons are selected as well as manage an aggregate onChange event where the toggle group would manage the state of the child buttons. Before pursuing that route though I wanted to check if that would fit with the design guidelines for the project.

Love any feedback anyone would like to offer before I make this ready for production.

@oliviertassinari
Copy link
Member

@phallguy Thank you for working on it! I will find some time to look at it. @mbrookes Raised a good point. It's now more important than ever to push the lab repository story forward to host components like this one—#9673.

@oliviertassinari oliviertassinari added the package: lab Specific to @mui/lab label Feb 3, 2018
return (
<div className={ classes.toggleContainer }>
<ToggleButtonGroup selected={ alignment.length > 0 }>
<ToggleButtonWithValue value="left" values={ alignment } onClick={ this.handleToggleAlignment }><FormatAlignLeft /></ToggleButtonWithValue>
Copy link
Contributor

@caub caub Feb 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsx attributes shouldn't be spaced: prop={value} I don't think it'll pass npm run lint like so (try to have your editor format/eslint --fix on save)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the note. This is currently WIP. I'll be sure to lint everything when it's totally ready. (normally have editor do it automatically but haven't set it up for this project).

@phallguy phallguy force-pushed the phallguy/toggle-buttons branch 5 times, most recently from ac1096c to 94a1688 Compare February 7, 2018 04:11

return React.cloneElement(child, {
selected,
onChange: exclusive ? this.handleExclusiveChange : this.handleChange,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this implementation the signature for the call to onChange changes slightly based on the exclusive prop. When exclusive onChange is called with a single value and when false it is called with an array of values. I don't have a really strong opinion on best approach. The adaptive implementation is really convenient for consumers of the component but the variable signature might have surprising results later. Happy to entertain other perspectives.

@phallguy phallguy changed the title [ToggleButtons]: Add toggle buttons (WIP) [ToggleButtons]: Add toggle buttons Feb 7, 2018
@phallguy phallguy force-pushed the phallguy/toggle-buttons branch 2 times, most recently from 63a3aca to 27d2f3f Compare February 7, 2018 04:39
@oliviertassinari oliviertassinari added this to the post v1 milestone Feb 11, 2018
@oliviertassinari
Copy link
Member

@phallguy Hey, thank you for this pull-request! I'm sorry I haven't provided a feedback earlier. I'm focusing on addressing the last issues before releasing v1. Reviewing this pull and merging can sensibly delay v1. I won't make it a priority until we ship v1.

@mbrookes
Copy link
Member

@phallguy We'll have a new home once this gets merged: #10288.

@phallguy
Copy link
Contributor Author

Sounds good. Looking forward to the 1.0 ship!

@mbrookes
Copy link
Member

@phallguy The lab package is up and running (packages/material-ui/lab). You could move ToggleButtons there.

@mbrookes
Copy link
Member

@phallguy How goes it? 👋 Just checking in to see if you're still working on this, or need any help moving it to the lab package?

@phallguy
Copy link
Contributor Author

Thanks for your patience. Been distracted with some other work. I haven't spent any time looking into moving into the lab. Is there any resource or guides available for submitting to the lab?

@mbrookes
Copy link
Member

@phallguy No worries, just checking in, no rush at alI.

I need to write that up, but basically it's exactly the same as for the main package, except the files go in the packages/material-ui-lab/src directory. We've also adopted the flat directory structure that v1-beta will move to. The demos go in a subdirectory of docs/pages/lab.

You could look at the Slider PR to get an idea of the structure:

image

@phallguy
Copy link
Contributor Author

Ok seems easy enough. I'll try and grab some time this week.

@phallguy phallguy force-pushed the phallguy/toggle-buttons branch 2 times, most recently from a3b8fb9 to b8c9f1d Compare April 25, 2018 15:17
@phallguy

This comment has been minimized.

@phallguy phallguy force-pushed the phallguy/toggle-buttons branch from b8c9f1d to 636dbfb Compare April 29, 2018 20:28
@oliviertassinari oliviertassinari changed the base branch from v1-beta to master May 12, 2018 18:20
@mbrookes mbrookes force-pushed the phallguy/toggle-buttons branch from 84d3f38 to 2fa762f Compare July 4, 2018 00:47
@mbrookes mbrookes force-pushed the phallguy/toggle-buttons branch from 2fa762f to b02145d Compare July 4, 2018 01:15
@mbrookes
Copy link
Member

mbrookes commented Jul 4, 2018

@phallguy My sincere apologies that it has taken so long to merge this. I had allowed time for @oliviertassinari to review the PR, but he has been tied up with support, bug fixes, and performance enhancements for core components, both before and since releasing v1, so hasn't had the opportunity, so I'm going to merge it, and take the responsibility for anything I've overlooked.

Thanks for your hard work pulling this together!

@mbrookes mbrookes merged commit 263b428 into mui:master Jul 4, 2018
@phallguy
Copy link
Contributor Author

phallguy commented Jul 4, 2018

No worries I really appreciate all the work you guys have done. Ping me if you need help cleaning anything up. Glad to help.

@phallguy phallguy deleted the phallguy/toggle-buttons branch July 4, 2018 02:43
@mbrookes
Copy link
Member

mbrookes commented Jul 5, 2018

@phallguy We keep forgetting to ask people, but would you be interested in any MUI logo stickers as a small token of appreciation?

@phallguy
Copy link
Contributor Author

phallguy commented Jul 6, 2018

Yeah that'd be pretty cool.

@mbrookes
Copy link
Member

mbrookes commented Jul 6, 2018

Cool. Ping me a note on gitter with your address and how many you'd like.

acroyear pushed a commit to acroyear/material-ui that referenced this pull request Jul 14, 2018
@oliviertassinari oliviertassinari changed the title [ToggleButtons]: Add toggle buttons [ToggleButtons] Add toggle buttons Jul 14, 2018
@oliviertassinari oliviertassinari added component: toggle button This is the name of the generic UI component, not the React module! new feature New feature or request and removed package: lab Specific to @mui/lab labels Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: toggle button This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants