mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
docs(expansion): create overview and examples (#5823)
* docs(expansion): create overview and examples * ommit 'public' keyword * change doc structure * review 2 * eliminate md-accordion mentioned in expansion panel content * will's reviews * break lines at 100 chars * typo * toggleHide => hideToggle in overview * Rafael's review (travis and prefix css class) * Rafael's review (prefix header-align css class) * new line for expansion-overview-example.css * overview jelbourn's reviews * expansion-steps-example (will's reviews) * new line in steps example * delete paragraph in header * expansion panel => expansion-panel * add styleUrls in steps example @Component decorator * update steps example @Component decorator
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
`<md-expansion-panel>` provides an expandable details-summary view.
|
||||
|
||||
<!-- example(expansion-overview) -->
|
||||
|
||||
### Expansion-panel content
|
||||
|
||||
Each expansion-panel must include a header and may optionally include an action bar.
|
||||
|
||||
#### Header
|
||||
|
||||
The `<md-expansion-panel-header>` shows a summary of the panel content and acts
|
||||
as the control for expanding and collapsing. This header may optionally contain an
|
||||
`<md-panel-title>` and an `<md-panel-description>`, which format the content of the
|
||||
header to align with Material Design specifications.
|
||||
|
||||
By default, the expansion-panel header includes a toggle icon at the end of the
|
||||
header to indicate the expansion state. This icon can be hidden via the
|
||||
`hideToggle` property.
|
||||
|
||||
```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>This is the primary content of the panel.</p>
|
||||
|
||||
</md-expansion-panel>
|
||||
```
|
||||
|
||||
#### Action bar
|
||||
|
||||
Actions may optionally be included at the bottom of the panel, visible only when the expansion is in its
|
||||
expanded state.
|
||||
|
||||
```html
|
||||
<md-expansion-panel>
|
||||
<md-expansion-panel-header>
|
||||
This is the expansion title
|
||||
</md-expansion-panel-header>
|
||||
|
||||
<p>This is the primary content of the panel.</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>
|
||||
<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>
|
||||
```
|
||||
@@ -0,0 +1 @@
|
||||
/** No CSS for this example */
|
||||
@@ -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>
|
||||
@@ -0,0 +1,8 @@
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'expansion-overview-example',
|
||||
templateUrl: 'expansion-overview-example.html',
|
||||
})
|
||||
export class ExpansionOverviewExample {}
|
||||
@@ -0,0 +1,9 @@
|
||||
.example-headers-align .mat-expansion-panel-header-title,
|
||||
.example-headers-align .mat-expansion-panel-header-description {
|
||||
flex-basis: 0;
|
||||
}
|
||||
|
||||
.example-headers-align .mat-expansion-panel-header-description {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<md-accordion class="example-headers-align">
|
||||
<md-expansion-panel [expanded]="step === 0" (opened)="setStep(0)" hideToggle="true">
|
||||
<md-expansion-panel-header>
|
||||
<md-panel-title>
|
||||
Personal data
|
||||
</md-panel-title>
|
||||
<md-panel-description>
|
||||
Type your name and age
|
||||
<md-icon>account_circle</md-icon>
|
||||
</md-panel-description>
|
||||
</md-expansion-panel-header>
|
||||
|
||||
<md-input-container>
|
||||
<input mdInput placeholder="First name">
|
||||
</md-input-container>
|
||||
|
||||
<md-input-container>
|
||||
<input mdInput type="number" min="1" placeholder="Age">
|
||||
</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)="setStep(1)" hideToggle="true">
|
||||
<md-expansion-panel-header>
|
||||
<md-panel-title>
|
||||
Destination
|
||||
</md-panel-title>
|
||||
<md-panel-description>
|
||||
Type the country name
|
||||
<md-icon>map</md-icon>
|
||||
</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)="setStep(2)" hideToggle="true">
|
||||
<md-expansion-panel-header>
|
||||
<md-panel-title>
|
||||
Day of the trip
|
||||
</md-panel-title>
|
||||
<md-panel-description>
|
||||
Inform the date you wish to travel
|
||||
<md-icon>date_range</md-icon>
|
||||
</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>
|
||||
@@ -0,0 +1,23 @@
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'expansion-steps-example',
|
||||
templateUrl: 'expansion-steps-example.html',
|
||||
styleUrls: ['expansion-steps-example.css']
|
||||
})
|
||||
export class ExpansionStepsExample {
|
||||
step = 0;
|
||||
|
||||
setStep(index: number) {
|
||||
this.step = index;
|
||||
}
|
||||
|
||||
nextStep() {
|
||||
this.step++;
|
||||
}
|
||||
|
||||
prevStep() {
|
||||
this.step--;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user