-
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.
Merge pull request #3 from orbisat-oeiras/post-carousel
Post carousel
- Loading branch information
Showing
54 changed files
with
251 additions
and
149 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Deploy to GitHub Pages | |
|
||
on: | ||
push: | ||
branches: "svelte" | ||
branches: "main" | ||
|
||
jobs: | ||
build_site: | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,11 +1,67 @@ | ||
<script lang="ts"> | ||
import type { Post } from '$lib/server/post.type'; | ||
import { themeStore } from '$lib/stores'; | ||
import PostComponent from './PostComponent.svelte'; | ||
export let postList: Post[]; | ||
// Carousel implementation | ||
// Width of the carousel | ||
let current_width = 0; | ||
// Container for the carouusel items | ||
let container: HTMLElement; | ||
// ???? | ||
let scroll_left = 0; | ||
let scroll_width = 0; | ||
// Scroll left to the next item | ||
function left() { | ||
container.scrollBy(-current_width, 0); | ||
} | ||
// Scroll right to the next item | ||
function right() { | ||
container.scrollBy(current_width, 0); | ||
} | ||
function scroll() { | ||
scroll_left = container.scrollLeft; | ||
scroll_width = container.scrollWidth; | ||
} | ||
</script> | ||
|
||
<div class="grid grid-cols-1 gap-x-4 gap-y-4 py-4 md:grid-cols-2 md:gap-x-[2%]"> | ||
{#each postList as post} | ||
<PostComponent {post} /> | ||
{/each} | ||
</div> | ||
{#if postList.length >= 1} | ||
<div class="flex overflow-hidden justify-between w-full"> | ||
<button | ||
class="dark:text-cansat-black dark:bg-cansat-cream text-cansat-cream bg-cansat-grey border-cansat-cream border-2 rounded-none rounded-l border-none p-4" | ||
on:pointerdown={left} | ||
style="background-color: {scroll_left == 0 ? '#b7b3a7' : $themeStore ? '#58595b' : '#fffde9'}" | ||
> | ||
<slot name="left_button"><</slot> | ||
</button> | ||
<div | ||
class="flex flex-grow overflow-auto overflow-x-auto snap-x snap-mandatory scroll-smooth [&>*]:snap-start [&>*]:flex-shrink-0 [&>*]:w-full [&::-webkit-scrollbar]:hidden" | ||
bind:clientWidth={current_width} | ||
bind:this={container} | ||
on:scroll={scroll} | ||
> | ||
{#each postList as post} | ||
<PostComponent {post} /> | ||
{/each} | ||
</div> | ||
<button | ||
class="dark:text-cansat-black dark:bg-cansat-cream text-cansat-cream bg-cansat-grey border-cansat-cream border-2 rounded-none rounded-r border-none p-4" | ||
on:pointerdown={right} | ||
style="background-color: {Math.abs(scroll_left + current_width - scroll_width) < 3 | ||
? '#b7b3a7' | ||
: $themeStore | ||
? '#58595b' | ||
: '#fffde9'}" | ||
> | ||
<slot name="right_button">></slot> | ||
</button> | ||
</div> | ||
{:else} | ||
<h4 class="no-underline text-center py-10"> | ||
Até à data não temos <em>posts</em>, mas estejam preparados para futuras publicações. | ||
</h4> | ||
{/if} |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.