|
| 1 | +# Using Modal Popup with Whats-New Component |
| 2 | + |
| 3 | +This guide shows you how to use the modal wrapper to display the whats-new component as a popup on your home.blade.php page. |
| 4 | + |
| 5 | +## Option 1: Simple Modal Wrapper |
| 6 | + |
| 7 | +Add this to your `home.blade.php` file: |
| 8 | + |
| 9 | +```blade |
| 10 | +<!-- Include the modal wrapper --> |
| 11 | +<x-version-platform-manager::modal-wrapper id="whats-new-modal" :autoShow="true"> |
| 12 | + <!-- Your whats-new component inside the modal --> |
| 13 | + <x-version-platform-manager::whats-new :autoShow="false"></x-version-platform-manager::whats-new> |
| 14 | + |
| 15 | + <!-- Optional footer with buttons --> |
| 16 | + <x-slot name="footer"> |
| 17 | + <button type="button" onclick="closeModal()" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> |
| 18 | + Got it! |
| 19 | + </button> |
| 20 | + <button type="button" onclick="closeModal()" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"> |
| 21 | + Close |
| 22 | + </button> |
| 23 | + </x-slot> |
| 24 | +</x-version-platform-manager::modal-wrapper> |
| 25 | +``` |
| 26 | + |
| 27 | +## Option 2: Manual Trigger Modal |
| 28 | + |
| 29 | +If you want to trigger the modal manually (e.g., with a button): |
| 30 | + |
| 31 | +```blade |
| 32 | +<!-- Button to trigger modal --> |
| 33 | +<button onclick="showModal()" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700"> |
| 34 | + Show Updates |
| 35 | +</button> |
| 36 | +
|
| 37 | +<!-- Modal wrapper --> |
| 38 | +<x-version-platform-manager::modal-wrapper id="whats-new-modal" :autoShow="false"> |
| 39 | + <x-version-platform-manager::whats-new :autoShow="false"></x-version-platform-manager::whats-new> |
| 40 | + |
| 41 | + <x-slot name="footer"> |
| 42 | + <button type="button" onclick="closeModal()" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> |
| 43 | + Got it! |
| 44 | + </button> |
| 45 | + </x-slot> |
| 46 | +</x-version-platform-manager::modal-wrapper> |
| 47 | +``` |
| 48 | + |
| 49 | +## Option 3: Custom Styled Modal |
| 50 | + |
| 51 | +For a more customized appearance: |
| 52 | + |
| 53 | +```blade |
| 54 | +<x-version-platform-manager::modal-wrapper id="announcement-modal" :autoShow="true" maxWidth="max-w-4xl"> |
| 55 | + <div class="text-center"> |
| 56 | + <div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-green-100 mb-4"> |
| 57 | + <svg class="h-6 w-6 text-green-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"> |
| 58 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2l4 -4" /> |
| 59 | + </svg> |
| 60 | + </div> |
| 61 | + |
| 62 | + <h2 class="text-2xl font-bold text-gray-900 mb-6"> |
| 63 | + 🎉 Exciting News: 🎉 <br> Major Updates to Improve Your Experience! |
| 64 | + </h2> |
| 65 | + |
| 66 | + <!-- Your whats-new component --> |
| 67 | + <x-version-platform-manager::whats-new :autoShow="false"></x-version-platform-manager::whats-new> |
| 68 | + |
| 69 | + <div class="bg-green-50 border-l-4 border-green-400 p-4 rounded mt-6"> |
| 70 | + <p class="text-green-800 mb-2">We're excited for you to experience these updates.</p> |
| 71 | + <p class="text-green-800">If you have any questions or comments, please don't hesitate to reach out.</p> |
| 72 | + <p class="text-green-900 font-semibold mt-3">Best regards,<br>Kitio Internacional d.o.o.</p> |
| 73 | + </div> |
| 74 | + </div> |
| 75 | + |
| 76 | + <x-slot name="footer"> |
| 77 | + <button type="button" onclick="closeModal()" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> |
| 78 | + Got it! |
| 79 | + </button> |
| 80 | + <button type="button" onclick="closeModal()" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"> |
| 81 | + Close |
| 82 | + </button> |
| 83 | + </x-slot> |
| 84 | +</x-version-platform-manager::modal-wrapper> |
| 85 | +``` |
| 86 | + |
| 87 | +## Configuration Options |
| 88 | + |
| 89 | +### Modal Wrapper Props: |
| 90 | +- `id`: Unique identifier for the modal (default: 'modal-wrapper') |
| 91 | +- `show`: Whether to show the modal initially (default: false) |
| 92 | +- `autoShow`: Whether to auto-show the modal after page load (default: false) |
| 93 | +- `maxWidth`: Tailwind max-width class (default: 'max-w-2xl') |
| 94 | + |
| 95 | +### Available Functions: |
| 96 | +- `showModal()`: Show the modal |
| 97 | +- `closeModal()`: Close the modal |
| 98 | + |
| 99 | +## Features: |
| 100 | +- ✅ Auto-shows after page load (if autoShow is true) |
| 101 | +- ✅ Closes when clicking outside |
| 102 | +- ✅ Closes with Escape key |
| 103 | +- ✅ Responsive design |
| 104 | +- ✅ Customizable width |
| 105 | +- ✅ Optional footer with buttons |
| 106 | +- ✅ Works with any content, including whats-new component |
| 107 | + |
| 108 | +## Example: Complete home.blade.php |
| 109 | + |
| 110 | +```blade |
| 111 | +@extends('layouts.app') |
| 112 | +
|
| 113 | +@section('content') |
| 114 | +<div class="container mx-auto px-4 py-8"> |
| 115 | + <h1 class="text-3xl font-bold text-gray-900 mb-8">Welcome to Our Platform</h1> |
| 116 | + |
| 117 | + <!-- Your existing content here --> |
| 118 | + |
| 119 | + <!-- Modal with whats-new component --> |
| 120 | + <x-version-platform-manager::modal-wrapper id="whats-new-modal" :autoShow="true"> |
| 121 | + <x-version-platform-manager::whats-new :autoShow="false"></x-version-platform-manager::whats-new> |
| 122 | + |
| 123 | + <x-slot name="footer"> |
| 124 | + <button type="button" onclick="closeModal()" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> |
| 125 | + Got it! |
| 126 | + </button> |
| 127 | + </x-slot> |
| 128 | + </x-version-platform-manager::modal-wrapper> |
| 129 | +</div> |
| 130 | +@endsection |
| 131 | +``` |
0 commit comments