Skip to content

Commit

Permalink
Pass button variant to child tabList component and send custom event …
Browse files Browse the repository at this point in the history
…when panel change

# Conflicts:
#	resources/frontend/scripts/constants/customEvents.js
  • Loading branch information
m4n1ok committed Sep 23, 2024
1 parent 84db79e commit 7b72ebc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
14 changes: 10 additions & 4 deletions resources/frontend/scripts/behaviors/Tabs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createBehavior } from '@area17/a17-behaviors'
import { customEvents } from '../constants/customEvents'

/*
Markup and JS taken from:
Expand Down Expand Up @@ -38,8 +39,10 @@ const Tabs = createBehavior(
this.current.tab.setAttribute('aria-selected', 'false')
this.current.tab.tabIndex = -1
this.current.tabpanel.inert = true
this.current.tabpanel.dispatchEvent(new CustomEvent('Tab:hidden'))

this.current.tabpanel.dispatchEvent(new CustomEvent(customEvents.TABS_HIDDEN))
document.dispatchEvent(
new CustomEvent(customEvents.TABS_HIDDEN)
)
if (!init && this.options.scrollonclick) {
this.$node.scrollIntoView(true)
}
Expand All @@ -53,15 +56,18 @@ const Tabs = createBehavior(
window.requestAnimationFrame(() => {
nextCurrentTab.tabpanel.inert = false
nextCurrentTab.tabpanel.dispatchEvent(
new CustomEvent('Tab:shown')
new CustomEvent(customEvents.TABS_SHOWN)
)
document.dispatchEvent(
new CustomEvent(customEvents.TABS_SHOWN, { detail: this.current })
)
})

this.current = nextCurrentTab
this.$node.dataset.tabsImmediate = false
if (!init) {
document.dispatchEvent(
new CustomEvent('tabs:opened', { detail: this.current })
new CustomEvent(customEvents.TABS_OPENED, { detail: this.current })
)
}
}, this.transitionTime)
Expand Down
6 changes: 5 additions & 1 deletion resources/frontend/scripts/constants/customEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ export const customEvents = {
DATE_PICKER_UPDATE: 'DatePicker:MinMaxUpdate' /* node event */,

INPUT_VALIDATED: 'Input:Validated' /* node event */,
INPUT_RESET: 'Input:Reset' /* node event */
INPUT_RESET: 'Input:Reset' /* node event */,

TABS_OPENED: 'Tabs:opened', /* node event */
TABS_SHOWN: 'Tabs:shown', /* node event */
TABS_HIDDEN: 'Tabs:hidden' /* node event */
}
1 change: 1 addition & 0 deletions resources/views/components/tabs/tabs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<x-vui-tabs-list :class="$ui('tabs', 'tablist')"
:tabs-names="$tabsNames"
:name="$name"
:tab-button-variant="$tabButtonVariant"
:tabListId="isset($title) ? $tabListId : null"/>

{{ $slot }}
Expand Down

0 comments on commit 7b72ebc

Please sign in to comment.