From 989c79afb8bcb8c0921749025972e0aec009c5a4 Mon Sep 17 00:00:00 2001 From: Kuldeep Matharu Date: Fri, 9 Aug 2024 11:33:15 +0100 Subject: [PATCH] add notification --- src/component/layout/index.js | 17 ++++++++- src/component/notification/index.css | 30 +++++++++++++++ src/component/notification/index.js | 55 ++++++++++++++++++++++++++++ src/style/zindex/index.css | 9 +++-- 4 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 src/component/notification/index.css create mode 100644 src/component/notification/index.js diff --git a/src/component/layout/index.js b/src/component/layout/index.js index 7a2aff09..fa7bef31 100644 --- a/src/component/layout/index.js +++ b/src/component/layout/index.js @@ -1,6 +1,9 @@ import { state } from '../state'; +import { Notification } from '../notification'; + import { node } from '../../utility/node'; +import { complexNode } from '../../utility/complexNode'; import { clearChildNode } from '../../utility/clearChildNode'; import { applyCSSVar } from '../../utility/applyCSSVar'; import { applyCSSClass } from '../../utility/applyCSSClass'; @@ -26,7 +29,17 @@ layout.area = { const body = document.querySelector('body'); - body.appendChild(layout.element.layout); + const notification = new Notification({ + children: [ + + complexNode({ tag: 'p', text: 'Search in nightTab will be removed to comply with a Chrome policy change. Filtering bookmarks will remain. Read more about this change on the nightTab repo.', complexText: true }) + + ] + }); + + body.append(notification.notification()); + + body.append(layout.element.layout); const resize = new ResizeObserver((entries) => { @@ -34,7 +47,7 @@ layout.area = { let breakpoint; - entries.forEach(function(entry) { + entries.forEach(function (entry) { if (entry.contentRect.width <= size.sm) { breakpoint = 'xs'; diff --git a/src/component/notification/index.css b/src/component/notification/index.css new file mode 100644 index 00000000..3d8d0af7 --- /dev/null +++ b/src/component/notification/index.css @@ -0,0 +1,30 @@ +:root { + --notification-space: 4; +} + +:root { + --notification-header-background: var(--theme-primary-030); + --notification-body-background: var(--theme-primary-020); +} + +.notification { + position: absolute; + top: 0; + left: 0; + width: 100%; + display: flex; + flex-direction: row; + z-index: var(--z-index-notification); +} + +.notification-body { + background-color: hsl(var(--notification-body-background)); + padding: calc((var(--notification-space) / 8) * 1em) calc((var(--notification-space) / 4) * 1em); + gap: calc((var(--notification-space) / 4) * 1em); + flex-grow: 1; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + transition: background-color var(--layout-transition-extra-fast); +} \ No newline at end of file diff --git a/src/component/notification/index.js b/src/component/notification/index.js new file mode 100644 index 00000000..2d96695e --- /dev/null +++ b/src/component/notification/index.js @@ -0,0 +1,55 @@ +import { Button } from '../button'; + +import { node } from '../../utility/node'; + +import './index.css'; + +export const Notification = function ({ + children = [], +} = {}) { + + this.element = { + notification: node('div|class:notification'), + body: node('div|class:notification-body'), + message: node('div|class:notification-message', children), + dismiss: new Button({ + text: 'Dismiss', + title: 'Dismiss', + size: 'small', + style: ['ring'], + func: () => { + } + }), + }; + + this.assemble = () => { + + this.element.body.appendChild(this.element.message); + + this.element.body.appendChild(this.element.dismiss.button); + + this.element.notification.appendChild(this.element.body); + + }; + + this.render = () => { + + const body = document.querySelector('body'); + + body.appendChild(layout.element.notification); + + }; + + this.close = () => { + + + + }; + + this.notification = () => { + return this.element.notification; + }; + + this.assemble(); + +}; diff --git a/src/style/zindex/index.css b/src/style/zindex/index.css index d0913fb6..bf1c97f1 100644 --- a/src/style/zindex/index.css +++ b/src/style/zindex/index.css @@ -5,8 +5,9 @@ --z-index-toolbar: 3000; --z-index-edge: 4000; --z-index-dropdown: 5000; - --z-index-shade: 6000; - --z-index-menu: 7000; - --z-index-modal: 8000; - --z-index-suggest: 9000; + --z-index-notification: 6000; + --z-index-shade: 7000; + --z-index-menu: 8000; + --z-index-modal: 9000; + --z-index-suggest: 10000; } \ No newline at end of file