Skip to content

Commit a70a8c3

Browse files
feat(badge): implement square shape (#12681)
* feat(badge): implement shape property Co-authored-by: Simeon Simeonoff <[email protected]>
1 parent a6f418c commit a70a8c3

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

projects/igniteui-angular/src/lib/badge/badge.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,24 @@ export class IgxBadgeComponent {
133133
@HostBinding('class.igx-badge')
134134
public cssClass = 'igx-badge';
135135

136+
/**
137+
* Sets a square shape to the badge, if `shape` is set to `square`.
138+
* By default the shape of the badge is rounded.
139+
*
140+
* @example
141+
* ```html
142+
* <igx-badge shape="square"></igx-badge>
143+
* ```
144+
*/
145+
@Input()
146+
public shape: 'rounded' | 'square' = 'rounded';
147+
148+
/** @hidden @internal */
149+
@HostBinding('class.igx-badge--square')
150+
public get _squareShape(): boolean {
151+
return this.shape === 'square';
152+
}
153+
136154
/**
137155
* Sets/gets the aria-label attribute value.
138156
*

projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-component.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
@extend %igx-badge--error !optional;
4040
}
4141

42+
@include m(square) {
43+
@extend %igx-badge--square !optional;
44+
}
45+
4246
@include m(hidden) {
4347
@extend %igx-badge--hidden !optional;
4448
}

projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@
127127
}
128128
}
129129

130+
%igx-badge--square {
131+
border-radius: 0;
132+
}
133+
130134
%igx-badge-value {
131135
white-space: nowrap;
132136
padding: $badge-value-padding;

src/app/badge/badge.sample.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h4 class="sample-title">In conjunction with the
99

1010
<div class="avatar-sample">
1111
<igx-avatar icon="face" size="medium"></igx-avatar>
12-
<igx-badge value="8"></igx-badge>
12+
<igx-badge value="8" shape="square"></igx-badge>
1313
</div>
1414

1515
<div class="avatar-sample">

0 commit comments

Comments
 (0)