File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
projects/sbb-esta/angular-business/button/src/button Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ < span class ="sbb-svgsprite-icon ">
2+ < ng-container *ngTemplateOutlet ="icon "> </ ng-container >
3+ </ span >
14< ng-content > </ ng-content >
5+ < span class ="sbb-svgsprite-icon ">
6+ < ng-container *ngTemplateOutlet ="icon "> </ ng-container >
7+ </ span >
Original file line number Diff line number Diff line change 11import {
22 ChangeDetectionStrategy ,
33 Component ,
4+ ContentChild ,
45 HostBinding ,
56 Input ,
7+ TemplateRef ,
68 ViewEncapsulation
79} from '@angular/core' ;
810import { BaseButton } from '@sbb-esta/angular-core/base' ;
11+ import { IconDirective } from '@sbb-esta/angular-core/icon-directive' ;
912
1013@Component ( {
1114 // tslint:disable-next-line:component-selector
@@ -21,6 +24,28 @@ export class ButtonComponent extends BaseButton {
2124 */
2225 @Input ( ) mode : 'primary' | 'secondary' | 'ghost' | 'alternative' | 'icon' = 'primary' ;
2326
27+ /**
28+ * Template that will contain icons.
29+ * Use the *sbbIcon structural directive to provide the desired icon.
30+ */
31+ @Input ( )
32+ get icon ( ) : TemplateRef < any > {
33+ return this . _contentIcon || this . _icon ;
34+ }
35+ set icon ( icon : TemplateRef < any > ) {
36+ this . _icon = icon ;
37+ }
38+ private _icon : TemplateRef < any > ;
39+
40+ /** @docs -private */
41+ @HostBinding ( 'class.sbb-button-has-icon' ) get buttonHasIconClass ( ) {
42+ return ! ! this . icon ;
43+ }
44+
45+ /** @docs -private */
46+ @ContentChild ( IconDirective , { read : TemplateRef , static : false } )
47+ _contentIcon : TemplateRef < any > ;
48+
2449 /** @docs -private */
2550 @HostBinding ( 'class.sbb-button-alternative' )
2651 get _alternativeClass ( ) {
You can’t perform that action at this time.
0 commit comments