From: Afreen Misbah Date: Thu, 3 Jul 2025 11:09:25 +0000 (+0530) Subject: mgr/dashboard: Add generic component for icons X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=fa5160444e71b09e2e845c040206e34c775c27ff;p=ceph.git mgr/dashboard: Add generic component for icons Fixes https://tracker.ceph.com/issues/71947 Fixes https://tracker.ceph.com/issues/71933 Signed-off-by: Afreen Misbah --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/card-row/card-row.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/card-row/card-row.component.html index a1e3e6b0b3711..a5a2f495f1c06 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/card-row/card-row.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/card-row/card-row.component.html @@ -52,18 +52,18 @@ {{ data.categoryPgAmount?.clean }} - - + + {{ data.info }} - - + + @@ -73,9 +73,9 @@ {{ data.categoryPgAmount?.warning }} - - + + @@ -85,9 +85,9 @@ {{ data.categoryPgAmount?.unknown }} - - + + @@ -99,13 +99,15 @@ - + + {{ data.up }} - - + + {{ data.up }} @@ -151,36 +153,36 @@ {{ data.up }} - - + type="success"> + {{ data.down }} - - + + {{ data }} - + {{ data - dropdownTotalError }} - + {{ dropdownTotalError }} - + @@ -211,17 +213,17 @@ {{ data.value.ok }} - - + type="success"> + {{ data.value.error }} - - + + diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts index 64bed45df778a..868a09b7af182 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts @@ -89,6 +89,7 @@ import InfoIcon from '@carbon/icons/es/information/16'; import CopyIcon from '@carbon/icons/es/copy/32'; import downloadIcon from '@carbon/icons/es/download/16'; import { ChartsModule } from '@carbon/charts-angular'; +import { IconComponent } from './icon/icon.component'; @NgModule({ imports: [ @@ -172,7 +173,8 @@ import { ChartsModule } from '@carbon/charts-angular'; FormAdvancedFieldsetComponent, UpgradableComponent, ProgressComponent, - SidePanelComponent + SidePanelComponent, + IconComponent ], providers: [provideCharts(withDefaultRegisterables())], exports: [ @@ -212,7 +214,8 @@ import { ChartsModule } from '@carbon/charts-angular'; FormAdvancedFieldsetComponent, UpgradableComponent, ProgressComponent, - SidePanelComponent + SidePanelComponent, + IconComponent ] }) export class ComponentsModule { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.html new file mode 100644 index 0000000000000..2e6522bd93891 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.html @@ -0,0 +1,23 @@ +@if (type === ICON_TYPE.danger) { + +} + +@if (type === ICON_TYPE.info) { + +} + +@if (type === ICON_TYPE.success) { + +} + +@if (type === ICON_TYPE.warning) { + +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.scss b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.scss new file mode 100644 index 0000000000000..e0a3d2050b34e --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.scss @@ -0,0 +1,17 @@ +@use '@carbon/styles/scss/theme'; + +.success-icon { + color: theme.$support-success; +} + +.danger-icon { + color: theme.$support-error; +} + +.info-icon { + color: theme.$support-info; +} + +.warning-icon { + color: theme.$support-caution-major; +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.spec.ts new file mode 100644 index 0000000000000..c14459401a617 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.spec.ts @@ -0,0 +1,22 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { IconComponent } from './icon.component'; + +describe('IconComponent', () => { + let component: IconComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [IconComponent] + }).compileComponents(); + + fixture = TestBed.createComponent(IconComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.ts new file mode 100644 index 0000000000000..82bb1981836aa --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/icon/icon.component.ts @@ -0,0 +1,15 @@ +import { Component, Input } from '@angular/core'; +import { ICON_TYPE, Icons, IconsSize } from '../../enum/icons.enum'; + +@Component({ + selector: 'cd-icon', + templateUrl: './icon.component.html', + styleUrl: './icon.component.scss' +}) +export class IconComponent { + @Input() type!: keyof typeof ICON_TYPE; + @Input() size: IconsSize = IconsSize.size16; + + readonly ICONS = Icons; + readonly ICON_TYPE = ICON_TYPE; +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts index 81f5e68ae3bc6..9d5c95413209a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/enum/icons.enum.ts @@ -36,7 +36,6 @@ export enum Icons { infoCircle = 'information--filled', // Info on landing page questionCircle = 'help', danger = 'warning--filled', - // success = 'fa fa-check-circle', success = 'checkmark--filled', check = 'checkmark', // Notification check show = 'view', // Show @@ -99,3 +98,17 @@ export enum Icons { spin = 'fa fa-spin', // To get any icon to rotate inverse = 'fa fa-inverse' // To get an alternative icon color } + +export enum IconsSize { + size16 = '16', + size20 = '20', + size24 = '24', + size32 = '32' +} + +export const ICON_TYPE = { + danger: 'danger', + info: 'info', + success: 'success', + warning: 'warning' +} as const; diff --git a/src/pybind/mgr/dashboard/frontend/src/styles/_carbon-defaults.scss b/src/pybind/mgr/dashboard/frontend/src/styles/_carbon-defaults.scss index 26b06564bd7ab..f66478d7ccba6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/styles/_carbon-defaults.scss +++ b/src/pybind/mgr/dashboard/frontend/src/styles/_carbon-defaults.scss @@ -177,10 +177,6 @@ Tabs background: var(--cds-layer-01); } -.cds-success-color { - fill: theme.$support-success; -} - .cds-danger-color { fill: theme.$support-error; }