diff --git a/src/app/components/components/expansion-panel/expansion-panel.component.html b/src/app/components/components/expansion-panel/expansion-panel.component.html index 25348b1f61..a0a18b90bb 100644 --- a/src/app/components/components/expansion-panel/expansion-panel.component.html +++ b/src/app/components/components/expansion-panel/expansion-panel.component.html @@ -71,6 +71,61 @@

md-padding class

+ + Grouped Expansion panels + Add margin animation between grouped expansion panels + + + + Demo + + +
+

md-padding class

+
+
+ +
+

md-padding class

+
+
+ +
+

md-padding class

+
+
+
+
+ + Code + +

HTML:

+ + + +
+

md-padding class

+
+
+ +
+

md-padding class

+
+
+ +
+

md-padding class

+
+
+ + ]]> +
+
+
+
+
+ Expansion panel with summary and templates Expand to view form, collapse to view summary diff --git a/src/platform/core/expansion-panel/README.md b/src/platform/core/expansion-panel/README.md index c491b6ec4f..62ad04b9a1 100644 --- a/src/platform/core/expansion-panel/README.md +++ b/src/platform/core/expansion-panel/README.md @@ -56,3 +56,24 @@ Example for HTML usage: ... add content that ``` + +# td-expansion-panel-group + +`td-expansion-panel-group` is used to group expansion panel components. + +It adds margin between them when expanded following the material spec. + +## Usage + +Example for HTML usage: + +```html + + + ..content + + + ..content + + +``` diff --git a/src/platform/core/expansion-panel/_expansion-panel-theme.scss b/src/platform/core/expansion-panel/_expansion-panel-theme.scss index 3ef2787967..609fd88fac 100644 --- a/src/platform/core/expansion-panel/_expansion-panel-theme.scss +++ b/src/platform/core/expansion-panel/_expansion-panel-theme.scss @@ -7,20 +7,26 @@ $warn: map-get($theme, warn); $foreground: map-get($theme, foreground); $background: map-get($theme, background); - // panel - td-expansion-panel { - @include mat-elevation(1); - background-color: mat-color($background, card); - &:not(:last-of-type) { - & .td-expanded { - margin-bottom: $margin; + + .td-expansion-panel-group { + .td-expansion-panel { + transition: 120ms ease-in; + &:not(:last-of-type) { + &.td-expanded { + margin-bottom: $margin; + } } - } - &:not(:first-of-type) { - & .td-expanded { - margin-top: $margin; + &:not(:first-of-type) { + &.td-expanded { + margin-top: $margin; + } } } + } + + .td-expansion-panel { + @include mat-elevation(1); + background-color: mat-color($background, card); .td-expansion-panel-header { &:focus, &:hover { diff --git a/src/platform/core/expansion-panel/expansion-panel-group.component.html b/src/platform/core/expansion-panel/expansion-panel-group.component.html new file mode 100644 index 0000000000..95a0b70bdc --- /dev/null +++ b/src/platform/core/expansion-panel/expansion-panel-group.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/platform/core/expansion-panel/expansion-panel-group.component.scss b/src/platform/core/expansion-panel/expansion-panel-group.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/platform/core/expansion-panel/expansion-panel-group.component.ts b/src/platform/core/expansion-panel/expansion-panel-group.component.ts new file mode 100644 index 0000000000..fbef2d651d --- /dev/null +++ b/src/platform/core/expansion-panel/expansion-panel-group.component.ts @@ -0,0 +1,15 @@ +import { Component, Renderer2, ElementRef } from '@angular/core'; + +@Component({ + selector: 'td-expansion-panel-group', + styleUrls: ['./expansion-panel-group.component.scss' ], + templateUrl: './expansion-panel-group.component.html', +}) +export class TdExpansionPanelGroupComponent { + + constructor(private _renderer: Renderer2, + private _elementRef: ElementRef) { + this._renderer.addClass(this._elementRef.nativeElement, 'td-expansion-panel-group'); + } + +} diff --git a/src/platform/core/expansion-panel/expansion-panel.component.html b/src/platform/core/expansion-panel/expansion-panel.component.html index b3ee929ec7..20d0f27f31 100644 --- a/src/platform/core/expansion-panel/expansion-panel.component.html +++ b/src/platform/core/expansion-panel/expansion-panel.component.html @@ -1,38 +1,35 @@ -
-
+ +
- -
-
- - {{label}} -
-
- - {{sublabel}} -
- - keyboard_arrow_down - keyboard_arrow_up + *ngIf="!expansionPanelHeader" + layout="row" + layout-align="start center" + flex> +
+ + {{label}}
+
+ + {{sublabel}} +
+ + keyboard_arrow_down + keyboard_arrow_up
-
- -
-
- -
-
\ No newline at end of file +
+
+ +
+
+ +
diff --git a/src/platform/core/expansion-panel/expansion-panel.component.scss b/src/platform/core/expansion-panel/expansion-panel.component.scss index 010de28b91..5393cb8db7 100644 --- a/src/platform/core/expansion-panel/expansion-panel.component.scss +++ b/src/platform/core/expansion-panel/expansion-panel.component.scss @@ -1,22 +1,19 @@ :host { display: block; - .td-expansion-panel { - transition: 400ms all ease; - .td-expansion-panel-header { - position: relative; - outline: none; - &:focus, - &:hover { - cursor: pointer; - } - &.mat-disabled { - background: none; - cursor: auto; - } - .td-expansion-panel-header-content { - height: 48px; - padding: 0 16px; - } + .td-expansion-panel-header { + position: relative; + outline: none; + &:focus, + &:hover { + cursor: pointer; + } + &.mat-disabled { + background: none; + cursor: auto; + } + .td-expansion-panel-header-content { + height: 48px; + padding: 0 16px; } } } diff --git a/src/platform/core/expansion-panel/expansion-panel.component.ts b/src/platform/core/expansion-panel/expansion-panel.component.ts index a28b7ab951..d1d6b515ca 100644 --- a/src/platform/core/expansion-panel/expansion-panel.component.ts +++ b/src/platform/core/expansion-panel/expansion-panel.component.ts @@ -1,4 +1,5 @@ -import { Component, Directive, Input, Output, TemplateRef, ViewContainerRef, ContentChild } from '@angular/core'; +import { Component, Directive, Input, Output, TemplateRef, ViewContainerRef, ContentChild, + ElementRef, Renderer2 } from '@angular/core'; import { EventEmitter } from '@angular/core'; import { TemplatePortalDirective } from '@angular/material'; @@ -107,6 +108,11 @@ export class TdExpansionPanelComponent { */ @Output() collapsed: EventEmitter = new EventEmitter(); + constructor(private _renderer: Renderer2, + private _elementRef: ElementRef) { + this._renderer.addClass(this._elementRef.nativeElement, 'td-expansion-panel'); + } + /** * Method executed when [TdExpansionPanelComponent] is clicked. */ @@ -149,8 +155,10 @@ export class TdExpansionPanelComponent { if (this._expand !== newExpand) { this._expand = newExpand; if (newExpand) { + this._renderer.addClass(this._elementRef.nativeElement, 'td-expanded'); this._onExpanded(); } else { + this._renderer.removeClass(this._elementRef.nativeElement, 'td-expanded'); this._onCollapsed(); } return true; diff --git a/src/platform/core/expansion-panel/expansion-panel.module.ts b/src/platform/core/expansion-panel/expansion-panel.module.ts index 508675cffe..a3713c3445 100644 --- a/src/platform/core/expansion-panel/expansion-panel.module.ts +++ b/src/platform/core/expansion-panel/expansion-panel.module.ts @@ -6,8 +6,10 @@ import { MdRippleModule, MdIconModule, PortalModule } from '@angular/material'; import { TdExpansionPanelComponent, TdExpansionPanelHeaderDirective, TdExpansionPanelLabelDirective, TdExpansionPanelSublabelDirective, TdExpansionPanelSummaryComponent } from './expansion-panel.component'; +import { TdExpansionPanelGroupComponent } from './expansion-panel-group.component'; const TD_EXPANSION_PANEL: Type[] = [ + TdExpansionPanelGroupComponent, TdExpansionPanelComponent, TdExpansionPanelHeaderDirective, TdExpansionPanelLabelDirective, @@ -16,6 +18,7 @@ const TD_EXPANSION_PANEL: Type[] = [ ]; export { TdExpansionPanelComponent } from './expansion-panel.component'; +export { TdExpansionPanelGroupComponent } from './expansion-panel-group.component'; @NgModule({ imports: [