From 834eda2b0eff84fa09b13f25f2245530e255e2b6 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Fri, 3 Sep 2021 00:13:46 +0200 Subject: [PATCH 01/28] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0502112..62c5e1e 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ It is currently not possible to add new fields to the support bubble's form. You If you're just looking to customize the field labels, intro text or success text (after the form submitted), you can publish the package's language files: ```bash -php artisan vendor:publish --provider="Spatie\LaravelSupportBubble\LaravelSupportBubbleServiceProvider" --tag=support-bubble-translations +php artisan vendor:publish --provider="Spatie\SupportBubble\SupportBubbleServiceProvider" --tag=support-bubble-translations ``` These published files can be found and changed in `resources/lang/vendor/laravel-support-bubble/en/`. @@ -167,7 +167,7 @@ You you're looking to change any more advanced styles, keep reading to learn how You can publish and change all views (including the JavaScript code) in this package: ```bash -php artisan vendor:publish --provider="Spatie\LaravelSupportBubble\LaravelSupportBubbleServiceProvider" --tag=support-bubble-views +php artisan vendor:publish --provider="Spatie\SupportBubble\SupportBubbleServiceProvider" --tag=support-bubble-views ``` These published views can be found and changed in `resources/views/vendor/laravel-support-bubble/`. From b5ba7f09fc7711c92d5af528eb89c5c6952cf2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20N=C3=BCrnberger?= Date: Fri, 3 Sep 2021 15:01:11 +0200 Subject: [PATCH 02/28] use `requiredIf` --- src/Http/Requests/SupportBubbleRequest.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Http/Requests/SupportBubbleRequest.php b/src/Http/Requests/SupportBubbleRequest.php index 22877ea..63a1ce3 100644 --- a/src/Http/Requests/SupportBubbleRequest.php +++ b/src/Http/Requests/SupportBubbleRequest.php @@ -3,19 +3,20 @@ namespace Spatie\SupportBubble\Http\Requests; use Illuminate\Foundation\Http\FormRequest; +use Illuminate\Validation\Rule; class SupportBubbleRequest extends FormRequest { public function rules() { return [ - 'name' => config('support-bubble.fields.name') ? 'required' : '', + 'name' => Rule::requiredIf(config('support-bubble.fields.name')), 'email' => [ 'email', - config('support-bubble.fields.email') ? 'required' : '', + Rule::requiredIf(config('support-bubble.fields.email')), ], - 'subject' => config('support-bubble.fields.subject') ? 'required' : '', - 'message' => config('support-bubble.fields.message') ? 'required' : '', + 'subject' => Rule::requiredIf(config('support-bubble.fields.subject')), + 'message' => Rule::requiredIf(config('support-bubble.fields.message')), 'url' => ['required', 'url'], ]; } From 5dc27331e31500635b7c231d509014457c8404f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Gabry=C5=9B?= Date: Fri, 3 Sep 2021 15:46:52 +0200 Subject: [PATCH 03/28] Made the submit button translatable --- resources/lang/en/support-bubble.php | 1 + resources/views/includes/form.blade.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/lang/en/support-bubble.php b/resources/lang/en/support-bubble.php index 963d4be..8a66e46 100644 --- a/resources/lang/en/support-bubble.php +++ b/resources/lang/en/support-bubble.php @@ -9,4 +9,5 @@ 'email_label' => 'E-mail', 'subject_label' => 'Subject', 'message_label' => 'How can we help?', + 'submit_label' => 'Submit', ]; diff --git a/resources/views/includes/form.blade.php b/resources/views/includes/form.blade.php index 9e1299c..3aedf6f 100644 --- a/resources/views/includes/form.blade.php +++ b/resources/views/includes/form.blade.php @@ -45,5 +45,5 @@ class="flex flex-col gap-6 text-base" /> @endif - + From 58f775f4a4a487b6179ea3cd1ecdf13d05f8bf1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Gabry=C5=9B?= Date: Fri, 3 Sep 2021 15:55:57 +0200 Subject: [PATCH 04/28] Added test --- tests/Components/SupportBubbleComponentTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Components/SupportBubbleComponentTest.php b/tests/Components/SupportBubbleComponentTest.php index 817a7c6..3ac8a1a 100644 --- a/tests/Components/SupportBubbleComponentTest.php +++ b/tests/Components/SupportBubbleComponentTest.php @@ -22,3 +22,8 @@ ->assertDontSee('john@example.com') ->assertDontSee('John Doe'); }); + +it('can render the submit button using the defult translation string', function () { + test()->blade('') + ->assertSee('Submit'); +}); From 587833d25a02ee2a748a1bf6d9805322913d58fa Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Fri, 3 Sep 2021 17:40:44 +0200 Subject: [PATCH 05/28] Update SupportBubbleComponentTest.php --- tests/Components/SupportBubbleComponentTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/Components/SupportBubbleComponentTest.php b/tests/Components/SupportBubbleComponentTest.php index 3ac8a1a..77cbbd1 100644 --- a/tests/Components/SupportBubbleComponentTest.php +++ b/tests/Components/SupportBubbleComponentTest.php @@ -23,7 +23,6 @@ ->assertDontSee('John Doe'); }); -it('can render the submit button using the defult translation string', function () { - test()->blade('') - ->assertSee('Submit'); -}); +it('can render the submit button using the default translation string') + ->blade('') + ->assertSee('Submit'); From ea911cfff64efe3c4e4726029570c2aa68218e18 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Fri, 3 Sep 2021 17:44:11 +0200 Subject: [PATCH 06/28] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4daa49c..0ae63ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `laravel-support-bubble` will be documented in this file. +## 1.0.2 - 2021-09-03 + +- make submit button translatable + ## 1.0.1 - 2021-09-02 - replace impersonation with reply-to From d1d6239b8465a83d775b3b1ea899720e716af80c Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Fri, 3 Sep 2021 18:15:16 +0200 Subject: [PATCH 07/28] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 62c5e1e..69a230c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ We invest a lot of resources into creating [best in class open source packages]( We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). +## Are you a visual learner? + +If [this stream on YouTube](https://www.youtube.com/watch?v=IucDLJI2mvQ), you'll see how to install that package, and how it works under the hood. + ## Installation You can install the package via composer: From c74efebddf37b21991df48fc64acafe25d08cbf1 Mon Sep 17 00:00:00 2001 From: Slava Abakumov Date: Fri, 3 Sep 2021 23:27:34 +0300 Subject: [PATCH 08/28] Update README with information about Tailwind JIT --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 69a230c..9ead2a9 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,17 @@ The views included in this package all use TailwindCSS classes. We've stuck to t ``` +If you use Tailwind [Just-in-Time Mode](https://tailwindcss.com/docs/just-in-time-mode) you should add these additional lines into your `tailwind.config.js` file: +```js +purge: [ + './vendor/spatie/laravel-support-bubble/config/**/*.php', + './vendor/spatie/laravel-support-bubble/resources/views/**/*.blade.php', + // other places +], +``` + +This way Tailwind JIT will build your styles including those properties used for the support bubble. + #### Add the component to your view After installing the package, you need to add the `` Blade component in your relevant view files. If you want it to show up on all pages you can add it to your `layout.blade.php` file. From 21458b735a18c8554a67ac0a542153801c27ceaf Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 4 Sep 2021 12:39:34 -0600 Subject: [PATCH 09/28] Make notifications a little less clunky when a name isn't provided --- src/Notifications/BubbleResponseNotification.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Notifications/BubbleResponseNotification.php b/src/Notifications/BubbleResponseNotification.php index a1d0c36..2baefa7 100644 --- a/src/Notifications/BubbleResponseNotification.php +++ b/src/Notifications/BubbleResponseNotification.php @@ -50,7 +50,7 @@ public function toMail($notifiable): MailMessage ->subject("Support bubble message from {$this->name}: {$this->subject}") ->replyTo($this->email) ->greeting($this->subject) - ->line("{$this->name} ({$this->email}) left a new message using the chat bubble:") + ->line("{$this->who()} left a new message using the chat bubble:") ->line(new HtmlString("
{$this->message}
")) ->line($metadataHtml); } @@ -71,4 +71,14 @@ protected function getMetadataHtml(): HtmlString return new HtmlString(trim($html)); } + + + protected function who(): string + { + if ($this->name == null) { + return $this->email; + } + + return $this->name . "(" . $this->email . ")"; + } } From 4e616feb60257d262d2c441db358f895024cff73 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Sun, 5 Sep 2021 13:06:24 +0200 Subject: [PATCH 10/28] code style --- src/Notifications/BubbleResponseNotification.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Notifications/BubbleResponseNotification.php b/src/Notifications/BubbleResponseNotification.php index 2baefa7..a2d7b53 100644 --- a/src/Notifications/BubbleResponseNotification.php +++ b/src/Notifications/BubbleResponseNotification.php @@ -75,10 +75,10 @@ protected function getMetadataHtml(): HtmlString protected function who(): string { - if ($this->name == null) { + if (is_null($this->name)) { return $this->email; } - return $this->name . "(" . $this->email . ")"; + return "{$this->name} ({$this->email})"; } } From 715f93359799c3175bbc6621b53c0c0ba1998981 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Sun, 5 Sep 2021 13:07:32 +0200 Subject: [PATCH 11/28] Update BubbleResponseNotification.php --- src/Notifications/BubbleResponseNotification.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Notifications/BubbleResponseNotification.php b/src/Notifications/BubbleResponseNotification.php index a2d7b53..7e2878b 100644 --- a/src/Notifications/BubbleResponseNotification.php +++ b/src/Notifications/BubbleResponseNotification.php @@ -75,10 +75,8 @@ protected function getMetadataHtml(): HtmlString protected function who(): string { - if (is_null($this->name)) { - return $this->email; - } - - return "{$this->name} ({$this->email})"; + return is_null($this->name) + ? $this->email + : "{$this->name} ({$this->email}); } } From a2e6c8f0fa6ac57ea770bc920461df2c1f024b3e Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Sun, 5 Sep 2021 13:10:22 +0200 Subject: [PATCH 12/28] Update BubbleResponseNotification.php --- src/Notifications/BubbleResponseNotification.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Notifications/BubbleResponseNotification.php b/src/Notifications/BubbleResponseNotification.php index 7e2878b..c5b462e 100644 --- a/src/Notifications/BubbleResponseNotification.php +++ b/src/Notifications/BubbleResponseNotification.php @@ -77,6 +77,6 @@ protected function who(): string { return is_null($this->name) ? $this->email - : "{$this->name} ({$this->email}); + : "{$this->name} ({$this->email})"; } } From 6d840e11361e00129c6df3c86688d7fae8c0740a Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Sun, 5 Sep 2021 21:27:11 +0200 Subject: [PATCH 13/28] Update support-bubble.php --- config/support-bubble.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/config/support-bubble.php b/config/support-bubble.php index f03f6d2..9a31f6a 100644 --- a/config/support-bubble.php +++ b/config/support-bubble.php @@ -1,12 +1,6 @@ 'supportBubble.submit', - /* * Enable or disable fields in the support bubble. * Keep in mind that `name` and `email` will be hidden automatically @@ -18,13 +12,7 @@ 'subject' => true, 'message' => true, ], - - /* - * When set to true we'll use currently logged in user to fill in - * the name and email fields. Both fields will also be hidden. - */ - 'prefill_logged_in_user' => true, - + /* * We'll send any chat bubble responses to this e-mail address. * @@ -32,6 +20,12 @@ */ 'mail_to' => null, + /* + * When set to true we'll use currently logged in user to fill in + * the name and email fields. Both fields will also be hidden. + */ + 'prefill_logged_in_user' => true, + /* * The TailwindCSS classes used on a couple of key components. * @@ -43,4 +37,10 @@ 'input' => 'bg-gray-100 border border-gray-200 w-full max-w-full p-2 rounded-sm shadow-input text-gray-800 text-base', 'button' => 'inline-flex place-center px-4 py-3 h-10 border-0 bg-purple-500 hover:bg-purple-600 active:bg-purple-600 overflow-hidden rounded-sm text-white leading-none no-underline', ], + + /* + * The default route and controller will be registered using this route name. + * This is a good place to hook in your own route and controller if necessary. + */ + 'form_action_route' => 'supportBubble.submit', ]; From 269354527e0b3afbcb4c7c5755209ff20891a3c1 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Sun, 5 Sep 2021 21:27:36 +0200 Subject: [PATCH 14/28] Update README.md --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 9ead2a9..890d8b2 100644 --- a/README.md +++ b/README.md @@ -108,12 +108,6 @@ These are the default contents of the published config file: 'supportBubble.submit', - /* * Enable or disable fields in the support bubble. * Keep in mind that `name` and `email` will be hidden automatically @@ -125,13 +119,7 @@ return [ 'subject' => true, 'message' => true, ], - - /* - * When set to true we'll use currently logged in user to fill in - * the name and email fields. Both fields will also be hidden. - */ - 'prefill_logged_in_user' => true, - + /* * We'll send any chat bubble responses to this e-mail address. * @@ -139,9 +127,15 @@ return [ */ 'mail_to' => null, + /* + * When set to true we'll use currently logged in user to fill in + * the name and email fields. Both fields will also be hidden. + */ + 'prefill_logged_in_user' => true, + /* * The TailwindCSS classes used on a couple of key components. - * + * * To customize the components further, you can publish * the views of this package. */ @@ -150,6 +144,12 @@ return [ 'input' => 'bg-gray-100 border border-gray-200 w-full max-w-full p-2 rounded-sm shadow-input text-gray-800 text-base', 'button' => 'inline-flex place-center px-4 py-3 h-10 border-0 bg-purple-500 hover:bg-purple-600 active:bg-purple-600 overflow-hidden rounded-sm text-white leading-none no-underline', ], + + /* + * The default route and controller will be registered using this route name. + * This is a good place to hook in your own route and controller if necessary. + */ + 'form_action_route' => 'supportBubble.submit', ]; ``` From 0a87e49899c48aa382f86ca89be53cf8a4ec729a Mon Sep 17 00:00:00 2001 From: Alex Vanderbist Date: Wed, 1 Sep 2021 14:35:37 +0200 Subject: [PATCH 15/28] Whitespace --- resources/views/components/support-bubble.blade.php | 3 ++- resources/views/includes/script.blade.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/views/components/support-bubble.blade.php b/resources/views/components/support-bubble.blade.php index 3cbc04e..133a110 100644 --- a/resources/views/components/support-bubble.blade.php +++ b/resources/views/components/support-bubble.blade.php @@ -1,4 +1,5 @@ -