-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Proposal: extract core checkbox and radio behavior into separate @Directives #347
Comments
Notes:
|
This is an interesting thought on composable behavior. It's really more of a I generally like this idea of extracting individual behaviors as building blocks for components. We've definitely talked about it before, and had been leaning on mixins as being the approach. Mixins make sense because, while all of these "checkable" components share some behavior, there is special behavior for each one, meaning that you'd end up building a custom component for each anyway. The result is easier to test and reuse. Aside from toggle-buttons and slide-toggle, do you have any other use cases in mind for such a |
@jelbourn In my project I do use mixins, this is because I have a The reason I did not emphasise it was the goal's of this project, it is intended to be an example of how to do Angular 2. Mixins, while wonderful and powerful are a bit more difficult to understand as opposed to classical inheritance... One have to connect the dots, tough its not that bad, totally up to you. As for more ideas, I have mentioned that checkbox is also used for radio, which in turn enables Exclusive selection in
This is quite a robust composition system :) With your permission, I would like to offer my contribution with a small PR that will introduce a refactor for Is this an option? Thanks, Shlomi |
@shlomiassaf I'd rather not introduce a new |
Sure thing, let me know if you need my help |
Now that TypeScript 2.2 supports mixins we will be exploring breaking out functionality into reusable pieces for the cdk. See #3944 for the first explorations into this space. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
A User can use
md-checkbox
/md-radio-X
components to create chebox's and radio's.User can apply checkbox / radio behaviour to any element as well as use the currently available
md-checkbox
/md-radio-X
components.By implement checkbox & radio group/button as directive's users can apply them on other elements.
The current implementation of
md-checkbox
&md-radio-X
will use the directives in their implementation so we are not duplicating code.Having this, user's can easily create a
Toggle
button or a group of toggle buttons as well as radio group made of buttons (as in bootstrap).This will also enable #112 today and reduce the code for it.
This is generally how the directive should look like
From here, creating a toggle button is as simple as
The code above was writting on the fly so it's just for the idea.
I'v implemented it in some components I work with not related to material, I can post a PR if you like the idea.
The text was updated successfully, but these errors were encountered: