-
Notifications
You must be signed in to change notification settings - Fork 6.8k
docs(expansion): create overview and examples #5823
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 4 commits
8a1c7bf
d647370
94ace13
f47066c
adec4ac
b1dcc81
a6f26c7
9d1b6ba
1758a93
d618749
774c53d
d916605
18ae28a
a0186bd
31f74ca
7d65af8
7b42a2e
9c4912f
960158c
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,80 @@ | ||
`<md-expansion-panel>` provides a way to show and hide content, by collapsing and expanding a view with animation. | ||
|
||
<!-- example(expansion-overview) --> | ||
|
||
### Expansion panel content | ||
|
||
Each expansion panel has a header section and an action (optional) sections. | ||
|
||
When grouped by an `<md-accordion>` element the expansion panels can be used to create ordered views or flows, as it brings up the possibility to expand one view at a time. | ||
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 would eliminate this sentence since we talk about accordions in their own section. |
||
|
||
#### Header | ||
|
||
The header section is always visible at the top of the component and contains a `<md-panel-title>` and a description `<md-panel-description>` subsections. | ||
|
||
The `<md-panel-title>` subsecion is shown in the begining of the header, followed by the `<md-panel-description>` subsection, which is supposed to contain a sumary of what's in the expansion content. | ||
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. typos: subsecion -> subsection, begining -> beginning, sumary -> summary 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. done |
||
|
||
By default, the expansion panel header has a toogle sign at the right edge, pointing up when the panel is expanded and down when it's collapsed. The toogle icon can be hidden by setting the input property `toogleHide` to `true`. | ||
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. toogle -> toggle (multiple) 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. done |
||
|
||
```html | ||
<md-expansion-panel> | ||
<md-expansion-panel-header> | ||
<md-panel-title> | ||
This is the expansion title | ||
</md-panel-title> | ||
<md-panel-description> | ||
This is a summary of the content | ||
</md-panel-description> | ||
</md-expansion-panel-header> | ||
|
||
<p>...</p> | ||
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. <p>This is the primary content of the panel.</p> |
||
|
||
</md-expansion-panel> | ||
``` | ||
|
||
#### Actions | ||
|
||
The actions section is optional and fixed at the bottom, being visible only when the expansion is in its expanded state. | ||
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 remove "being" "...at the bottom, visible only when" 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. done |
||
|
||
```html | ||
<md-expansion-panel> | ||
<md-expansion-panel-header> | ||
This is the expansion title | ||
</md-expansion-panel-header> | ||
|
||
<p>...</p> | ||
|
||
<md-action-row> | ||
<button md-button>Click me</button> | ||
</md-action-row> | ||
</md-expansion-panel> | ||
``` | ||
|
||
### Accordion | ||
|
||
Multiple expansion panels can be combined into an accordion. The `multi="true"` input allows the expansions state to be set independently of each other. When `multi="false"` (default) just one panel can be expanded at a given time: | ||
|
||
```html | ||
<md-accordion> | ||
|
||
<md-expansion-panel multi="false"> | ||
<md-expansion-panel-header> | ||
This is the expansion 1 title | ||
</md-expansion-panel-header> | ||
|
||
This the expansion 1 content | ||
|
||
</md-expansion-panel> | ||
|
||
<md-expansion-panel> | ||
<md-expansion-panel-header> | ||
This is the expansion 2 title | ||
</md-expansion-panel-header> | ||
|
||
This the expansion 2 content | ||
|
||
</md-expansion-panel> | ||
|
||
</md-accordion> | ||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/** No CSS for this example */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<md-expansion-panel> | ||
<md-expansion-panel-header> | ||
<md-panel-title> | ||
Personal data | ||
</md-panel-title> | ||
<md-panel-description> | ||
Type your name and age | ||
</md-panel-description> | ||
</md-expansion-panel-header> | ||
|
||
<md-input-container> | ||
<input mdInput placeholder="First name"> | ||
</md-input-container> | ||
|
||
<md-input-container> | ||
<input mdInput placeholder="Age"> | ||
</md-input-container> | ||
|
||
</md-expansion-panel> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
|
||
@Component({ | ||
selector: 'expansion-overview-example', | ||
templateUrl: 'expansion-overview-example.html', | ||
}) | ||
export class ExpansionOverviewExample {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.headers-align .mat-expansion-panel-header-title, | ||
.headers-align .mat-expansion-panel-header-description { | ||
flex-basis: 0; | ||
} | ||
|
||
.icons-to-right { | ||
display: inline-block; | ||
width: 100%; | ||
text-align: right; | ||
margin-top: 5px; | ||
color: blue; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<md-accordion class="headers-align"> | ||
<md-expansion-panel [expanded]="step === 0" (opened)="openEvent(0)" hideToggle="true"> | ||
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. Personally I think the toggles should be shown (instead of the icons) since this is the main example and you're trying to demo the features of the panel. If you insist on using icons,
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. The icons are there just to show a situation where the the default is hidden (and to show that is possible to use some html inside the description). They are not really necessary. I can drop them. But before I'll try your suggestions to see how they 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. Your html point is good... maybe wait for a team member before dropping? But yeah, I think the styles can be cleaned up a little anyway 😁 |
||
<md-expansion-panel-header> | ||
<md-panel-title> | ||
Personal data | ||
</md-panel-title> | ||
<md-panel-description> | ||
<div>Type your name and age</div> | ||
<div class="icons-to-right"><md-icon>account_circle</md-icon></div> | ||
</md-panel-description> | ||
</md-expansion-panel-header> | ||
|
||
<md-input-container> | ||
<input mdInput placeholder="First name"> | ||
</md-input-container> | ||
|
||
<md-input-container> | ||
<input mdInput placeholder="Age"> | ||
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. type="number"? |
||
</md-input-container> | ||
|
||
<md-action-row> | ||
<button md-button color="primary" (click)="nextStep()">Next</button> | ||
</md-action-row> | ||
</md-expansion-panel> | ||
|
||
<md-expansion-panel [expanded]="step === 1" (opened)="openEvent(1)" hideToggle="true"> | ||
<md-expansion-panel-header> | ||
<md-panel-title> | ||
Destination | ||
</md-panel-title> | ||
<md-panel-description> | ||
<div>Type the country name</div> | ||
<div class="icons-to-right"><md-icon>map</md-icon></div> | ||
</md-panel-description> | ||
</md-expansion-panel-header> | ||
|
||
<md-input-container> | ||
<input mdInput placeholder="Country"> | ||
</md-input-container> | ||
|
||
<md-action-row> | ||
<button md-button color="warn" (click)="prevStep()">Previous</button> | ||
<button md-button color="primary" (click)="nextStep()">Next</button> | ||
</md-action-row> | ||
</md-expansion-panel> | ||
|
||
<md-expansion-panel [expanded]="step === 2" (opened)="openEvent(2)" hideToggle="true"> | ||
<md-expansion-panel-header> | ||
<md-panel-title> | ||
Day of the trip | ||
</md-panel-title> | ||
<md-panel-description> | ||
<div>Inform the date you wish to travel</div> | ||
<div class="icons-to-right"><md-icon>date_range</md-icon></div> | ||
</md-panel-description> | ||
</md-expansion-panel-header> | ||
|
||
<md-input-container> | ||
<input mdInput placeholder="Date" [mdDatepicker]="picker" | ||
(focus)="picker.open()" readonly> | ||
</md-input-container> | ||
<md-datepicker #picker></md-datepicker> | ||
|
||
<md-action-row> | ||
<button md-button color="warn" (click)="prevStep()">Previous</button> | ||
<button md-button color="primary" (click)="nextStep()">End</button> | ||
</md-action-row> | ||
</md-expansion-panel> | ||
|
||
</md-accordion> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
|
||
@Component({ | ||
selector: 'expansion-overview-example', | ||
templateUrl: 'expansion-overview-example.html', | ||
}) | ||
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. @Component({
selector: 'expansion-steps-example',
templateUrl: 'expansion-steps-example.html',
styleUrls: ['expansion-steps-example.css'],
}) 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. Added the missing styleUrls 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. The template and selector need to change too! Looks like copy/paste from the other example 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. The steps example was built over the overview one. |
||
export class ExpansionStepsExample { | ||
step = 0; | ||
|
||
openEvent(stepNumb: number) { | ||
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. How about https://github.com/angular/material2/blob/master/CODING_STANDARDS.md#methods |
||
this.step = stepNumb; | ||
} | ||
|
||
nextStep() { | ||
this.step++; | ||
} | ||
|
||
prevStep() { | ||
this.step--; | ||
} | ||
} |
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.
Expansion-panel
(here and elsewhere)