openproject-primer_view_components 0.48.0 → 0.48.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,7 @@ module Primer
11
11
  HEADING_TAG_OPTIONS = [:h1, :h2, :h3, :h4, :h5, :h6].freeze
12
12
  HEADING_TAG_FALLBACK = :h1
13
13
 
14
- renders_one :editable_form, lambda { |model: nil, update_path:, cancel_path:, input_name: :title, method: :put, label: I18n.t(:label_title), placeholder: I18n.t(:label_title), **system_arguments|
14
+ renders_one :editable_form, lambda { |model: false, update_path:, cancel_path:, input_name: :title, method: :put, label: I18n.t(:label_title), placeholder: I18n.t(:label_title), **system_arguments|
15
15
  primer_form_with(
16
16
  model: model,
17
17
  method: method,
@@ -1,8 +1,13 @@
1
1
  declare class ZenModeButtonElement extends HTMLElement {
2
2
  button: HTMLElement;
3
3
  inZenMode: boolean;
4
+ constructor();
5
+ disconnectedCallback(): void;
6
+ fullscreenChangeEventHandler(): void;
7
+ dispatchZenModeStatus(): void;
4
8
  private deactivateZenMode;
5
9
  private activateZenMode;
10
+ changeButtonState(inZenMode: boolean): void;
6
11
  performAction(): void;
7
12
  }
8
13
  declare global {
@@ -6,24 +6,43 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { controller, target } from '@github/catalyst';
8
8
  let ZenModeButtonElement = class ZenModeButtonElement extends HTMLElement {
9
+ // eslint-disable-next-line custom-elements/no-constructor
9
10
  constructor() {
10
- super(...arguments);
11
+ super();
11
12
  this.inZenMode = false;
13
+ document.addEventListener('fullscreenchange', this.fullscreenChangeEventHandler.bind(this));
14
+ }
15
+ disconnectedCallback() {
16
+ document.removeEventListener('fullscreenchange', this.fullscreenChangeEventHandler.bind(this));
17
+ }
18
+ fullscreenChangeEventHandler() {
19
+ this.changeButtonState(!this.inZenMode);
20
+ this.dispatchZenModeStatus();
21
+ }
22
+ dispatchZenModeStatus() {
23
+ // Create a new custom event
24
+ const event = new CustomEvent('zenModeToggled', {
25
+ detail: {
26
+ active: this.inZenMode,
27
+ },
28
+ });
29
+ // Dispatch the custom event
30
+ window.dispatchEvent(event);
12
31
  }
13
32
  deactivateZenMode() {
14
- this.inZenMode = false;
15
- this.button.setAttribute('aria-pressed', 'false');
16
33
  if (document.exitFullscreen) {
17
34
  void document.exitFullscreen();
18
35
  }
19
36
  }
20
37
  activateZenMode() {
21
- this.inZenMode = true;
22
- this.button.setAttribute('aria-pressed', 'true');
23
38
  if (document.documentElement.requestFullscreen) {
24
39
  void document.documentElement.requestFullscreen();
25
40
  }
26
41
  }
42
+ changeButtonState(inZenMode) {
43
+ this.inZenMode = inZenMode;
44
+ this.button.setAttribute('aria-pressed', inZenMode.toString());
45
+ }
27
46
  performAction() {
28
47
  if (this.inZenMode) {
29
48
  this.deactivateZenMode();
@@ -5,21 +5,46 @@ class ZenModeButtonElement extends HTMLElement {
5
5
  @target button: HTMLElement
6
6
  inZenMode = false
7
7
 
8
+ // eslint-disable-next-line custom-elements/no-constructor
9
+ constructor() {
10
+ super()
11
+ document.addEventListener('fullscreenchange', this.fullscreenChangeEventHandler.bind(this))
12
+ }
13
+
14
+ disconnectedCallback() {
15
+ document.removeEventListener('fullscreenchange', this.fullscreenChangeEventHandler.bind(this))
16
+ }
17
+
18
+ fullscreenChangeEventHandler() {
19
+ this.changeButtonState(!this.inZenMode)
20
+ this.dispatchZenModeStatus()
21
+ }
22
+ dispatchZenModeStatus() {
23
+ // Create a new custom event
24
+ const event = new CustomEvent('zenModeToggled', {
25
+ detail: {
26
+ active: this.inZenMode,
27
+ },
28
+ })
29
+ // Dispatch the custom event
30
+ window.dispatchEvent(event)
31
+ }
32
+
8
33
  private deactivateZenMode() {
9
- this.inZenMode = false
10
- this.button.setAttribute('aria-pressed', 'false')
11
34
  if (document.exitFullscreen) {
12
35
  void document.exitFullscreen()
13
36
  }
14
37
  }
15
38
 
16
39
  private activateZenMode() {
17
- this.inZenMode = true
18
- this.button.setAttribute('aria-pressed', 'true')
19
40
  if (document.documentElement.requestFullscreen) {
20
41
  void document.documentElement.requestFullscreen()
21
42
  }
22
43
  }
44
+ public changeButtonState(inZenMode: boolean) {
45
+ this.inZenMode = inZenMode
46
+ this.button.setAttribute('aria-pressed', inZenMode.toString())
47
+ }
23
48
 
24
49
  public performAction() {
25
50
  if (this.inZenMode) {
@@ -6,7 +6,7 @@ module Primer
6
6
  module VERSION
7
7
  MAJOR = 0
8
8
  MINOR = 48
9
- PATCH = 0
9
+ PATCH = 2
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openproject-primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.48.0
4
+ version: 0.48.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-10-08 00:00:00.000000000 Z
12
+ date: 2024-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionview