1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-23 14:59:36 +02:00

adventure card improvements

This commit is contained in:
Sean Morley 2024-07-18 18:37:46 -04:00
parent 704eb6f6de
commit 2ca24b9f15
6 changed files with 65 additions and 47 deletions

View file

@ -1,7 +1,7 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import { goto } from '$app/navigation';
import type { Adventure } from '$lib/types';
import type { Adventure, User } from '$lib/types';
const dispatch = createEventDispatcher();
import Launch from '~icons/mdi/launch';
@ -20,6 +20,8 @@
export let type: string;
export let user: User | null;
let isCollectionModalOpen: boolean = false;
export let adventure: Adventure;
@ -130,9 +132,9 @@
{adventure.name}
</h2>
<div>
{#if adventure.type == 'visited'}
{#if adventure.type == 'visited' && user?.pk == adventure.user_id}
<div class="badge badge-primary">Visited</div>
{:else}
{:else if user?.pk == adventure.user_id}
<div class="badge badge-secondary">Planned</div>
{/if}
<div class="badge badge-neutral">{adventure.is_public ? 'Public' : 'Private'}</div>
@ -162,6 +164,7 @@
<div class="card-actions justify-end mt-2">
<!-- action options dropdown -->
{#if type != 'link'}
{#if user?.pk == adventure.user_id}
<div class="dropdown dropdown-end">
<div tabindex="0" role="button" class="btn btn-neutral">
<DotsHorizontal class="w-6 h-6" />
@ -204,6 +207,11 @@
>
</ul>
</div>
{:else}
<button class="btn btn-neutral mb-2" on:click={() => goto(`/adventures/${adventure.id}`)}
><Launch class="w-6 h-6" /></button
>
{/if}
{/if}
{#if type == 'link'}
<button class="btn btn-primary" on:click={link}><Link class="w-6 h-6" /></button>

View file

@ -1,6 +1,6 @@
<script lang="ts">
import { deserialize } from '$app/forms';
import type { Adventure } from '$lib/types';
import type { Adventure, User } from '$lib/types';
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
import type { ActionResult } from '@sveltejs/kit';
@ -10,6 +10,8 @@
let adventures: Adventure[] = [];
export let user: User | null;
onMount(async () => {
modal = document.getElementById('my_modal_1') as HTMLDialogElement;
if (modal) {
@ -53,7 +55,7 @@
<h1 class="text-center font-bold text-4xl mb-6">My Adventures</h1>
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
{#each adventures as adventure}
<AdventureCard type="link" {adventure} on:link={add} />
<AdventureCard user={user ?? null} type="link" {adventure} on:link={add} />
{/each}
{#if adventures.length === 0}
<p class="text-center text-lg">

View file

@ -185,6 +185,7 @@
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
{#each adventures as adventure}
<AdventureCard
user={data.user}
type={adventure.type}
{adventure}
on:delete={deleteAdventure}

View file

@ -167,7 +167,7 @@
<h1 class="text-center font-bold text-4xl mb-6">My Collections</h1>
<p class="text-center">This search returned {count} results.</p>
{#if collections.length === 0}
<NotFound />
<NotFound error={undefined} />
{/if}
<div class="p-4">
<button

View file

@ -77,6 +77,7 @@
{#if isShowingCreateModal}
<AdventureLink
user={data?.user ?? null}
on:close={() => {
isShowingCreateModal = false;
}}
@ -171,6 +172,7 @@
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
{#each adventures as adventure}
<AdventureCard
user={data.user}
on:edit={editAdventure}
on:delete={deleteAdventure}
type={adventure.type}

View file

@ -48,7 +48,12 @@
<h2 class="text-center font-bold text-2xl mb-4">AdventureLog Results</h2>
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center">
{#each adventures as adventure}
<AdventureCard type={adventure.type} {adventure} on:delete={deleteAdventure} />
<AdventureCard
user={data.user}
type={adventure.type}
{adventure}
on:delete={deleteAdventure}
/>
{/each}
</div>
<div class="divider"></div>