Sha256: cc3c128c20d750856cfde4b2bef046c921f46179b095815f5555223d5fe3ca6e

Contents?: true

Size: 1.16 KB

Versions: 122

Compression:

Stored size: 1.16 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

122 entries across 122 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.55-aarch64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.55-x86_64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.55 app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.55-x64-mingw-ucrt app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.54-x86_64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.54-arm64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.54 app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.54-aarch64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.54-x86_64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.54-x64-mingw-ucrt app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.53-arm64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.53-aarch64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.53 app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.53-x64-mingw-ucrt app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.53-x86_64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.53-x86_64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.52-x86_64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.52-x86_64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.52-aarch64-linux app/components/ariadne/tab_container_component/tab-container-component.ts
ariadne_view_components-0.0.52-arm64-darwin app/components/ariadne/tab_container_component/tab-container-component.ts