Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions resources/views/button.blade.php
Original file line number Diff line number Diff line change
@@ -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>
11 changes: 10 additions & 1 deletion src/CookiesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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();
}
Expand Down