Sha256: 1a5f4580676d6b3e9e3a6dd907e3f3ad91d154d876a868a86b4ce0bcda866449

Contents?: true

Size: 973 Bytes

Versions: 28

Compression:

Stored size: 973 Bytes

Contents

import {controller, target} from '@github/catalyst'

declare global {
  interface HTMLElementEventMap {
    'banner:dismiss': CustomEvent<void>
  }
}

@controller
class XBannerElement extends HTMLElement {
  @target titleText: HTMLElement

  dismiss() {
    if (this.#dismissScheme === 'remove') {
      const parentElement = this.parentElement
      if (!parentElement) return

      parentElement.removeChild(this)
    } else {
      this.hide()
    }

    this.dispatchEvent(new CustomEvent('banner:dismiss'))
  }

  show() {
    this.style.setProperty('display', 'initial')
  }

  hide() {
    this.style.setProperty('display', 'none')
  }

  get #dismissScheme(): string {
    return this.getAttribute('data-dismiss-scheme')!
  }
}

declare global {
  interface Window {
    XBannerElement: typeof XBannerElement
  }
}

if (!window.customElements.get('x-banner')) {
  window.XBannerElement = XBannerElement
  window.customElements.define('x-banner', XBannerElement)
}

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
primer_view_components-0.36.5 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.52.2 app/components/primer/alpha/x_banner.ts
primer_view_components-0.36.4 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.52.1 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.52.0 app/components/primer/alpha/x_banner.ts
primer_view_components-0.36.3 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.51.0 app/components/primer/alpha/x_banner.ts
primer_view_components-0.36.2 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.50.1 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.50.0 app/components/primer/alpha/x_banner.ts
primer_view_components-0.36.1 app/components/primer/alpha/x_banner.ts
primer_view_components-0.36.0 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.49.2 app/components/primer/alpha/x_banner.ts
primer_view_components-0.35.2 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.49.1 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.49.0 app/components/primer/alpha/x_banner.ts
primer_view_components-0.35.1 app/components/primer/alpha/x_banner.ts
primer_view_components-0.35.0 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.48.2 app/components/primer/alpha/x_banner.ts
openproject-primer_view_components-0.48.1 app/components/primer/alpha/x_banner.ts