-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Add readme and package.json files to the button toggle #925
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
Changes from 3 commits
bead011
cf73f11
93aedab
3eb6421
725624b
f44d18e
d50e969
ac46f84
c2ec4cb
f34536d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# MdButtonToggle | ||
|
||
`MdButtonToggle` is a group of buttons that can be toggled. There are two modes, `multiple` and | ||
`exclusive`. `Multiple` is a group in which multiple buttons can be toggled at once. `Exclusive` is | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be clearer if you say "selected" here, rather than "toggled". Technically all of them can be toggled in any mode, but only one (or multiple) can be selected. How about:
|
||
a group in which only one button can be toggled at once. | ||
|
||
## `<md-button-toggle>` | ||
|
||
### Bound Properties | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd put the summary of properties and events at the bottom. It's usually more useful for people to see basic usage examples first (and the other components are organized this way). |
||
|
||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| `id` | string | The unique ID of the toggle. IDs are generated by default when not specified. | | ||
| `name` | string | Optional, defaults to parent group name if one exists for exclusive selection toggles, otherwise null. This is used to differentiate between different groups. | | ||
| `value` | any | Value of the toggle. Only used when in a group to determine which are selected. | | ||
| `checked` | boolean | Optional, default = `false`. Whether or not the toggle is checked. | | ||
| `disabled` | boolean | Optional, default = `false`. Whether or not the toggle is disabled | | ||
|
||
### Events | ||
|
||
| Name | Description | | ||
| --- | --- | | ||
| `change` | Emitted when the `checked` value is changed. | | ||
|
||
## `<md-button-toggle-group>` | ||
|
||
### Bound Properties | ||
|
||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| `name` | string | Optional, the name of the group. | | ||
| `disabled` | boolean | Optional, default = `false`. | | ||
| `value` | any | The current value for the group. Will be set to the value of the selected toggle or a list of values from the selected toggles. | | ||
| `selected` | `mdButtonToggle` | The current selected toggle or a list of the selected toggles. | | ||
|
||
### Attributes | ||
|
||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| `multiple` | boolean | Optional, default = `false`. Whether or not the group allows multiple selection. | | ||
|
||
### Events | ||
|
||
| Name | Description | | ||
| --- | --- | | ||
| `change` | Emitted when the `value` of the group changes. | | ||
|
||
## Usage | ||
|
||
### Basic Usage | ||
|
||
`md-button-toggle` can be used on its own and acts as a checkbox. | ||
|
||
```html | ||
<md-button-toggle>Bold</md-button-toggle> | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a screenshot of what this might look like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks good, but I think it's showing two button toggles? Does the code match the image? |
||
|
||
### Multiple Selection | ||
|
||
`md-button-toggle` can be used in a multiple selection group when surrounded by | ||
`md-button-toggle-group multiple`. This styles all buttons within the group to appear as a single | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, have you thought about putting the exclusive selection section before multiple selection? It's probably more common, and that way, you can explain |
||
group of button toggles. | ||
|
||
```html | ||
<md-button-toggle-group multiple> | ||
<md-button-toggle>Flour</md-button-toggle> | ||
<md-button-toggle>Eggs</md-button-toggle> | ||
<md-button-toggle>Sugar</md-button-toggle> | ||
<md-button-toggle>Milk</md-button-toggle> | ||
</md-button-toggle-group> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add screenshots for this and exclusive selection as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: It might be a little confusing that you are showing a disabled button-toggle along with a selected one. It almost looks like multi-select. Perhaps create another section for the "disabled" example, so it's clear? |
||
``` | ||
|
||
### Exclusive Selection | ||
|
||
`md-button-toggle` can be used in an exclusive selection group when surrounded by | ||
`md-button-toggle-group`. This styles all buttons within the group to appear as a single | ||
group of button toggles and allows only one button toggle to be selected at a time. | ||
|
||
```html | ||
<md-button-toggle-group name="alignment"> | ||
<md-button-toggle value="left"><md-icon>format_align_left</md-icon></md-button-toggle> | ||
<md-button-toggle value="center"><md-icon>format_align_center</md-icon></md-button-toggle> | ||
<md-button-toggle value="right"><md-icon>format_align_right</md-icon></md-button-toggle> | ||
<md-button-toggle value="justify" disabled><md-icon>format_align_justify</md-icon></md-button-toggle> | ||
</md-button-toggle-group> | ||
``` | ||
|
||
## Dynamic Exclusive Selection | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is dynamic exclusive selection? Probably need some text here. |
||
```html | ||
<md-button-toggle-group name="pies" [(ngModel)]="favoritePie"> | ||
<md-button-toggle *ngFor="let pie of pieOptions" [value]="pie"> | ||
{{pie}} | ||
</md-button-toggle> | ||
</md-button-toggle-group> | ||
<p>Your favorite type of pie is: {{favoritePie}}</p> | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "@angular2-material/button-toggle", | ||
"version": "2.0.0-alpha.6-2", | ||
"description": "Angular 2 Material Button Toggle", | ||
"main": "./button-toggle.js", | ||
"typings": "./button-toggle.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/angular/material2.git" | ||
}, | ||
"keywords": [ | ||
"angular", | ||
"material", | ||
"material design", | ||
"components", | ||
"button-toggle", | ||
"button", | ||
"toggle" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/angular/material2/issues" | ||
}, | ||
"homepage": "https://github.com/angular/material2#readme", | ||
"peerDependencies": { | ||
"@angular2-material/core": "2.0.0-alpha.6-2", | ||
"@angular/forms": "^0.2.0" | ||
} | ||
} |
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.
You might want to take a step back and start with importing MD_BUTTON_TOGGLE_DIRECTIVES. Definitely mention that you need
MdUniqueSelectionDispatcher
and give an example of that.