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 >
1
4
< 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 1
1
import {
2
2
ChangeDetectionStrategy ,
3
3
Component ,
4
+ ContentChild ,
4
5
HostBinding ,
5
6
Input ,
7
+ TemplateRef ,
6
8
ViewEncapsulation
7
9
} from '@angular/core' ;
8
10
import { BaseButton } from '@sbb-esta/angular-core/base' ;
11
+ import { IconDirective } from '@sbb-esta/angular-core/icon-directive' ;
9
12
10
13
@Component ( {
11
14
// tslint:disable-next-line:component-selector
@@ -21,6 +24,28 @@ export class ButtonComponent extends BaseButton {
21
24
*/
22
25
@Input ( ) mode : 'primary' | 'secondary' | 'ghost' | 'alternative' | 'icon' = 'primary' ;
23
26
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
+
24
49
/** @docs -private */
25
50
@HostBinding ( 'class.sbb-button-alternative' )
26
51
get _alternativeClass ( ) {
You can’t perform that action at this time.
0 commit comments