Skip to content

Commit

Permalink
Feat modal component (#17)
Browse files Browse the repository at this point in the history
* Remove unnecessary files

* feat: modal component

* Hide modal
  • Loading branch information
ricardogobbosouza authored Dec 14, 2020
1 parent feb7d34 commit 692928e
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 291 deletions.
20 changes: 0 additions & 20 deletions _components/_bkp/card.blade.php

This file was deleted.

21 changes: 0 additions & 21 deletions _components/_bkp/modal.blade.php

This file was deleted.

122 changes: 0 additions & 122 deletions _components/_bkp/progress-bar.blade.php

This file was deleted.

90 changes: 0 additions & 90 deletions _components/_bkp/toast.blade.php

This file was deleted.

38 changes: 0 additions & 38 deletions _components/card.blade.php

This file was deleted.

64 changes: 64 additions & 0 deletions config/tall-kit.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
'socialmeta' => \Datalogix\TALLKit\Components\Layouts\SocialMeta::class, //alias

/**
* Modals.
*/
'modal' => \Datalogix\TALLKit\Components\Modals\Modal::class,

/**x
* Navigations.
*/
'dropdown' => \Datalogix\TALLKit\Components\Navigations\Dropdown::class,
Expand Down Expand Up @@ -743,6 +748,65 @@

'social-meta' => [],

/**
* Modals.
*/
'modal' => [
'container' => [
'x-data' => '{
show: false,
focusables() {
// All focusable element types...
let selector = \'a, button, input, textarea, select, details, [tabindex]:not([tabindex=-1])\'
return [...$el.querySelectorAll(selector)]
// All non-disabled elements...
.filter(el => ! el.hasAttribute(\'disabled\'))
},
firstFocusable() { return this.focusables()[0] },
lastFocusable() { return this.focusables().slice(-1)[0] },
nextFocusable() { return this.focusables()[this.nextFocusableIndex()] || this.firstFocusable() },
prevFocusable() { return this.focusables()[this.prevFocusableIndex()] || this.lastFocusable() },
nextFocusableIndex() { return (this.focusables().indexOf(document.activeElement) + 1) % (this.focusables().length + 1) },
prevFocusableIndex() { return Math.max(0, this.focusables().indexOf(document.activeElement)) -1 },
}',
'@close.stop' => 'show = false',
'@keydown.escape.window' => 'show = false',
'@keydown.tab.prevent' => '$event.shiftKey || nextFocusable().focus()',
'@keydown.shift.tab.prevent' => 'prevFocusable().focus()',
'x-show' => 'show',
'class' => 'fixed top-0 inset-x-0 px-4 pt-6 z-50 flex items-top justify-center',
'style' => 'display: none;',
],

'overlay' => [
'x-show' => 'show',
'class' => 'fixed inset-0 transform transition-all',
'@click' => 'show = false',
'x-transition:enter' => 'ease-out duration-300',
'x-transition:enter-start' => 'opacity-0',
'x-transition:enter-end' => 'opacity-100',
'x-transition:leave' => 'ease-in duration-200',
'x-transition:leave-start' => 'opacity-100',
'x-transition:leave-end' => 'opacity-0',
],

'backdrop' => [
'class' => 'absolute inset-0 bg-gray-500 opacity-75',
],

'modal' => [
'x-show' => 'show',
'class' => 'bg-white p-4 rounded overflow-hidden shadow transform transition-all w-full',
'x-transition:enter' => 'ease-out duration-300',
'x-transition:enter-start' => 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95',
'x-transition:enter-end' => 'opacity-100 translate-y-0 sm:scale-100',
'x-transition:leave' => 'ease-in duration-200',
'x-transition:leave-start' => 'opacity-100 translate-y-0 sm:scale-100',
'x-transition:leave-end' => 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95',
],
],

/**
* Navigations.
*/
Expand Down
9 changes: 9 additions & 0 deletions resources/views/components/modals/modal.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div {{ $themeProvider->container }}>
<div {{ $themeProvider->overlay }}>
<div {{ $themeProvider->backdrop }}></div>
</div>

<div {{ $attributes->merge(toArray($themeProvider->modal)) }}>
{{ $slot }}
</div>
</div>
Loading

0 comments on commit 692928e

Please sign in to comment.