Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add labels to icon-only buttons

Benjamin Bädorf14b11e50f409
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index 2c7fa8998a8..b2c36d39f7b 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -1267,3 +1267,9 @@ en:
load_error_message: 'There was an error loading the form'
validation_error_message: 'Please fix the errors present in the form'
advanced_settings: 'Advanced settings'
+
+ spot:
+ filter_chip:
+ remove: 'Remove'
+ drop_modal:
+ Close: 'Close'
diff --git a/frontend/src/app/shared/components/project-include/project-include.component.html b/frontend/src/app/shared/components/project-include/project-include.component.html
index 91b108d3ff9..6306721f01b 100644
--- a/frontend/src/app/shared/components/project-include/project-include.component.html
+++ b/frontend/src/app/shared/components/project-include/project-include.component.html
@@ -41,7 +41,7 @@
>
<span
slot="before"
- class="op-icon icon-search"
+ class="spot-icon spot-icon_search"
></span>
</spot-text-field>
diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal.component.html b/frontend/src/app/spot/components/drop-modal/drop-modal.component.html
index 0cf769a450d..4e6994f7bd5 100644
--- a/frontend/src/app/spot/components/drop-modal/drop-modal.component.html
+++ b/frontend/src/app/spot/components/drop-modal/drop-modal.component.html
@@ -9,7 +9,7 @@
<button
class="spot-drop-modal--close-button spot-button"
type="button"
- aria-label="Close"
+ [attr.aria-label]="text.close"
(click)="close()"
>
<span class="spot-icon spot-icon_close"></span>
diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
index 4b492a3a43b..a52ebe24b85 100644
--- a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
+++ b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts
@@ -7,6 +7,7 @@ import {
OnDestroy,
} from '@angular/core';
import { KeyCodes } from 'core-app/shared/helpers/keyCodes.enum';
+import { I18nService } from 'core-app/core/i18n/i18n.service';
enum SpotDropModalAlignmentOption {
BottomCenter = 'bottom-center',
@@ -58,6 +59,12 @@ export class SpotDropModalComponent implements OnDestroy {
return `spot-drop-modal--body_${this.alignment}`;
}
+ public text = {
+ close: this.i18n.t('js.spot.drop_modal.close'),
+ };
+
+ constructor(readonly i18n:I18nService) {}
+
close():void {
this.open = false;
}
diff --git a/frontend/src/app/spot/components/filter-chip/filter-chip.component.html b/frontend/src/app/spot/components/filter-chip/filter-chip.component.html
index 888b0f12a92..73e6c09a3f4 100644
--- a/frontend/src/app/spot/components/filter-chip/filter-chip.component.html
+++ b/frontend/src/app/spot/components/filter-chip/filter-chip.component.html
@@ -3,5 +3,14 @@
class="spot-filter-chip--remove"
type="button"
(click)="remove.emit()"
->x</button>
-<div class="spot-filter-chip--title">{{ title }}</div>
+ [attr.aria-label]="text.remove"
+>
+ <span class="spot-icon spot-icon_close"></span>
+</button>
+<div class="spot-filter-chip--title">
+ <span
+ *ngIf="icon"
+ [ngClass]="iconClasses"
+ ></span>
+ {{ title }}
+</div>
diff --git a/frontend/src/app/spot/components/filter-chip/filter-chip.component.ts b/frontend/src/app/spot/components/filter-chip/filter-chip.component.ts
index 4ab898ae898..528b7251da3 100644
--- a/frontend/src/app/spot/components/filter-chip/filter-chip.component.ts
+++ b/frontend/src/app/spot/components/filter-chip/filter-chip.component.ts
@@ -5,6 +5,7 @@ import {
Input,
Output,
} from '@angular/core';
+import { I18nService } from 'core-app/core/i18n/i18n.service';
@Component({
selector: 'spot-filter-chip',
@@ -16,6 +17,20 @@ export class SpotFilterChipComponent {
@Input() removable = true;
@Input() title = '';
+ @Input() icon = '';
@Output() remove = new EventEmitter<void>();
+
+ public text = {
+ remove: this.i18n.t('js.spot.filter_chip.remove'),
+ };
+
+ public get iconClasses() {
+ return [
+ 'spot-icon',
+ `spot-icon_${this.icon}`,
+ ];
+ }
+
+ constructor(readonly i18n:I18nService) {}
}
diff --git a/frontend/src/app/spot/spot-docs.component.html b/frontend/src/app/spot/spot-docs.component.html
index 3f310e05d6b..da5839270a5 100644
--- a/frontend/src/app/spot/spot-docs.component.html
+++ b/frontend/src/app/spot/spot-docs.component.html
@@ -138,8 +138,18 @@ Currently selected value is {{ toggleValue }}
(remove)="onRemoveChip()"
></spot-filter-chip>
<spot-filter-chip
- [removable]="false"
title="Unremovable chip"
+ [removable]="false"
+></spot-filter-chip>
+<spot-filter-chip
+ title="Default chip with icon"
+ icon="bell"
+ (remove)="onRemoveChip()"
+></spot-filter-chip>
+<spot-filter-chip
+ icon="bell"
+ title="Unremovable chip with icon"
+ [removable]="false"
></spot-filter-chip>
<h1>Text Field</h1>