Skip to content

Commit

Permalink
Add Reopening Time to OH Panel, Make OH Panel Responsive (#385)
Browse files Browse the repository at this point in the history
* Add Reopening Time to OH Panel, Make OH Panel Responsive

* Fix Month and Date Orientation
  • Loading branch information
ajaygandecha authored Apr 19, 2024
1 parent 72fe4aa commit 0abfac2
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 18 deletions.
8 changes: 6 additions & 2 deletions frontend/src/app/coworking/coworking.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { MatCardModule } from '@angular/material/card';
import { CoworkingReservationCard } from './widgets/coworking-reservation-card/coworking-reservation-card';
import { CoworkingDropInCard } from './widgets/dropin-availability-card/dropin-availability-card.widget';
import { MatListModule } from '@angular/material/list';
import { CoworkingHoursCard } from './widgets/operating-hours-panel/operating-hours-panel.widget';
import {
CoworkingHoursCard,
OperatingHoursCapitalizationPipe
} from './widgets/operating-hours-panel/operating-hours-panel.widget';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatTableModule } from '@angular/material/table';
import { ReservationComponent } from './reservation/reservation.component';
Expand Down Expand Up @@ -47,7 +50,8 @@ import { AmbassadorRoomListComponent } from './ambassador-home/ambassador-room/l
ConfirmReservationComponent,
NewReservationPageComponent,
DateSelector,
OperatingHoursDialog
OperatingHoursDialog,
OperatingHoursCapitalizationPipe
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
margin-right: 8px;
padding: 0 16px;
color: white;
width: fit-content;
}

.open .badge {
Expand All @@ -43,3 +44,24 @@
flex-direction: row;
width: 100%;
}

button {
margin-left: auto;
}

@media only screen and (max-width: 900px) {
.header-row {
flex-direction: column;
align-items: baseline;
}

.mat-mdc-card-title {
display: flex;
flex-direction: column;
}

button {
margin-left: 0;
}

}
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
<mat-card appearance="outlined">
<mat-card-header class="header">
<mat-card-title
class="hours-title open"
*ngIf="openOperatingHours; else closed">
<div class="header-row">
<span class="badge">Open</span>
until {{ openOperatingHours!.end | date: 'h:mma' | lowercase }}
</div>
</mat-card-title>
<ng-template #closed>
<mat-card-title class="hours-title closed"
><span class="badge">Closed</span></mat-card-title
>
</ng-template>
<button mat-stroked-button id="hours-button" (click)="openDialog()">
All Hours
</button>
<div class="header-row">
<mat-card-title
class="hours-title open"
*ngIf="openOperatingHours; else closed">
<div class="header-row">
<span class="badge">Open</span>
until {{ openOperatingHours!.end | date: 'h:mma' | lowercase }}
</div>
</mat-card-title>
<ng-template #closed>
<mat-card-title class="hours-title closed">
<span class="badge">Closed</span>
<span *ngIf="operatingHours.length > 0"
>Open
{{
operatingHours[0]!.start
| date: "EEE, MMM d 'at' h:mma"
| operatingHoursCapitalizationPipe
}}</span
>
</mat-card-title>
</ng-template>
<button mat-stroked-button id="hours-button" (click)="openDialog()">
All Hours
</button>
</div>
</mat-card-header>
</mat-card>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, Input } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { OperatingHours } from 'src/app/coworking/coworking.models';
import { OperatingHoursDialog } from '../operating-hours-dialog/operating-hours-dialog.widget';
import { Pipe, PipeTransform } from '@angular/core';

@Component({
selector: 'coworking-operating-hours-panel',
Expand All @@ -20,3 +21,24 @@ export class CoworkingHoursCard {
});
}
}

/** Local pipe that capitalizes the first letter of the string. */
@Pipe({
name: 'operatingHoursCapitalizationPipe'
})
export class OperatingHoursCapitalizationPipe implements PipeTransform {
transform(sentence: string | null | undefined): string {
if (!sentence) return '';
let newSentence = '';
sentence.split(' ').forEach((segment) => {
if (segment != 'at') {
newSentence +=
segment[0].toUpperCase() + segment.substring(1).toLowerCase();
} else {
newSentence += segment;
}
newSentence += ' ';
});
return newSentence.trimEnd();
}
}

0 comments on commit 0abfac2

Please sign in to comment.