Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[58256] Header and sidebar menu should be hidden while pressing zen mode button #17045

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,4 @@ end

gem "openproject-octicons", "~>19.19.0"
gem "openproject-octicons_helper", "~>19.19.0"
gem "openproject-primer_view_components", "~>0.48.1"
gem "openproject-primer_view_components", "~>0.48.2"
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ GEM
actionview
openproject-octicons (= 19.19.0)
railties
openproject-primer_view_components (0.48.1)
openproject-primer_view_components (0.48.2)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
openproject-octicons (>= 19.17.0)
Expand Down Expand Up @@ -1307,7 +1307,7 @@ DEPENDENCIES
openproject-octicons (~> 19.19.0)
openproject-octicons_helper (~> 19.19.0)
openproject-openid_connect!
openproject-primer_view_components (~> 0.48.1)
openproject-primer_view_components (~> 0.48.2)
openproject-recaptcha!
openproject-reporting!
openproject-storages!
Expand Down
28 changes: 14 additions & 14 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@
"@ngneat/content-loader": "^7.0.0",
"@ngx-formly/core": "^6.1.4",
"@openproject/octicons-angular": "^19.19.0",
"@openproject/primer-view-components": "^0.48.1",
"@openproject/primer-view-components": "^0.48.2",
"@openproject/reactivestates": "^3.0.1",
"@primer/css": "^21.5.0",
"@primer/primitives": "^9.1.2",
"@primer/view-components": "npm:@openproject/primer-view-components@^0.48.1",
"@primer/view-components": "npm:@openproject/primer-view-components@^0.48.2",
"@types/hotwired__turbo": "^8.0.1",
"@uirouter/angular": "^13.0.0",
"@uirouter/core": "^6.1.0",
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/app/core/setup/globals/global-listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@
performAnchorHijacking(evt, linkElement);
});

// Listen for 'zenModeToggled' event to toggle Zen Mode styling on the body.
// Adds 'zen-mode' class if active; removes it if not.
window.addEventListener('zenModeToggled', (event:CustomEvent) => {
const isActive = event.detail.active;

Check failure on line 90 in frontend/src/app/core/setup/globals/global-listeners.ts

View workflow job for this annotation

GitHub Actions / eslint

[eslint] frontend/src/app/core/setup/globals/global-listeners.ts#L90 <@typescript-eslint/no-unsafe-assignment>(https://typescript-eslint.io/rules/no-unsafe-assignment)

Unsafe assignment of an `any` value.
Raw output
{"ruleId":"@typescript-eslint/no-unsafe-assignment","severity":2,"message":"Unsafe assignment of an `any` value.","line":90,"column":11,"nodeType":"VariableDeclarator","messageId":"anyAssignment","endLine":90,"endColumn":41}

Check failure on line 90 in frontend/src/app/core/setup/globals/global-listeners.ts

View workflow job for this annotation

GitHub Actions / eslint

[eslint] frontend/src/app/core/setup/globals/global-listeners.ts#L90 <@typescript-eslint/no-unsafe-member-access>(https://typescript-eslint.io/rules/no-unsafe-member-access)

Unsafe member access .active on an `any` value.
Raw output
{"ruleId":"@typescript-eslint/no-unsafe-member-access","severity":2,"message":"Unsafe member access .active on an `any` value.","line":90,"column":35,"nodeType":"Identifier","messageId":"unsafeMemberExpression","endLine":90,"endColumn":41}
if (isActive) {
document.body.classList.add('zen-mode');
} else {
document.body.classList.remove('zen-mode');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 You can simplify the whole method by using toggle

window.addEventListener('zenModeToggled', (event:CustomEvent) => {
  document.body.classList.toggle('zen-mode', event.detail.active)
}

}
});

// Jump to the element given by location.hash, if present
const { hash } = window.location;
if (hash && hash.startsWith('#')) {
Expand Down