whitecube / laravel-cookie-consent

Register, configure and ask for cookies consent in a EU-compliant way
MIT License
295 stars 32 forks source link

Make @cookieconsentbutton more customizable #43

Open raymanP opened 3 months ago

raymanP commented 3 months ago

Yet it is possible to customize the button only to some extent. I need to add tooltips and symbol instead of button text.

E.g.

@cookieconsentbutton(action: 'reset', label: '<i class="material-icons" style="font-size: 2em">shield</i>',
  attributes: ['id' => 'reset-button', 'class' => 'btn fixed-bottom cookie-reset'],
  btnattributes: ['class' => 'btn bg-transparent', 'style' => 'margin-left: 5px; margin-bottom:5px',
    'data-toggle' => 'tooltip', 'title' => __('cookieConsent::cookies.manage')])

I added a pull request #42 for that. Hope it finds a way to the main code. @toonvandenbos fell free to check and adapt, as you have better insight into the code. Thanks for your work and support!

toonvandenbos commented 2 months ago

Hi @raymanP, why not simply publish the button view and directly work in the Blade file instead?

raymanP commented 1 month ago

Hi @toonvandenbos , I don't undestand how to get two different button versions as in ccokies.blade.php these two are used as buttons:

@cookieconsentbutton(action: 'accept.essentials', label: __('cookieConsent::cookies.essentials'), attributes: ['class' => 'cookiesBtn cookiesBtn--essentials'])
@cookieconsentbutton(action: 'accept.all', label: __('cookieConsent::cookies.all'), attributes: ['class' => 'cookiesBtn cookiesBtn--accept'])

and in app.blade.php I need the specific reset button so that the button attributes are set while in the upper cases they should not changed. Here the button.blade.php:

<form action="{!! $url !!}" {!! $attributes !!}>
    @csrf
    <button type="submit" {!! $btnattributes !!}>
        <span class="{!! $basename !!}__label">{!! $label !!}</span>
    </button>
</form>

vs. original blade:

<form action="{!! $url !!}" {!! $attributes !!}>
    @csrf
    <button type="submit" class="{!! $basename !!}__link">
        <span class="{!! $basename !!}__label">{{ $label }}</span>
    </button>
</form>

Maybe you can give a hint how to change the button attributes only for the reset button ( ['class' => 'btn bg-transparent', 'style' => 'margin-left: 5px; margin-bottom:5px', 'data-toggle' => 'tooltip', 'title' => __('cookieConsent::cookies.manage')] )... maybe using php programming?