Sha256: e7c8b21bb89a84e728cb09fd1ba9314c1a055e0debd540586db34259ed14e69b

Contents?: true

Size: 855 Bytes

Versions: 2

Compression:

Stored size: 855 Bytes

Contents

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

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

  dismiss() {
    if (this.shouldReappear()) {
      this.style.setProperty('visibility', 'hidden')

      setTimeout(() => {
        this.style.setProperty('visibility', 'visible')
      }, 2000)

      return
    }

    const parentElement = this.parentElement
    if (!parentElement) return

    parentElement.removeChild(this)
  }

  private shouldReappear(): boolean {
    return this.root.getAttribute('data-reappear') === 'true'
  }
}

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

2 entries across 2 versions & 1 rubygems

Version Path
primer_view_components-0.0.107 app/components/primer/beta/x_banner.ts
primer_view_components-0.0.106 app/components/primer/beta/x_banner.ts