From 163e16fee8b689e64aafabc4c064385487facc5d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:18:46 +0000 Subject: [PATCH 1/7] Initial plan From 5c5216819b943411da9b694628fb262b99fab586 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:26:39 +0000 Subject: [PATCH 2/7] Add badge sizes, dot type, and improved outline implementation Co-authored-by: kdinev <1472513+kdinev@users.noreply.github.com> --- .../src/lib/badge/badge.component.ts | 42 ++++++++++++++++++- .../components/badge/_badge-component.scss | 4 ++ .../styles/components/badge/_badge-theme.scss | 17 +++++++- src/app/badge/badge.sample.html | 2 + src/app/badge/badge.sample.ts | 10 ++++- 5 files changed, 70 insertions(+), 5 deletions(-) diff --git a/projects/igniteui-angular/src/lib/badge/badge.component.ts b/projects/igniteui-angular/src/lib/badge/badge.component.ts index fe3990d8b12..4dfc3422562 100644 --- a/projects/igniteui-angular/src/lib/badge/badge.component.ts +++ b/projects/igniteui-angular/src/lib/badge/badge.component.ts @@ -11,9 +11,20 @@ export const IgxBadgeType = { INFO: 'info', SUCCESS: 'success', WARNING: 'warning', - ERROR: 'error' + ERROR: 'error', + DOT: 'dot' } as const; export type IgxBadgeType = (typeof IgxBadgeType)[keyof typeof IgxBadgeType]; + +/** + * Determines the igxBadge size + */ +export const IgxBadgeSize = { + SMALL: 'small', + MEDIUM: 'medium', + LARGE: 'large' +} as const; +export type IgxBadgeSize = (typeof IgxBadgeSize)[keyof typeof IgxBadgeSize]; /** * Badge provides visual notifications used to decorate avatars, menus, etc. * @@ -62,7 +73,7 @@ export class IgxBadgeComponent { * Sets/gets the type of the badge. * * @remarks - * Allowed values are `primary`, `info`, `success`, `warning`, `error`. + * Allowed values are `primary`, `info`, `success`, `warning`, `error`, `dot`. * Providing an invalid value won't display a badge. * * @example @@ -73,6 +84,21 @@ export class IgxBadgeComponent { @Input() public type: string | IgxBadgeType = IgxBadgeType.PRIMARY; + /** + * Sets/gets the size of the badge. + * + * @remarks + * Allowed values are `small`, `medium`, `large`. + * Default value is `medium`. + * + * @example + * ```html + * + * ``` + */ + @Input() + public size: string | IgxBadgeSize = IgxBadgeSize.MEDIUM; + /** * Sets/gets the value to be displayed inside the badge. * @@ -219,4 +245,16 @@ export class IgxBadgeComponent { public get errorClass() { return this.type === IgxBadgeType.ERROR; } + + @HostBinding('class.igx-badge--dot') + public get dotClass() { + return this.type === IgxBadgeType.DOT; + } + + @HostBinding('style.--component-size') + protected get componentSize() { + if (this.size) { + return `var(--ig-size-${this.size})`; + } + } } diff --git a/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-component.scss b/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-component.scss index 909374bd288..a630908f0f7 100644 --- a/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-component.scss +++ b/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-component.scss @@ -35,6 +35,10 @@ @extend %igx-badge--error !optional; } + @include m(dot) { + @extend %igx-badge--dot !optional; + } + @include m(outlined) { @extend %igx-badge--outlined !optional; } diff --git a/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss b/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss index 02a91673ef0..fc02f8e88f7 100644 --- a/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss +++ b/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss @@ -10,7 +10,7 @@ $variant: map.get($theme, '_meta', 'theme'); %igx-badge-display { - --size: #{rem(22px)}; + --size: var(--component-size, #{rem(22px)}); --_badge-size: var(--size); display: inline-flex; @@ -45,7 +45,8 @@ } %igx-badge--outlined { - box-shadow: inset 0 0 0 rem(if($variant != 'bootstrap', 2px, 1px)) var-get($theme, 'border-color'); + outline: rem(if($variant != 'bootstrap', 2px, 1px)) solid var-get($theme, 'border-color'); + outline-offset: rem(-2px); } %igx-badge--square { @@ -73,6 +74,18 @@ background: color($color: 'error'); } + %igx-badge--dot { + --size: #{rem(8px)}; + min-width: var(--size); + min-height: var(--size); + padding: 0; + + .igx-badge__value, + igx-icon { + display: none; + } + } + %igx-badge--hidden { visibility: hidden; } diff --git a/src/app/badge/badge.sample.html b/src/app/badge/badge.sample.html index 47e674f1fb3..b8b8dae5114 100644 --- a/src/app/badge/badge.sample.html +++ b/src/app/badge/badge.sample.html @@ -5,6 +5,7 @@

Angular Badge

[type]="properties.variant" value="8" [shape]="properties.shape" + [size]="properties.size" [outlined]="properties.outlined" >
@@ -12,6 +13,7 @@

Angular Badge

bluetooth diff --git a/src/app/badge/badge.sample.ts b/src/app/badge/badge.sample.ts index f8bcb45c90a..fa445d5facc 100644 --- a/src/app/badge/badge.sample.ts +++ b/src/app/badge/badge.sample.ts @@ -47,10 +47,17 @@ export class BadgeSampleComponent { variant: { control: { type: 'select', - options: ['default', 'info', 'success', 'warning', 'error'], + options: ['default', 'info', 'success', 'warning', 'error', 'dot'], defaultValue: 'default' } }, + size: { + control: { + type: 'button-group', + options: ['small', 'medium', 'large'], + defaultValue: 'medium' + } + }, outlined: { control: { type: 'boolean', @@ -84,6 +91,7 @@ export class BadgeSampleComponent { success: 'success', warning: 'warning', error: 'danger', + dot: 'primary', }) ); From f3866017e67f56b260777673e2b0dbe52d174166 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:28:31 +0000 Subject: [PATCH 3/7] Add tests for badge size and dot type features Co-authored-by: kdinev <1472513+kdinev@users.noreply.github.com> --- .../src/lib/badge/badge.component.spec.ts | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/projects/igniteui-angular/src/lib/badge/badge.component.spec.ts b/projects/igniteui-angular/src/lib/badge/badge.component.spec.ts index d6654f0974e..3b7e382bde6 100644 --- a/projects/igniteui-angular/src/lib/badge/badge.component.spec.ts +++ b/projects/igniteui-angular/src/lib/badge/badge.component.spec.ts @@ -1,7 +1,7 @@ import { Component, ViewChild } from '@angular/core'; import { TestBed, waitForAsync } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { IgxBadgeComponent, IgxBadgeType } from './badge.component'; +import { IgxBadgeComponent, IgxBadgeType, IgxBadgeSize } from './badge.component'; describe('Badge', () => { beforeEach(waitForAsync(() => { @@ -11,7 +11,9 @@ describe('Badge', () => { InitBadgeWithDefaultsComponent, InitBadgeWithIconComponent, IgxBadgeComponent, - InitBadgeWithIconARIAComponent + InitBadgeWithIconARIAComponent, + InitBadgeWithSizeComponent, + InitBadgeWithDotTypeComponent ] }).compileComponents(); })); @@ -87,6 +89,33 @@ describe('Badge', () => { const container = fixture.nativeElement.querySelectorAll('.igx-badge')[0]; expect(container.getAttribute('aria-roledescription')).toMatch(expectedDescription); }); + + it('Initializes badge with size', () => { + const fixture = TestBed.createComponent(InitBadgeWithSizeComponent); + fixture.detectChanges(); + const badge = fixture.componentInstance.badge; + const domBadge = fixture.debugElement.query(By.css('igx-badge')).nativeElement; + + expect(badge.size).toBe(IgxBadgeSize.LARGE); + expect(domBadge.style.getPropertyValue('--component-size')).toBe('var(--ig-size-large)'); + }); + + it('Initializes badge with default size', () => { + const fixture = TestBed.createComponent(InitBadgeWithDefaultsComponent); + fixture.detectChanges(); + const badge = fixture.componentInstance.badge; + + expect(badge.size).toBe(IgxBadgeSize.MEDIUM); + }); + + it('Initializes badge with dot type', () => { + const fixture = TestBed.createComponent(InitBadgeWithDotTypeComponent); + fixture.detectChanges(); + const badge = fixture.componentInstance.badge; + + expect(badge.type).toBe(IgxBadgeType.DOT); + expect(fixture.debugElement.query(By.css('.igx-badge--dot'))).toBeTruthy(); + }); }); @Component({ @@ -120,3 +149,19 @@ class InitBadgeWithIconComponent { class InitBadgeWithIconARIAComponent { @ViewChild(IgxBadgeComponent, { static: true }) public badge: IgxBadgeComponent; } + +@Component({ + template: ``, + imports: [IgxBadgeComponent] +}) +class InitBadgeWithSizeComponent { + @ViewChild(IgxBadgeComponent, { static: true }) public badge: IgxBadgeComponent; +} + +@Component({ + template: ``, + imports: [IgxBadgeComponent] +}) +class InitBadgeWithDotTypeComponent { + @ViewChild(IgxBadgeComponent, { static: true }) public badge: IgxBadgeComponent; +} From 807c4ea8e098fbda1522a6f5ea35ad599d59c8d9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:30:37 +0000 Subject: [PATCH 4/7] Improve badge colors for WCAG AA compliance and update sizing Co-authored-by: kdinev <1472513+kdinev@users.noreply.github.com> --- .../styles/components/badge/_badge-theme.scss | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss b/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss index fc02f8e88f7..69aec14cf76 100644 --- a/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss +++ b/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss @@ -10,7 +10,7 @@ $variant: map.get($theme, '_meta', 'theme'); %igx-badge-display { - --size: var(--component-size, #{rem(22px)}); + --size: var(--component-size, var(--ig-size-medium, #{rem(22px)})); --_badge-size: var(--size); display: inline-flex; @@ -60,18 +60,38 @@ %igx-badge--success { background: color($color: 'success'); + color: white; + + igx-icon { + color: white; + } } %igx-badge--info { background: color($color: 'info'); + color: white; + + igx-icon { + color: white; + } } %igx-badge--warn { background: color($color: 'warn'); + color: white; + + igx-icon { + color: white; + } } %igx-badge--error { background: color($color: 'error'); + color: white; + + igx-icon { + color: white; + } } %igx-badge--dot { From 8bed749c42f81dd0966b73b75fb0ab7699947ca7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:34:59 +0000 Subject: [PATCH 5/7] Update badge README documentation with new features Co-authored-by: kdinev <1472513+kdinev@users.noreply.github.com> --- .../igniteui-angular/src/lib/badge/README.md | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/projects/igniteui-angular/src/lib/badge/README.md b/projects/igniteui-angular/src/lib/badge/README.md index cd6e11958ac..f36aab187ce 100644 --- a/projects/igniteui-angular/src/lib/badge/README.md +++ b/projects/igniteui-angular/src/lib/badge/README.md @@ -1,7 +1,7 @@ # igx-badge The **igx-badge** component is an absolutely positioned element that can be used in tandem with other components such as avatars, navigation menus, or anywhere else in an app where some active indication is required. -With the igx-badge you can display active count or an icon in several different predefined styles. +With the igx-badge you can display active count or an icon in several different predefined styles and sizes. A walkthrough of how to get started can be found [here](https://www.infragistics.com/products/ignite-ui-angular/angular/components/badge.html) # Usage @@ -13,10 +13,13 @@ A walkthrough of how to get started can be found [here](https://www.infragistics | Name | Type | Description | |:----------|:-------------:|:------| | `id` | string | Unique identifier of the component. If not provided it will be automatically generated.| -| `type` | string | Set the type of the badge to either `primary`, `info`, `success`, `warning`, or `error`. This will change the background color of the badge according to the values set in the default theme. | +| `type` | string | Set the type of the badge to either `primary`, `info`, `success`, `warning`, `error`, or `dot`. This will change the background color of the badge according to the values set in the default theme. The `dot` type creates a minimal badge without any content. | +| `size` | string | Set the size of the badge to either `small`, `medium`, or `large`. Default is `medium`. | | `position` | string | Set the position of the badge relative to its parent container to either `top-right`, `top-left`, `bottom-right`, or `bottom-left`. | | `value` | string | Set the value to be displayed inside the badge. | | `icon` | string | Set an icon for the badge from the material icons set. Will not be displayed if `value` for the badge is already set. | +| `outlined` | boolean | Set whether the badge should have an outline. Default is `false`. | +| `shape` | string | Set the shape of the badge to either `rounded` or `square`. Default is `rounded`. | # Examples @@ -26,3 +29,16 @@ Using `igx-badge` with the `igx-avatar` component to show active status. ``` + +Using `igx-badge` with different sizes. +```html + + + +``` + +Using `igx-badge` as a dot indicator. +```html + + +``` From ba8095d91de9e80e50e44836849002aad24b5a0b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 09:36:57 +0000 Subject: [PATCH 6/7] Enhance badge sample with comprehensive examples of new features Co-authored-by: kdinev <1472513+kdinev@users.noreply.github.com> --- src/app/badge/badge.sample.html | 110 ++++++++++++++++++++++++++------ src/app/badge/badge.sample.scss | 42 +++++++++++- 2 files changed, 131 insertions(+), 21 deletions(-) diff --git a/src/app/badge/badge.sample.html b/src/app/badge/badge.sample.html index b8b8dae5114..f5f1c518bfa 100644 --- a/src/app/badge/badge.sample.html +++ b/src/app/badge/badge.sample.html @@ -1,23 +1,97 @@
-

Angular Badge

- -
- - - bluetooth - +

Angular Badge - Interactive

+
+
+ + With Value +
+
+ + bluetooth + + With Icon +
+
+ + + bluetooth + + On Avatar +
+
+ +

Size Variants

+
+
+ + Small +
+
+ + Medium +
+
+ + Large +
+
+ +

Dot Type

+
+
+ + Default Dot +
+
+ + Outlined Dot +
+
+ + + Dot on Avatar +
+
+ +

Type Variants

+
+
+ + Primary +
+
+ + Info +
+
+ + Success +
+
+ + Warning +
+
+ + Error +
diff --git a/src/app/badge/badge.sample.scss b/src/app/badge/badge.sample.scss index 85f3261b048..692a4eca183 100644 --- a/src/app/badge/badge.sample.scss +++ b/src/app/badge/badge.sample.scss @@ -1,16 +1,52 @@ .wrapper { display: grid; grid-template-columns: repeat(2, 1fr); + gap: 48px; + padding: 24px; } .badges { - place-items: center; - display: grid; - grid-template-columns: subgrid; + place-items: start; + display: flex; + flex-direction: column; gap: 24px; } +.sample-title { + margin: 16px 0 8px 0; + font-size: 18px; + font-weight: 600; +} + +.badge-examples { + display: flex; + flex-wrap: wrap; + gap: 32px; + align-items: center; +} + +.badge-item { + display: flex; + flex-direction: column; + align-items: center; + gap: 8px; + position: relative; + + span { + font-size: 12px; + color: #666; + margin-top: 4px; + } +} + .avatar-sample { display: flex; align-items: center; + position: relative; + + igx-badge { + position: absolute; + top: -4px; + right: -4px; + } } From 4b53f14292bb743f65106cd2f76cc1988d661516 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:08:22 +0000 Subject: [PATCH 7/7] Refactor badge: Remove size input, change dot from type to boolean property Co-authored-by: kdinev <1472513+kdinev@users.noreply.github.com> --- .../igniteui-angular/src/lib/badge/README.md | 20 ++++--- .../src/lib/badge/badge.component.spec.ts | 42 +++++--------- .../src/lib/badge/badge.component.ts | 56 ++++++------------- .../styles/components/badge/_badge-theme.scss | 2 +- src/app/badge/badge.sample.html | 36 ++++++------ src/app/badge/badge.sample.ts | 14 ++--- 6 files changed, 65 insertions(+), 105 deletions(-) diff --git a/projects/igniteui-angular/src/lib/badge/README.md b/projects/igniteui-angular/src/lib/badge/README.md index f36aab187ce..a342c2e09c6 100644 --- a/projects/igniteui-angular/src/lib/badge/README.md +++ b/projects/igniteui-angular/src/lib/badge/README.md @@ -13,8 +13,8 @@ A walkthrough of how to get started can be found [here](https://www.infragistics | Name | Type | Description | |:----------|:-------------:|:------| | `id` | string | Unique identifier of the component. If not provided it will be automatically generated.| -| `type` | string | Set the type of the badge to either `primary`, `info`, `success`, `warning`, `error`, or `dot`. This will change the background color of the badge according to the values set in the default theme. The `dot` type creates a minimal badge without any content. | -| `size` | string | Set the size of the badge to either `small`, `medium`, or `large`. Default is `medium`. | +| `type` | string | Set the type of the badge to either `primary`, `info`, `success`, `warning`, or `error`. This will change the background color of the badge according to the values set in the default theme. | +| `dot` | boolean | Set whether the badge is displayed as a minimal dot indicator without any content. Default is `false`. | | `position` | string | Set the position of the badge relative to its parent container to either `top-right`, `top-left`, `bottom-right`, or `bottom-left`. | | `value` | string | Set the value to be displayed inside the badge. | | `icon` | string | Set an icon for the badge from the material icons set. Will not be displayed if `value` for the badge is already set. | @@ -30,15 +30,17 @@ Using `igx-badge` with the `igx-avatar` component to show active status. ``` -Using `igx-badge` with different sizes. +Using `igx-badge` as a dot indicator for notifications. ```html - - - + + ``` -Using `igx-badge` as a dot indicator. +Using different badge types. ```html - - + + + + + ``` diff --git a/projects/igniteui-angular/src/lib/badge/badge.component.spec.ts b/projects/igniteui-angular/src/lib/badge/badge.component.spec.ts index 3b7e382bde6..6d398d5e871 100644 --- a/projects/igniteui-angular/src/lib/badge/badge.component.spec.ts +++ b/projects/igniteui-angular/src/lib/badge/badge.component.spec.ts @@ -1,7 +1,7 @@ import { Component, ViewChild } from '@angular/core'; import { TestBed, waitForAsync } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { IgxBadgeComponent, IgxBadgeType, IgxBadgeSize } from './badge.component'; +import { IgxBadgeComponent, IgxBadgeType } from './badge.component'; describe('Badge', () => { beforeEach(waitForAsync(() => { @@ -12,8 +12,7 @@ describe('Badge', () => { InitBadgeWithIconComponent, IgxBadgeComponent, InitBadgeWithIconARIAComponent, - InitBadgeWithSizeComponent, - InitBadgeWithDotTypeComponent + InitBadgeWithDotComponent ] }).compileComponents(); })); @@ -90,31 +89,24 @@ describe('Badge', () => { expect(container.getAttribute('aria-roledescription')).toMatch(expectedDescription); }); - it('Initializes badge with size', () => { - const fixture = TestBed.createComponent(InitBadgeWithSizeComponent); - fixture.detectChanges(); - const badge = fixture.componentInstance.badge; - const domBadge = fixture.debugElement.query(By.css('igx-badge')).nativeElement; - - expect(badge.size).toBe(IgxBadgeSize.LARGE); - expect(domBadge.style.getPropertyValue('--component-size')).toBe('var(--ig-size-large)'); - }); - - it('Initializes badge with default size', () => { - const fixture = TestBed.createComponent(InitBadgeWithDefaultsComponent); + it('Initializes badge with dot property', () => { + const fixture = TestBed.createComponent(InitBadgeWithDotComponent); fixture.detectChanges(); const badge = fixture.componentInstance.badge; - expect(badge.size).toBe(IgxBadgeSize.MEDIUM); + expect(badge.dot).toBeTruthy(); + expect(fixture.debugElement.query(By.css('.igx-badge--dot'))).toBeTruthy(); }); - it('Initializes badge with dot type', () => { - const fixture = TestBed.createComponent(InitBadgeWithDotTypeComponent); + it('Initializes success badge as dot', () => { + const fixture = TestBed.createComponent(InitBadgeWithDotComponent); fixture.detectChanges(); const badge = fixture.componentInstance.badge; - expect(badge.type).toBe(IgxBadgeType.DOT); + expect(badge.type).toBe(IgxBadgeType.SUCCESS); + expect(badge.dot).toBeTruthy(); expect(fixture.debugElement.query(By.css('.igx-badge--dot'))).toBeTruthy(); + expect(fixture.debugElement.query(By.css('.igx-badge--success'))).toBeTruthy(); }); }); @@ -151,17 +143,9 @@ class InitBadgeWithIconARIAComponent { } @Component({ - template: ``, - imports: [IgxBadgeComponent] -}) -class InitBadgeWithSizeComponent { - @ViewChild(IgxBadgeComponent, { static: true }) public badge: IgxBadgeComponent; -} - -@Component({ - template: ``, + template: ``, imports: [IgxBadgeComponent] }) -class InitBadgeWithDotTypeComponent { +class InitBadgeWithDotComponent { @ViewChild(IgxBadgeComponent, { static: true }) public badge: IgxBadgeComponent; } diff --git a/projects/igniteui-angular/src/lib/badge/badge.component.ts b/projects/igniteui-angular/src/lib/badge/badge.component.ts index 4dfc3422562..7d2671b99e4 100644 --- a/projects/igniteui-angular/src/lib/badge/badge.component.ts +++ b/projects/igniteui-angular/src/lib/badge/badge.component.ts @@ -11,20 +11,9 @@ export const IgxBadgeType = { INFO: 'info', SUCCESS: 'success', WARNING: 'warning', - ERROR: 'error', - DOT: 'dot' + ERROR: 'error' } as const; export type IgxBadgeType = (typeof IgxBadgeType)[keyof typeof IgxBadgeType]; - -/** - * Determines the igxBadge size - */ -export const IgxBadgeSize = { - SMALL: 'small', - MEDIUM: 'medium', - LARGE: 'large' -} as const; -export type IgxBadgeSize = (typeof IgxBadgeSize)[keyof typeof IgxBadgeSize]; /** * Badge provides visual notifications used to decorate avatars, menus, etc. * @@ -73,7 +62,7 @@ export class IgxBadgeComponent { * Sets/gets the type of the badge. * * @remarks - * Allowed values are `primary`, `info`, `success`, `warning`, `error`, `dot`. + * Allowed values are `primary`, `info`, `success`, `warning`, `error`. * Providing an invalid value won't display a badge. * * @example @@ -84,21 +73,6 @@ export class IgxBadgeComponent { @Input() public type: string | IgxBadgeType = IgxBadgeType.PRIMARY; - /** - * Sets/gets the size of the badge. - * - * @remarks - * Allowed values are `small`, `medium`, `large`. - * Default value is `medium`. - * - * @example - * ```html - * - * ``` - */ - @Input() - public size: string | IgxBadgeSize = IgxBadgeSize.MEDIUM; - /** * Sets/gets the value to be displayed inside the badge. * @@ -209,6 +183,20 @@ export class IgxBadgeComponent { @HostBinding('class.igx-badge--outlined') public outlined = false; + /** + * Sets/gets whether the badge is displayed as a dot. + * When true, the badge will be rendered as a minimal 8px indicator without any content. + * Default value is `false`. + * + * @example + * ```html + * + * ``` + */ + @Input({transform: booleanAttribute}) + @HostBinding('class.igx-badge--dot') + public dot = false; + /** * Defines a human-readable, accessor, author-localized description for * the `type` and the `icon` or `value` of the element. @@ -245,16 +233,4 @@ export class IgxBadgeComponent { public get errorClass() { return this.type === IgxBadgeType.ERROR; } - - @HostBinding('class.igx-badge--dot') - public get dotClass() { - return this.type === IgxBadgeType.DOT; - } - - @HostBinding('style.--component-size') - protected get componentSize() { - if (this.size) { - return `var(--ig-size-${this.size})`; - } - } } diff --git a/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss b/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss index 69aec14cf76..94044f175bd 100644 --- a/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss +++ b/projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss @@ -10,7 +10,7 @@ $variant: map.get($theme, '_meta', 'theme'); %igx-badge-display { - --size: var(--component-size, var(--ig-size-medium, #{rem(22px)})); + --size: var(--ig-size, #{rem(22px)}); --_badge-size: var(--size); display: inline-flex; diff --git a/src/app/badge/badge.sample.html b/src/app/badge/badge.sample.html index f5f1c518bfa..ed76062ab36 100644 --- a/src/app/badge/badge.sample.html +++ b/src/app/badge/badge.sample.html @@ -7,8 +7,8 @@

Angular Badge - Interactive

[type]="properties.variant" value="8" [shape]="properties.shape" - [size]="properties.size" [outlined]="properties.outlined" + [dot]="properties.dot" > With Value
@@ -16,8 +16,8 @@

Angular Badge - Interactive

bluetooth @@ -28,8 +28,8 @@

Angular Badge - Interactive

bluetooth @@ -37,35 +37,35 @@

Angular Badge - Interactive

-

Size Variants

+

Dot Badges

- - Small + + Primary Dot
- - Medium + + Info Dot
- - Large + + Success Dot +
+
+ + Warning Dot
-
- -

Dot Type

-
- - Default Dot + + Error Dot
- + Outlined Dot
- + Dot on Avatar
diff --git a/src/app/badge/badge.sample.ts b/src/app/badge/badge.sample.ts index fa445d5facc..b2f466206af 100644 --- a/src/app/badge/badge.sample.ts +++ b/src/app/badge/badge.sample.ts @@ -47,18 +47,17 @@ export class BadgeSampleComponent { variant: { control: { type: 'select', - options: ['default', 'info', 'success', 'warning', 'error', 'dot'], + options: ['default', 'info', 'success', 'warning', 'error'], defaultValue: 'default' } }, - size: { + outlined: { control: { - type: 'button-group', - options: ['small', 'medium', 'large'], - defaultValue: 'medium' + type: 'boolean', + defaultValue: false } }, - outlined: { + dot: { control: { type: 'boolean', defaultValue: false @@ -90,8 +89,7 @@ export class BadgeSampleComponent { info: 'info', success: 'success', warning: 'warning', - error: 'danger', - dot: 'primary', + error: 'danger' }) );