Last active
August 19, 2019 18:19
-
-
Save leandroruel/30e77cb411c6c426d0f8812803d596c7 to your computer and use it in GitHub Desktop.
creating a bootstrap 4 accordion component using laravel @component and @slot directive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<div class="card"> | |
<div class="card-header" | |
@isset($cardHeadingId) | |
id="{{ $cardHeadingId }}" | |
@endisset | |
> | |
<h2 class="mb-0"> | |
<button | |
class="btn btn-link collapsed" | |
type="button" | |
data-toggle="collapse" | |
@isset($cardCollapseId) | |
data-target="{{ '#' . $cardCollapseId }}" | |
@endisset | |
aria-expanded="true" | |
@isset($cardCollapseId) | |
aria-controls="{{ $cardCollapseId }}"> | |
@endisset | |
@isset($cardTitle) | |
{{ $cardTitle }} | |
@endisset | |
</button> | |
</h2> | |
</div> | |
<div id="{{ $cardCollapseId }}" class="collapse" | |
@isset($cardHeadingId) | |
aria-labelledby="{{ $cardHeadingId }}" | |
@endisset | |
@isset($parentId) | |
data-parent="{{ '#' . $parentId }}"> | |
@endisset | |
<div class="card-body"> | |
@isset($cardBody) | |
{{ $cardBody }} | |
@endisset | |
</div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<div class="accordion" id="accordion1"> | |
@component('card', ['cardHeadingId' => 'headingOne', 'cardCollapseId' => 'collapseOne', 'parentId' => 'accordion1']) | |
@slot('cardTitle') | |
my card title #1 | |
@endslot | |
@slot('cardBody') | |
<strong> this the content of my card body</strong> | |
@endslot | |
@endcomponent | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment