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 @@ <form action="{!! $url !!}" {!! $attributes !!}> @csrf - <button type="submit" class="{!! $basename !!}__link"> - <span class="{!! $basename !!}__label">{{ $label }}</span> + <button type="submit" {!! $btnattributes !!}> + <span class="{!! $basename !!}__label">{!! $label !!}</span> </button> </form> 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(); }