Skip to content

Commit 304bc83

Browse files
authored
Animate deletion of notifications (hestiacp#4316)
1 parent d0567b5 commit 304bc83

File tree

6 files changed

+39
-19
lines changed

6 files changed

+39
-19
lines changed

build.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as lightningcss from 'lightningcss';
1212
const externalPackages = [
1313
'chart.js/auto',
1414
'alpinejs/dist/cdn.min.js',
15+
'@alpinejs/collapse/dist/cdn.min.js',
1516
'xterm',
1617
'xterm-addon-webgl',
1718
'xterm-addon-canvas',
@@ -63,6 +64,8 @@ function getOutputPath(pkg) {
6364

6465
if (pkg.startsWith('alpinejs')) {
6566
pkgName = 'alpinejs';
67+
} else if (pkg.startsWith('@alpinejs/collapse')) {
68+
pkgName = 'alpinejs-collapse';
6669
} else {
6770
pkgName = pkg.replace(/\//g, '-');
6871
}

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"prepare": "husky"
2020
},
2121
"dependencies": {
22+
"@alpinejs/collapse": "^3.13.5",
2223
"@fortawesome/fontawesome-free": "^6.5.1",
2324
"alpinejs": "^3.13.5",
2425
"chart.js": "^4.4.1",

web/css/src/themes/default.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@
212212
color: #6f6f6f;
213213
font-size: 0.8rem;
214214
border-bottom: 1px solid #e9e4e4;
215-
padding: 15px 20px;
216215

217216
&:last-child {
218217
border-bottom: none;
@@ -231,6 +230,10 @@
231230
& a {
232231
font-weight: 600;
233232
}
233+
}
234+
235+
.top-bar-notification-inner {
236+
padding: 15px 20px;
234237

235238
@media (--viewport-small) {
236239
padding-left: 15px;

web/templates/includes/js.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script defer src="/js/dist/main.min.js?<?= JS_LATEST_UPDATE ?>"></script>
2+
<script defer src="/js/dist/alpinejs-collapse.min.js?<?= JS_LATEST_UPDATE ?>"></script>
23
<script defer src="/js/dist/alpinejs.min.js?<?= JS_LATEST_UPDATE ?>"></script>
34
<script>
45
document.documentElement.classList.replace('no-js', 'js');

web/templates/includes/panel.php

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,32 @@ class="top-bar-notifications-panel"
9999
x-bind:id="`notification-${notification.ID}`"
100100
x-bind:class="notification.ACK && 'unseen'"
101101
class="top-bar-notification-item"
102+
x-data="{ open: true }"
103+
x-show="open"
104+
x-collapse
102105
>
103-
<div class="top-bar-notification-header">
104-
<p x-text="notification.TOPIC" class="top-bar-notification-title"></p>
105-
<button
106-
x-on:click="remove(notification.ID)"
107-
type="button"
108-
class="top-bar-notification-delete"
109-
title="<?= _("Delete notification") ?>"
110-
>
111-
<i class="fas fa-xmark"></i>
112-
</button>
106+
<div class="top-bar-notification-inner">
107+
<div class="top-bar-notification-header">
108+
<p x-text="notification.TOPIC" class="top-bar-notification-title"></p>
109+
<button
110+
x-on:click="open = false; setTimeout(() => remove(notification.ID), 300);"
111+
type="button"
112+
class="top-bar-notification-delete"
113+
title="<?= _("Delete notification") ?>"
114+
>
115+
<i class="fas fa-xmark"></i>
116+
<span class="u-hidden-visually"><?= _("Delete notification") ?></span>
117+
</button>
118+
</div>
119+
<div class="top-bar-notification-content" x-html="notification.NOTICE"></div>
120+
<p class="top-bar-notification-timestamp">
121+
<time
122+
:datetime="`${notification.TIMESTAMP_ISO}`"
123+
x-bind:title="`${notification.TIMESTAMP_TITLE}`"
124+
x-text="`${notification.TIMESTAMP_TEXT}`"
125+
></time>
126+
</p>
113127
</div>
114-
<div class="top-bar-notification-content" x-html="notification.NOTICE"></div>
115-
<p class="top-bar-notification-timestamp">
116-
<time
117-
:datetime="`${notification.TIMESTAMP_ISO}`"
118-
x-bind:title="`${notification.TIMESTAMP_TITLE}`"
119-
x-text="`${notification.TIMESTAMP_TEXT}`"
120-
></time>
121-
</p>
122128
</li>
123129
</template>
124130
</ul>

0 commit comments

Comments
 (0)