From 86d9994dcbce2963498593043b2134085837b3e8 Mon Sep 17 00:00:00 2001 From: Lewis Larsen Date: Fri, 23 Aug 2024 16:46:00 +0100 Subject: [PATCH] style: Improved quiet mode --- .../profile/quiet-mode-manager.blade.php | 163 ++++++++++++++---- 1 file changed, 125 insertions(+), 38 deletions(-) diff --git a/resources/views/livewire/profile/quiet-mode-manager.blade.php b/resources/views/livewire/profile/quiet-mode-manager.blade.php index 687f812a..7cc2ce7d 100644 --- a/resources/views/livewire/profile/quiet-mode-manager.blade.php +++ b/resources/views/livewire/profile/quiet-mode-manager.blade.php @@ -7,6 +7,12 @@ new class extends Component { public ?string $quietUntilDate = null; + public array $suggestedDates = [ + '7' => '1 week', + '14' => '2 weeks', + '30' => '1 month', + ]; + public bool $isFaqOpen = false; public function mount(): void { @@ -22,7 +28,7 @@ private function refreshQuietUntilDate(): void #[Computed] public function isQuietModeActive(): bool { - return $this->quietUntilDate !== null && Carbon::parse($this->quietUntilDate)->isFuture(); + return Auth::user()->quiet_until && Auth::user()->quiet_until->isFuture(); } #[Computed] @@ -31,7 +37,12 @@ public function daysLeft(): int if (!$this->isQuietModeActive) { return 0; } - return floor(now()->floatDiffInDays(Carbon::parse($this->quietUntilDate))); + return max(0, now()->diffInDays(Auth::user()->quiet_until, false)); + } + + public function selectSuggestedDate(int $days): void + { + $this->quietUntilDate = now()->addDays($days)->format('Y-m-d'); } public function enableQuietMode(): void @@ -39,7 +50,8 @@ public function enableQuietMode(): void $this->validate([ 'quietUntilDate' => 'required|date|after:today', ], [ - 'quietUntilDate.required' => __('Please specify the duration for which notifications should be silenced.') + 'quietUntilDate.required' => __('Please specify the duration for which notifications should be silenced.'), + 'quietUntilDate.after' => __('The quiet mode end date must be after today.'), ]); $user = Auth::user(); @@ -61,6 +73,11 @@ public function disableQuietMode(): void $this->quietUntilDate = null; Toaster::success(__("Welcome back! Quiet Mode is now off.")); } + + public function toggleFaq(): void + { + $this->isFaqOpen = !$this->isFaqOpen; + } } ?> @@ -73,16 +90,30 @@ public function disableQuietMode(): void heroicon-o-bell-snooze -
-
+
+

{{ __('What is Quiet Mode?') }}

+
+

{{ __('Quiet Mode temporarily pauses most notifications from our platform.') }}

+

{{ __('It\'s ideal for:') }}

+
    +
  • {{ __('Vacations') }}
  • +
  • {{ __('Taking a break from updates') }}
  • +
+

{{ __('While active, we pause your backup task notifications.') }}

+

{{ __('You can set a specific duration for Quiet Mode.') }}

+

{{ __('We\'ll email you when your Quiet Mode is about to expire.') }}

+
+
+ +
+
- @svg('heroicon-o-bell-snooze', 'w-10 h-10 text-gray-500 dark:text-gray-400 mr-4')
-

{{ __('Quiet Mode Status') }}

+

{{ __('Quiet Mode Status') }}

@if ($this->isQuietModeActive) @php - $friendlyDate = Carbon::parse($quietUntilDate)->format('l, F j'); + $friendlyDate = Auth::user()->quiet_until->format('l, F j'); $daysLeft = $this->daysLeft; @endphp @if ($daysLeft > 1) @@ -93,50 +124,106 @@ public function disableQuietMode(): void {{ __('Ending today (:date)', ['date' => $friendlyDate]) }} @endif @else - {{ __('Currently inactive') }} + {{ __('Currently not using quiet mode.') }} @endif

- @if ($this->isQuietModeActive) -
-
-
- @svg('heroicon-s-envelope', 'h-5 w-5 text-blue-400') +
+ @if (!$this->isQuietModeActive) +
+
+ + +
-
-

- {{ __("You'll receive an email when your Quiet Mode period ends.") }} +

+ + {{ __('Quick Duration Options') }} + +

+ {{ __('Click a duration to pre-fill the input above.') }}

+
+ @foreach ($suggestedDates as $days => $label) + + @endforeach +
-
-
- @endif - -
- @if (!$this->isQuietModeActive) -
- - - -
- - {{ __('Enable Quiet Mode') }} - + + {{ __('Enable Quiet Mode') }} + + @else {{ __('Disable Quiet Mode') }} @endif
+ +
+ +
+
+
{{ __('What happens to my notifications during Quiet Mode?') }}
+

{{ __('During Quiet Mode, all but the most critical notifications about your backup tasks are paused. They are automatically un-paused when you leave Quiet Mode.') }}

+
+
+
{{ __('Can I end Quiet Mode early?') }}
+

{{ __('Yes, you can disable Quiet Mode at any time by clicking the "Disable Quiet Mode" button. You\'ll immediately start receiving notifications again.') }}

+
+
+
{{ __('Will I receive any notifications during Quiet Mode?') }}
+

+ {{ __('During Quiet Mode, you\'ll receive two types of important notifications:') }} +

+
    +
  • {{ __('An email alert when your Quiet Mode period is about to end.') }}
  • +
  • {{ __('Any critical backup failure emails. These are not additional notifications, but rather essential alerts about the status of your backups.') }}
  • +
+

+ {{ __('All other notifications will not be sent.') }} +

+
+
+