Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Outreachy Task Submission] Add Keyboard Support For Add Post Modal #975

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
<div mat-dialog-content>
<app-spinner class="spinner" *ngIf="!types"></app-spinner>
<ul role="list" class="types-list" *ngIf="!!types" [data-qa]="'add-post-modal-surveys'">
<li *ngFor="let type of types">
<li *ngFor="let type of types" [attr.aria-label]="type.name">
<div
matRipple
*ngIf="type.visible"
role="listitem"
[ngStyle]="{ '--color': type.color }"
[mat-dialog-close]="{ type: type.id }"
[routerLink]="['/post/create/', type.id]"
(keydown.enter)="gotoForm(type.id)"
mat-dialog-close
class="type-item"
[data-qa]="'add-post-modal-surveys-item' + type.id"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
margin: 0;
padding: 0;
list-style: none;
display: grid;
grid-template-columns: 1fr;
grid-gap: 5px;

@include breakpoint-min($tablet) {
columns: 2;
grid-template-columns: repeat(2, 1fr);
}
}

.type-item {
cursor: pointer;
padding: 15px 12px;
position: relative;
margin-bottom: 8px;
background: var(--color-neutral-10);
border-radius: 4px;
border-inline-start: 5px solid var(--color);
height: 100%;
}

.spinner {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Component } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { SurveysService, SurveyItem, generalHelpers } from '@mzima-client/sdk';

@Component({
Expand All @@ -9,7 +11,11 @@ import { SurveysService, SurveyItem, generalHelpers } from '@mzima-client/sdk';
export class AddPostModalComponent {
public types: SurveyItem[];

constructor(private surveysService: SurveysService) {
constructor(
private surveysService: SurveysService,
private dialog: MatDialog,
private router: Router,
) {
this.getPostAllowedTypes();
}

Expand All @@ -27,4 +33,9 @@ export class AddPostModalComponent {
},
});
}

public gotoForm(id: number) {
this.dialog.closeAll();
this.router.navigate(['/post/create/', id]);
}
}
Loading