web: fix icon flashing in header, fix notification header icon in dark mode
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
5ff3e9b418
commit
a4b051fcc1
|
@ -127,7 +127,8 @@ body {
|
||||||
.pf-c-page__main-section {
|
.pf-c-page__main-section {
|
||||||
--pf-c-page__main-section--BackgroundColor: var(--ak-dark-background);
|
--pf-c-page__main-section--BackgroundColor: var(--ak-dark-background);
|
||||||
}
|
}
|
||||||
.sidebar-trigger {
|
.sidebar-trigger,
|
||||||
|
.notification-trigger {
|
||||||
background-color: var(--ak-dark-background-light) !important;
|
background-color: var(--ak-dark-background-light) !important;
|
||||||
}
|
}
|
||||||
.pf-c-page__main-section.pf-m-light {
|
.pf-c-page__main-section.pf-m-light {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||||
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
||||||
import { EVENT_NOTIFICATION_TOGGLE, EVENT_SIDEBAR_TOGGLE, TITLE_DEFAULT } from "../constants";
|
import { EVENT_NOTIFICATION_TOGGLE, EVENT_SIDEBAR_TOGGLE, TITLE_DEFAULT } from "../constants";
|
||||||
import { DEFAULT_CONFIG, tenant } from "../api/Config";
|
import { DEFAULT_CONFIG, tenant } from "../api/Config";
|
||||||
import { until } from "lit-html/directives/until";
|
|
||||||
import { EventsApi } from "../../api/dist";
|
import { EventsApi } from "../../api/dist";
|
||||||
|
|
||||||
@customElement("ak-page-header")
|
@customElement("ak-page-header")
|
||||||
|
@ -18,6 +17,9 @@ export class PageHeader extends LitElement {
|
||||||
@property({type: Boolean})
|
@property({type: Boolean})
|
||||||
iconImage = false
|
iconImage = false
|
||||||
|
|
||||||
|
@property({type: Boolean})
|
||||||
|
hasNotifications = false;
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
set header(value: string) {
|
set header(value: string) {
|
||||||
tenant().then(tenant => {
|
tenant().then(tenant => {
|
||||||
|
@ -79,6 +81,16 @@ export class PageHeader extends LitElement {
|
||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firstUpdated(): void {
|
||||||
|
new EventsApi(DEFAULT_CONFIG).eventsNotificationsList({
|
||||||
|
seen: false,
|
||||||
|
ordering: "-created",
|
||||||
|
pageSize: 1,
|
||||||
|
}).then(r => {
|
||||||
|
this.hasNotifications = r.pagination.count > 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render(): TemplateResult {
|
render(): TemplateResult {
|
||||||
return html`<button
|
return html`<button
|
||||||
class="sidebar-trigger pf-c-button pf-m-plain"
|
class="sidebar-trigger pf-c-button pf-m-plain"
|
||||||
|
@ -102,25 +114,18 @@ export class PageHeader extends LitElement {
|
||||||
html`<p>${this.description}</p>` : html``}
|
html`<p>${this.description}</p>` : html``}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
${until(new EventsApi(DEFAULT_CONFIG).eventsNotificationsList({
|
<button
|
||||||
seen: false,
|
class="notification-trigger pf-c-button pf-m-plain ${this.hasNotifications ? "has-notifications" : ""}"
|
||||||
ordering: "-created",
|
@click=${() => {
|
||||||
pageSize: 1,
|
this.dispatchEvent(
|
||||||
}).then(r => {
|
new CustomEvent(EVENT_NOTIFICATION_TOGGLE, {
|
||||||
return html`
|
bubbles: true,
|
||||||
<button
|
composed: true,
|
||||||
class="notification-trigger pf-c-button pf-m-plain ${r.pagination.count > 0 ? "has-notifications" : ""}"
|
})
|
||||||
@click=${() => {
|
);
|
||||||
this.dispatchEvent(
|
}}>
|
||||||
new CustomEvent(EVENT_NOTIFICATION_TOGGLE, {
|
<i class="fas fa-bell"></i>
|
||||||
bubbles: true,
|
</button>`;
|
||||||
composed: true,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}}>
|
|
||||||
<i class="fas fa-bell"></i>
|
|
||||||
</button>`;
|
|
||||||
}))}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue