From cd3711a102c2f989e7d1e4b442e8f237451ffedc Mon Sep 17 00:00:00 2001 From: Reimund Renner Date: Wed, 10 Apr 2024 13:42:52 +0200 Subject: [PATCH] added btnattributes for @cookieconsentbutton to allow button customizing, removed button label escaping to allow html labels --- resources/views/button.blade.php | 4 ++-- src/CookiesManager.php | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/resources/views/button.blade.php b/resources/views/button.blade.php index 4bc358e..fc131de 100644 --- a/resources/views/button.blade.php +++ b/resources/views/button.blade.php @@ -1,6 +1,6 @@
@csrf -
diff --git a/src/CookiesManager.php b/src/CookiesManager.php index 0082b1f..c8ea508 100644 --- a/src/CookiesManager.php +++ b/src/CookiesManager.php @@ -230,7 +230,7 @@ public function getNoticeMarkup(): string /** * Output a single cookie consent action button. */ - public function renderButton(string $action, ?string $label = null, array $attributes = []): string + public function renderButton(string $action, ?string $label = null, array $attributes = [], array $btnattributes = []): string { $url = match ($action) { 'accept.all' => route('cookieconsent.accept.all'), @@ -259,10 +259,19 @@ public function renderButton(string $action, ?string $label = null, array $attri ->map(fn($value, $attribute) => $attribute . '="' . $value . '"') ->implode(' '); + if(! ($btnattributes['class'] ?? null)) { + $btnattributes['class'] = $basename . '__link'; + } + + $btnattributes = collect($btnattributes) + ->map(fn($value, $attribute) => $attribute . '="' . $value . '"') + ->implode(' '); + return view('cookie-consent::button', [ 'url' => $url, 'label' => $label ?? $action, // TODO: use lang file 'attributes' => $attributes, + 'btnattributes' => $btnattributes, 'basename' => $basename, ])->render(); }