mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-01 13:10:44 -03:00
cocinado boton para volver arriba
This commit is contained in:
16
src/lib/components/MostrarVolver.svelte.ts
Normal file
16
src/lib/components/MostrarVolver.svelte.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
export class MostrarVolver {
|
||||||
|
scrollY = $state(0);
|
||||||
|
value = $derived(this.scrollY > 500);
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
$effect(() => {
|
||||||
|
const handleScroll = () => {
|
||||||
|
this.scrollY = window.scrollY;
|
||||||
|
};
|
||||||
|
window.addEventListener('scroll', handleScroll);
|
||||||
|
return () => window.removeEventListener('scroll', handleScroll);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
src/lib/components/VolverArriba.svelte
Normal file
27
src/lib/components/VolverArriba.svelte
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<script>
|
||||||
|
import { fade, scale } from 'svelte/transition';
|
||||||
|
import Button from './ui/button/button.svelte';
|
||||||
|
import { MostrarVolver } from './MostrarVolver.svelte';
|
||||||
|
import ArrowUp from '@lucide/svelte/icons/arrow-up';
|
||||||
|
|
||||||
|
let mostrarVolver = new MostrarVolver();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if mostrarVolver.value}
|
||||||
|
<div transition:fade>
|
||||||
|
<div class="fixed right-9 bottom-12 flex flex-col gap-2" transition:scale>
|
||||||
|
<Button
|
||||||
|
onclick={() => {
|
||||||
|
window.scrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
class="align-middle"
|
||||||
|
>
|
||||||
|
Volver
|
||||||
|
<ArrowUp />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
import { sesionStore } from '@/stores/usuario';
|
import { sesionStore } from '@/stores/usuario';
|
||||||
import { likePost } from '@/hooks/likePost';
|
import { likePost } from '@/hooks/likePost';
|
||||||
import ThumbsUp from '@lucide/svelte/icons/thumbs-up';
|
import ThumbsUp from '@lucide/svelte/icons/thumbs-up';
|
||||||
import { TamañoPantalla } from './TamañoPantalla.svelte';
|
|
||||||
import BotonSeguir from '@/components/BotonSeguir.svelte';
|
import BotonSeguir from '@/components/BotonSeguir.svelte';
|
||||||
import Pen from '@lucide/svelte/icons/pen';
|
import Pen from '@lucide/svelte/icons/pen';
|
||||||
import Trash_2 from '@lucide/svelte/icons/trash-2';
|
import Trash_2 from '@lucide/svelte/icons/trash-2';
|
||||||
@@ -26,6 +25,7 @@
|
|||||||
import { deletePost } from '@/hooks/deletePost';
|
import { deletePost } from '@/hooks/deletePost';
|
||||||
import { flip } from 'svelte/animate';
|
import { flip } from 'svelte/animate';
|
||||||
import { obtenerRespuestasPorId } from '@/hooks/obtenerRespuestasPorId';
|
import { obtenerRespuestasPorId } from '@/hooks/obtenerRespuestasPorId';
|
||||||
|
import VolverArriba from '@/components/VolverArriba.svelte';
|
||||||
|
|
||||||
interface Prop {
|
interface Prop {
|
||||||
data: {
|
data: {
|
||||||
@@ -34,8 +34,6 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let tamaño = new TamañoPantalla();
|
|
||||||
|
|
||||||
let { data }: Prop = $props();
|
let { data }: Prop = $props();
|
||||||
|
|
||||||
let respuestasPaginadas: Post[] = $state([]);
|
let respuestasPaginadas: Post[] = $state([]);
|
||||||
@@ -154,6 +152,8 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<VolverArriba />
|
||||||
|
|
||||||
{#snippet Respuesta(post: Post)}
|
{#snippet Respuesta(post: Post)}
|
||||||
<div class="ml-2 flex-1">
|
<div class="ml-2 flex-1">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
|
|||||||
Reference in New Issue
Block a user