-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[52150] Zen mode for project lists page (#17102)
* pass zen-mode button to the more menu in projects list * remove aria-pressed attr
- Loading branch information
1 parent
eb31820
commit 73314f0
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
frontend/src/stimulus/controllers/dynamic/projects/zen-mode.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ApplicationController } from 'stimulus-use'; | ||
|
||
export default class OpProjectsZenModeController extends ApplicationController { | ||
static targets = ['button']; | ||
inZenMode = false; | ||
|
||
declare readonly buttonTarget:HTMLElement; | ||
|
||
connect() { | ||
document.addEventListener('fullscreenchange', this.fullscreenChangeEventHandler.bind(this)); | ||
} | ||
|
||
disconnect() { | ||
super.disconnect(); | ||
document.removeEventListener('fullscreenchange', this.fullscreenChangeEventHandler.bind(this)); | ||
} | ||
|
||
fullscreenChangeEventHandler() { | ||
this.inZenMode = !this.inZenMode; | ||
this.dispatchZenModeStatus(); | ||
} | ||
|
||
dispatchZenModeStatus() { | ||
// Create a new custom event | ||
const event = new CustomEvent('zenModeToggled', { | ||
detail: { | ||
active: this.inZenMode, | ||
}, | ||
}); | ||
// Dispatch the custom event | ||
window.dispatchEvent(event); | ||
} | ||
|
||
private deactivateZenMode() { | ||
if (document.exitFullscreen) { | ||
void document.exitFullscreen(); | ||
} | ||
} | ||
|
||
private activateZenMode() { | ||
if (document.documentElement.requestFullscreen) { | ||
void document.documentElement.requestFullscreen(); | ||
} | ||
} | ||
|
||
public performAction() { | ||
if (this.inZenMode) { | ||
this.deactivateZenMode(); | ||
} else { | ||
this.activateZenMode(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters