-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2757] Add home view styling for when notifications exist
- Loading branch information
1 parent
282365d
commit 904afd4
Showing
6 changed files
with
76 additions
and
2 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
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
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,44 @@ | ||
export class NotificationHandler { | ||
static selector = '.view---pages-root' | ||
|
||
constructor(root) { | ||
this.root = root | ||
this.notificationsSection = document.querySelector('.notification') | ||
|
||
this.checkNotifications() | ||
|
||
// Listen for the dispatch event from notifications | ||
document.addEventListener( | ||
'notificationClosed', | ||
this.updateStyling.bind(this) | ||
) | ||
} | ||
|
||
checkNotifications() { | ||
if ( | ||
this.notificationsSection && | ||
this.notificationsSection.children.length > 0 | ||
) { | ||
this.root.classList.add('has-notifications') | ||
} | ||
} | ||
|
||
/** | ||
* Updates styling based on presence of the dispatch event | ||
*/ | ||
updateStyling() { | ||
const notificationExists = | ||
this.notificationsSection.querySelector('.notification') | ||
if (!notificationExists) { | ||
this.root.classList.remove('has-notifications') | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Controls deviant styling of notifications in Homepage | ||
*/ | ||
const rootElement = document.querySelector(NotificationHandler.selector) | ||
if (rootElement) { | ||
new NotificationHandler(rootElement) | ||
} |
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,2 @@ | ||
// Handling exceptions in certain views | ||
import './home-view' |
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
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