Skip to content

Commit 66126a1

Browse files
authored
feat: shows a subtle background affect when a new container is added (#4494)
1 parent 7371b86 commit 66126a1

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

assets/components/HostMenu.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@
7979
</router-link>
8080
</summary>
8181
<ul>
82-
<li v-for="item in containers" :class="item.state" :key="item.id">
82+
<li
83+
v-for="item in containers"
84+
:class="[item.state, { 'highlight-new': item.isNew }]"
85+
:key="item.id"
86+
@animationend="item.isNew = false"
87+
>
8388
<Popup>
8489
<router-link
8590
:to="{ name: '/container/[id]', params: { id: item.id } }"
@@ -248,4 +253,17 @@ li.exited {
248253
li.deleted {
249254
@apply hidden;
250255
}
256+
257+
li.highlight-new {
258+
animation: highlight-fade 3s ease-out;
259+
}
260+
261+
@keyframes highlight-fade {
262+
from {
263+
background-color: oklch(from var(--color-secondary) l c h / 0.25);
264+
}
265+
to {
266+
background-color: transparent;
267+
}
268+
}
251269
</style>

assets/models/Container.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class Container {
4949
stats: Stat[],
5050
public readonly group?: string,
5151
public health?: ContainerHealth,
52+
public isNew: boolean = false,
5253
) {
5354
const defaultStat = { cpu: 0, memory: 0, memoryUsage: 0, networkRxTotal: 0, networkTxTotal: 0 } as Stat;
5455
this._stat = ref(stats.at(-1) || defaultStat);

assets/stores/container.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,23 @@ export const useContainerStore = defineStore("container", () => {
135135

136136
existingContainers.forEach((c) => {
137137
const existing = allContainersById.value[c.id];
138+
if (ready.value && existing.state !== "running" && c.state === "running") {
139+
existing.isNew = true;
140+
}
138141
existing.state = c.state;
139142
existing.health = c.health;
140143
existing.name = c.name;
141144
});
142145

143-
containers.value = [...containers.value, ...newContainers.map(Container.fromJSON)];
146+
const mapped = newContainers.map((c) => {
147+
const container = Container.fromJSON(c);
148+
if (ready.value) {
149+
container.isNew = true;
150+
}
151+
return container;
152+
});
153+
154+
containers.value = [...containers.value, ...mapped];
144155
};
145156

146157
const currentContainer = (id: Ref<string>) => computed(() => allContainersById.value[id.value]);

0 commit comments

Comments
 (0)