Sha256: ec86e71aa164f084498357fc7e7341cc2dd6206174ba2e3ee9a2b3e9e748acd3

Contents?: true

Size: 1.15 KB

Versions: 70

Compression:

Stored size: 1.15 KB

Contents

import '@github/tab-container-element'

// keep in sync with tab_container_component.rb
const DEFAULT_SELECTED_CLASSES: string[] = ['ariadne-border-slate-500', 'ariadne-text-slate-600']
const DEFAULT_UNSELECTED_CLASSES: string[] = [
  'ariadne-text-gray-500',
  'hover:ariadne-text-gray-700',
  'hover:ariadne-border-gray-300'
]

for (const tabContainer of document.getElementsByTagName('tab-container')) {
  tabContainer.addEventListener('tab-container-change', function (event: Event) {
    const newPanel = (event as CustomEvent).detail.relatedTarget as HTMLElement
    const tabContainer = newPanel.closest('tab-container') as HTMLElement
    const tabList = tabContainer.firstElementChild as HTMLElement
    const currentTab = tabList.querySelector('[aria-selected="true"]') as HTMLElement
    const tabId = newPanel.getAttribute('id')?.split('-').slice(1).join('-')
    const newTab = tabList.querySelector(`#${tabId}`) as HTMLElement
    currentTab.classList.remove(...DEFAULT_SELECTED_CLASSES)
    currentTab.classList.add(...DEFAULT_UNSELECTED_CLASSES)
    newTab.classList.add(...DEFAULT_SELECTED_CLASSES)
    newTab.classList.remove(...DEFAULT_UNSELECTED_CLASSES)
  })
}

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.34 app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.34-x86_64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.34-x86_64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.34-x64-mingw32 app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.34-x64-mingw-ucrt app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.34-arm64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.34-aarch64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.33 app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.33-x86_64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.33-x86_64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.33-x64-mingw32 app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.33-x64-mingw-ucrt app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.33-arm64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.33-aarch64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.32 app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.32-x86_64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.32-x86_64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.32-x64-mingw32 app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.32-x64-mingw-ucrt app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.32-arm64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts