Skip to content

Commit

Permalink
Merge pull request #483 from puzzle/bug/ux-error-font
Browse files Browse the repository at this point in the history
Adjust global error color and font weight
  • Loading branch information
peggimann authored Oct 20, 2023
2 parents c8b641d + 668833b commit 368078b
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 31 deletions.
10 changes: 5 additions & 5 deletions frontend/src/app/keyresult-type/keyresult-type.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<input class="input-fields metric-fields" formControlName="baseline" [attr.data-testId]="'baseline'" />
<div *ngIf="isTouchedOrDirty('baseline')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('baseline')">
{{ errorMessages[errorKey.toUpperCase()] }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</div>
Expand All @@ -58,7 +58,7 @@
/>
<div *ngIf="isTouchedOrDirty('stretchGoal')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('stretchGoal')">
{{ errorMessages[errorKey.toUpperCase()] }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</div>
Expand All @@ -80,7 +80,7 @@
<textarea class="input-fields" formControlName="commitZone" [attr.data-testId]="'commitZone'"></textarea>
<div *ngIf="isTouchedOrDirty('commitZone')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('commitZone')">
{{ errorMessages[errorKey.toUpperCase()] }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</div>
Expand All @@ -89,7 +89,7 @@
<textarea class="input-fields" formControlName="targetZone" [attr.data-testId]="'targetZone'"></textarea>
<div *ngIf="isTouchedOrDirty('targetZone')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('targetZone')">
{{ errorMessages[errorKey.toUpperCase()] }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</div>
Expand All @@ -102,7 +102,7 @@
></textarea>
<div *ngIf="isTouchedOrDirty('stretchZone')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('stretchZone')">
{{ errorMessages[errorKey.toUpperCase()] }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<mat-form-field appearance="outline">
<textarea matInput class="w-100" formControlName="changeInfo"></textarea>
<div *ngIf="isTouchedOrDirty('changeInfo')">
<mat-error class="fw-bold" *ngFor="let errorKey of getErrorKeysOfFormField('changeInfo')">
{{ getErrorMessage(errorKey) }}
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('changeInfo')">
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</mat-form-field>
Expand All @@ -15,8 +15,8 @@
<mat-form-field appearance="outline">
<textarea matInput formControlName="initiatives"></textarea>
<div *ngIf="isTouchedOrDirty('initiatives')">
<mat-error class="fw-bold" *ngFor="let errorKey of getErrorKeysOfFormField('initiatives')">
{{ getErrorMessage(errorKey) }}
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('initiatives')">
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import errorMessages from '../../../../../assets/errors/error-messages.json';
export class CheckInBaseInformationsComponent {
@Input()
dialogForm!: FormGroup;
protected readonly errorMessages: any = errorMessages;

isTouchedOrDirty(name: string) {
return this.dialogForm.get(name)?.dirty || this.dialogForm.get(name)?.touched;
Expand All @@ -19,10 +20,4 @@ export class CheckInBaseInformationsComponent {
const errors = this.dialogForm.get(name)?.errors;
return errors == null ? [] : Object.keys(errors);
}

getErrorMessage(key: string) {
return errorMessages[key.toUpperCase() as keyof typeof errorMessages];
}

protected readonly errorMessages = errorMessages;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
(focusin)="resetValue()"
></app-custom-input>
<div *ngIf="isTouchedOrDirty('value')">
<mat-error class="fw-bold error-font" *ngFor="let errorKey of getErrorKeysOfFormField('value')">
{{ errorMessages[errorKey.toUpperCase()] }}
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('value')">
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.error-font {
font-size: 13px;
}

.custom-input {
margin-top: 3px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ <h1 mat-dialog-title class="d-flex justify-content-center">This is an example di
<mat-label>Name</mat-label>
<input matInput formControlName="name" placeholder="Ex. Tom" />
<div *ngIf="isTouchedOrDirty('name')">
<mat-error class="fw-bold" *ngFor="let errorKey of getErrorKeysOfFormField('name')">
{{ errorMessages[errorKey.toUpperCase()] }}
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('name')">
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</mat-form-field>
Expand All @@ -17,8 +17,8 @@ <h1 mat-dialog-title class="d-flex justify-content-center">This is an example di
<mat-radio-button value="other">Other</mat-radio-button>
</mat-radio-group>
<div *ngIf="isTouchedOrDirty('gender')">
<mat-error class="fw-bold" *ngFor="let errorKey of getErrorKeysOfFormField('gender')">
{{ errorMessages[errorKey.toUpperCase()] }}
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('gender')">
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>

Expand All @@ -29,8 +29,8 @@ <h1 mat-dialog-title class="d-flex justify-content-center">This is an example di
</mat-select>
</mat-form-field>
<div *ngIf="isTouchedOrDirty('hobby')">
<mat-error class="fw-bold" *ngFor="let errorKey of getErrorKeysOfFormField('hobby')">
{{ errorMessages[errorKey.toUpperCase()] }}
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('hobby')">
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<textarea [attr.data-testId]="'titleInput'" class="input-fields" formControlName="title" id="title"></textarea>
<div *ngIf="isTouchedOrDirty('title')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('title')">
{{ errorMessages[errorKey.toUpperCase()] }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</div>
Expand Down Expand Up @@ -44,7 +44,7 @@
<textarea [attr.data-testId]="'descriptionInput'" class="input-fields" formControlName="description"></textarea>
<div *ngIf="isTouchedOrDirty('description')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('description')">
{{ errorMessages[errorKey.toUpperCase()] }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<textarea cdkFocusInitial formControlName="title" id="title" matInput placeholder="Objective Title"></textarea>
<span *ngIf="isTouchedOrDirty('title')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('title')">
{{ errorMessages[errorKey.toUpperCase()] }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</span>
</mat-form-field>
Expand All @@ -28,7 +28,7 @@
<textarea formControlName="description" matInput placeholder="Objective Beschreibung"></textarea>
<span *ngIf="isTouchedOrDirty('description')">
<mat-error *ngFor="let errorKey of getErrorKeysOfFormField('description')">
{{ errorMessages[errorKey.toUpperCase()] }}
{{ errorMessages[errorKey.toUpperCase().trim()] }}
</mat-error>
</span>
</mat-form-field>
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/style/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ body pzsh-backdrop {
border: none;
padding: 0;
}

.mat-mdc-form-field-error {
color: #b3261b;
}

0 comments on commit 368078b

Please sign in to comment.