From 0abfac2b04c7197b4d23456e6432fefebed6159e Mon Sep 17 00:00:00 2001 From: Ajay Gandecha Date: Fri, 19 Apr 2024 07:44:02 -0400 Subject: [PATCH] Add Reopening Time to OH Panel, Make OH Panel Responsive (#385) * Add Reopening Time to OH Panel, Make OH Panel Responsive * Fix Month and Date Orientation --- .../src/app/coworking/coworking.module.ts | 8 +++- .../operating-hours-panel.widget.css | 22 ++++++++++ .../operating-hours-panel.widget.html | 42 ++++++++++++------- .../operating-hours-panel.widget.ts | 22 ++++++++++ 4 files changed, 76 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/coworking/coworking.module.ts b/frontend/src/app/coworking/coworking.module.ts index fd3b5bfb8..f9c366aaa 100644 --- a/frontend/src/app/coworking/coworking.module.ts +++ b/frontend/src/app/coworking/coworking.module.ts @@ -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'; @@ -47,7 +50,8 @@ import { AmbassadorRoomListComponent } from './ambassador-home/ambassador-room/l ConfirmReservationComponent, NewReservationPageComponent, DateSelector, - OperatingHoursDialog + OperatingHoursDialog, + OperatingHoursCapitalizationPipe ], imports: [ CommonModule, diff --git a/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.css b/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.css index 43107c3b3..d5e609627 100644 --- a/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.css +++ b/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.css @@ -23,6 +23,7 @@ margin-right: 8px; padding: 0 16px; color: white; + width: fit-content; } .open .badge { @@ -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; + } + +} \ No newline at end of file diff --git a/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.html b/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.html index 1debc4e32..5552cc289 100644 --- a/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.html +++ b/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.html @@ -1,20 +1,30 @@ - -
- Open - until {{ openOperatingHours!.end | date: 'h:mma' | lowercase }} -
-
- - Closed - - +
+ +
+ Open + until {{ openOperatingHours!.end | date: 'h:mma' | lowercase }} +
+
+ + + Closed + Open + {{ + operatingHours[0]!.start + | date: "EEE, MMM d 'at' h:mma" + | operatingHoursCapitalizationPipe + }} + + + +
diff --git a/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.ts b/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.ts index 102d7f33e..8ea34a9b2 100644 --- a/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.ts +++ b/frontend/src/app/coworking/widgets/operating-hours-panel/operating-hours-panel.widget.ts @@ -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', @@ -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(); + } +}