-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update carousel, move to own component.
- Loading branch information
Showing
3 changed files
with
40 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<script lang="ts"> | ||
import { onDestroy, onMount } from 'svelte'; | ||
import { fade } from 'svelte/transition'; | ||
import type { Spotlight } from '../lib/app-types'; | ||
export let projects: Spotlight[]; | ||
let currentSpotlightIndex = 0; | ||
function next() { | ||
currentSpotlightIndex = (currentSpotlightIndex + 1) % projects.length; | ||
} | ||
$: projectName = projects[currentSpotlightIndex].title; | ||
$: projectLink = `papers/${projects[currentSpotlightIndex].paper}`; | ||
let timer: any; | ||
const timeout = 5000; | ||
onMount(() => { | ||
timer = setInterval(next, timeout); | ||
}); | ||
onDestroy(() => { | ||
clearInterval(timer); | ||
}); | ||
</script> | ||
|
||
<div class="spotlight relative w-full hidden md:flex h-52"> | ||
{#each projects as image, index (image)} | ||
{#if index === currentSpotlightIndex} | ||
<a href={projectLink} in:fade={{ duration: 1000 }} out:fade={{ duration: 1000 }}> | ||
<img src={image.image} alt="Image for {projectName}" /> | ||
<div>{projectName}</div> | ||
</a> | ||
{/if} | ||
{/each} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters