Sha256: c136fc7794788c95c0a374e9b568b871349d880262550162cfe9b94e2f31f995

Contents?: true

Size: 1009 Bytes

Versions: 38

Compression:

Stored size: 1009 Bytes

Contents

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

@controller
class ZenModeButtonElement extends HTMLElement {
  @target button: HTMLElement
  inZenMode = false

  private deactivateZenMode() {
    this.inZenMode = false
    this.button.setAttribute('aria-pressed', 'false')
    if (document.exitFullscreen) {
      void document.exitFullscreen()
    }
  }

  private activateZenMode() {
    this.inZenMode = true
    this.button.setAttribute('aria-pressed', 'true')
    if (document.documentElement.requestFullscreen) {
      void document.documentElement.requestFullscreen()
    }
  }

  public performAction() {
    if (this.inZenMode) {
      this.deactivateZenMode()
    } else {
      this.activateZenMode()
    }
  }
}

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

if (!window.customElements.get('zen-mode-button')) {
  window.ZenModeButtonElement = ZenModeButtonElement
  window.customElements.define('zen-mode-button', ZenModeButtonElement)
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
openproject-primer_view_components-0.48.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.47.1 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.47.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.46.1 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.46.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.45.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.44.3 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.44.2 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.44.1 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.44.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.43.1 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.43.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.42.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.41.1 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.41.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.40.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.39.1 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.39.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.38.0 app/components/primer/open_project/zen_mode_button.ts
openproject-primer_view_components-0.37.1 app/components/primer/open_project/zen_mode_button.ts