feat(ui): use view transitions for realtime feed

This commit is contained in:
josedario87
2025-06-09 22:27:29 -06:00
parent 21274ba1e0
commit 0d2ffee841
3 changed files with 26 additions and 3 deletions

View File

@@ -114,6 +114,7 @@ const operationClass = computed(() => {
.realtime-event { .realtime-event {
margin-bottom: 1rem; margin-bottom: 1rem;
padding: 0.5rem; padding: 0.5rem;
view-transition-name: auto;
} }
.old-card, .old-card,

View File

@@ -34,8 +34,15 @@ export const useRealtimeStore = defineStore('realtime', {
console.log('📦 Payload parseado:', payload); console.log('📦 Payload parseado:', payload);
console.log('🧪 Tabla recibida:', payload.table); console.log('🧪 Tabla recibida:', payload.table);
// store event for feed // store event for feed with View Transition if available
this.events.unshift({ ...payload, receivedAt: new Date().toISOString() }); const addEvent = () => {
this.events.unshift({ ...payload, receivedAt: new Date().toISOString() });
};
if (document.startViewTransition) {
document.startViewTransition(addEvent);
} else {
addEvent();
}
// mark badge for module and operation // mark badge for module and operation
if (this.badges[payload.table]) { if (this.badges[payload.table]) {
@@ -64,7 +71,7 @@ export const useRealtimeStore = defineStore('realtime', {
this._sse.onerror = () => { this._sse.onerror = () => {
console.warn('SSE connection lost, reloading...'); console.warn('SSE connection lost, reloading...');
}; };
} },
clearBadgesForTable(table) { clearBadgesForTable(table) {
if (this.badges[table]) { if (this.badges[table]) {
this.badges[table].INSERT = false; this.badges[table].INSERT = false;

View File

@@ -79,4 +79,19 @@ onMounted(() => {
.feed-list::-webkit-scrollbar { .feed-list::-webkit-scrollbar {
display: none; /* Chrome, Safari */ display: none; /* Chrome, Safari */
} }
:global(::view-transition-old(.realtime-event)),
:global(::view-transition-new(.realtime-event)) {
animation: slide 0.25s ease both;
}
@keyframes slide {
from {
transform: translateY(var(--view-transition-slide-y, 0));
opacity: 0;
}
to {
transform: none;
opacity: 1;
}
}
</style> </style>