Add profile pictures and improve modal animations
- Add ProfilePicture component with fallback to user initials - Integrate profile pictures in dashboard recent activity dialog layout - Add profile pictures to payments list and split details - Fix modal animation overshoot by using fixed positioning and smooth slide-in - Add fade-in animation for modal content with proper sequencing 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import { onMount, createEventDispatcher } from 'svelte';
|
import { onMount, createEventDispatcher } from 'svelte';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
|
import ProfilePicture from './ProfilePicture.svelte';
|
||||||
|
|
||||||
export let paymentId;
|
export let paymentId;
|
||||||
|
|
||||||
@@ -150,11 +151,14 @@
|
|||||||
{#each payment.splits as split}
|
{#each payment.splits as split}
|
||||||
<div class="split-item" class:current-user={split.username === session?.user?.nickname}>
|
<div class="split-item" class:current-user={split.username === session?.user?.nickname}>
|
||||||
<div class="split-user">
|
<div class="split-user">
|
||||||
|
<ProfilePicture username={split.username} size={24} />
|
||||||
|
<div class="user-info">
|
||||||
<span class="username">{split.username}</span>
|
<span class="username">{split.username}</span>
|
||||||
{#if split.username === session?.user?.nickname}
|
{#if split.username === session?.user?.nickname}
|
||||||
<span class="you-badge">You</span>
|
<span class="you-badge">You</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="split-amount" class:positive={split.amount < 0} class:negative={split.amount > 0}>
|
<div class="split-amount" class:positive={split.amount < 0} class:negative={split.amount > 0}>
|
||||||
{#if split.amount > 0}
|
{#if split.amount > 0}
|
||||||
owes {formatCurrency(split.amount)}
|
owes {formatCurrency(split.amount)}
|
||||||
@@ -362,6 +366,12 @@
|
|||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.split-user .user-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.username {
|
.username {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
|
66
src/lib/components/ProfilePicture.svelte
Normal file
66
src/lib/components/ProfilePicture.svelte
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<script>
|
||||||
|
export let username;
|
||||||
|
export let size = 40; // Default size in pixels
|
||||||
|
export let alt = '';
|
||||||
|
|
||||||
|
let imageError = false;
|
||||||
|
|
||||||
|
$: profileUrl = `https://bocken.org/static/user/full/${username}.webp`;
|
||||||
|
$: altText = alt || `${username}'s profile picture`;
|
||||||
|
|
||||||
|
function handleError() {
|
||||||
|
imageError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getInitials(name) {
|
||||||
|
if (!name) return '?';
|
||||||
|
return name.split(' ')
|
||||||
|
.map(word => word.charAt(0))
|
||||||
|
.join('')
|
||||||
|
.toUpperCase()
|
||||||
|
.substring(0, 2);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="profile-picture" style="width: {size}px; height: {size}px;">
|
||||||
|
{#if !imageError}
|
||||||
|
<img
|
||||||
|
src={profileUrl}
|
||||||
|
alt={altText}
|
||||||
|
on:error={handleError}
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<div class="fallback">
|
||||||
|
{getInitials(username)}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.profile-picture {
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fallback {
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 0.75em;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
</style>
|
@@ -38,38 +38,63 @@
|
|||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if showModal}
|
|
||||||
<div class="side-panel">
|
<div class="side-panel">
|
||||||
|
{#if showModal}
|
||||||
|
<div class="modal-content">
|
||||||
<PaymentModal {paymentId} on:close={() => showModal = false} />
|
<PaymentModal {paymentId} on:close={() => showModal = false} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.layout-container {
|
.layout-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-content {
|
.main-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
transition: all 0.3s ease;
|
transition: margin-right 0.3s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-container.has-modal .main-content {
|
.layout-container.has-modal .main-content {
|
||||||
flex: 0 0 60%;
|
margin-right: 400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.side-panel {
|
.side-panel {
|
||||||
flex: 0 0 40%;
|
position: fixed;
|
||||||
min-width: 400px;
|
top: 0;
|
||||||
max-width: 500px;
|
right: 0;
|
||||||
|
width: 400px;
|
||||||
|
height: 100vh;
|
||||||
background: white;
|
background: white;
|
||||||
border-left: 1px solid #dee2e6;
|
border-left: 1px solid #dee2e6;
|
||||||
box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
|
box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
transform: translateX(100%);
|
||||||
|
transition: transform 0.3s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-container.has-modal .side-panel {
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-content {
|
||||||
|
opacity: 0;
|
||||||
|
animation: fadeIn 0.3s ease-out 0.1s forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(20px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { pushState } from '$app/navigation';
|
import { pushState } from '$app/navigation';
|
||||||
|
import ProfilePicture from '$lib/components/ProfilePicture.svelte';
|
||||||
|
|
||||||
export let data; // Used by the layout for session data
|
export let data; // Used by the layout for session data
|
||||||
|
|
||||||
@@ -96,16 +97,21 @@
|
|||||||
{#if balance.recentSplits && balance.recentSplits.length > 0}
|
{#if balance.recentSplits && balance.recentSplits.length > 0}
|
||||||
<div class="recent-activity">
|
<div class="recent-activity">
|
||||||
<h2>Recent Activity</h2>
|
<h2>Recent Activity</h2>
|
||||||
<div class="activity-list">
|
<div class="activity-dialog">
|
||||||
{#each balance.recentSplits as split}
|
{#each balance.recentSplits as split}
|
||||||
|
<div class="activity-message" class:is-me={split.paymentId?.paidBy === data.session?.user?.nickname}>
|
||||||
|
<div class="message-content">
|
||||||
|
<ProfilePicture username={split.paymentId?.paidBy || 'Unknown'} size={36} />
|
||||||
<a
|
<a
|
||||||
href="/cospend/payments/view/{split.paymentId?._id}"
|
href="/cospend/payments/view/{split.paymentId?._id}"
|
||||||
class="activity-item"
|
class="activity-bubble"
|
||||||
on:click={(e) => handlePaymentClick(split.paymentId?._id, e)}
|
on:click={(e) => handlePaymentClick(split.paymentId?._id, e)}
|
||||||
>
|
>
|
||||||
<div class="activity-info">
|
|
||||||
<div class="activity-header">
|
<div class="activity-header">
|
||||||
|
<div class="user-info">
|
||||||
<strong class="payment-title">{split.paymentId?.title || 'Payment'}</strong>
|
<strong class="payment-title">{split.paymentId?.title || 'Payment'}</strong>
|
||||||
|
<span class="username">Paid by {split.paymentId?.paidBy || 'Unknown'}</span>
|
||||||
|
</div>
|
||||||
<div class="activity-amount" class:positive={split.amount < 0} class:negative={split.amount > 0}>
|
<div class="activity-amount" class:positive={split.amount < 0} class:negative={split.amount > 0}>
|
||||||
{#if split.amount > 0}
|
{#if split.amount > 0}
|
||||||
-{formatCurrency(split.amount)}
|
-{formatCurrency(split.amount)}
|
||||||
@@ -118,7 +124,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="payment-details">
|
<div class="payment-details">
|
||||||
<div class="payment-meta">
|
<div class="payment-meta">
|
||||||
<span class="paid-by">Paid by {split.paymentId?.paidBy || 'Unknown'}</span>
|
|
||||||
<span class="payment-date">{formatDate(split.createdAt)}</span>
|
<span class="payment-date">{formatDate(split.createdAt)}</span>
|
||||||
</div>
|
</div>
|
||||||
{#if split.paymentId?.description}
|
{#if split.paymentId?.description}
|
||||||
@@ -127,8 +132,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</a>
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -277,45 +283,112 @@
|
|||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-list {
|
.activity-dialog {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1rem;
|
gap: 0.75rem;
|
||||||
|
padding: 0.5rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-item {
|
.activity-message {
|
||||||
display: block;
|
display: flex;
|
||||||
padding: 1rem;
|
align-items: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-message.is-me {
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-content {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.75rem;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-message.is-me .message-content {
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-bubble {
|
||||||
background: #f8f9fa;
|
background: #f8f9fa;
|
||||||
border-radius: 0.5rem;
|
border-radius: 1rem;
|
||||||
|
padding: 1rem;
|
||||||
|
position: relative;
|
||||||
|
border: 1px solid #e9ecef;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
display: block;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
border: 1px solid transparent;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-item:hover {
|
.activity-message.is-me .activity-bubble {
|
||||||
background: #e9ecef;
|
background: #e3f2fd;
|
||||||
border-color: #1976d2;
|
border-color: #2196f3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-bubble:hover {
|
||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-info {
|
.activity-bubble::before {
|
||||||
width: 100%;
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 1rem;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border: 8px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-bubble::before {
|
||||||
|
left: -15px;
|
||||||
|
border-right-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-message.is-me .activity-bubble::before {
|
||||||
|
left: auto;
|
||||||
|
right: -15px;
|
||||||
|
border-left-color: #e3f2fd;
|
||||||
|
border-right-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-header {
|
.activity-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.payment-title {
|
.payment-title {
|
||||||
color: #333;
|
color: #333;
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
margin-right: 1rem;
|
font-weight: 600;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.username {
|
||||||
|
color: #666;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.you-badge {
|
||||||
|
background-color: #1976d2;
|
||||||
|
color: white;
|
||||||
|
padding: 0.125rem 0.5rem;
|
||||||
|
border-radius: 1rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.activity-amount {
|
.activity-amount {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import ProfilePicture from '$lib/components/ProfilePicture.svelte';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
@@ -133,6 +134,8 @@
|
|||||||
{#each payments as payment}
|
{#each payments as payment}
|
||||||
<div class="payment-card">
|
<div class="payment-card">
|
||||||
<div class="payment-header">
|
<div class="payment-header">
|
||||||
|
<div class="payment-title-section">
|
||||||
|
<ProfilePicture username={payment.paidBy} size={40} />
|
||||||
<div class="payment-title">
|
<div class="payment-title">
|
||||||
<h3>{payment.title}</h3>
|
<h3>{payment.title}</h3>
|
||||||
<div class="payment-meta">
|
<div class="payment-meta">
|
||||||
@@ -140,6 +143,7 @@
|
|||||||
<span class="amount">{formatCurrency(payment.amount)}</span>
|
<span class="amount">{formatCurrency(payment.amount)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{#if payment.image}
|
{#if payment.image}
|
||||||
<img src={payment.image} alt="Receipt" class="receipt-thumb" />
|
<img src={payment.image} alt="Receipt" class="receipt-thumb" />
|
||||||
{/if}
|
{/if}
|
||||||
@@ -335,6 +339,13 @@
|
|||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.payment-title-section {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.75rem;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.payment-title h3 {
|
.payment-title h3 {
|
||||||
margin: 0 0 0.5rem 0;
|
margin: 0 0 0.5rem 0;
|
||||||
color: #333;
|
color: #333;
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import ProfilePicture from '$lib/components/ProfilePicture.svelte';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
@@ -123,11 +124,14 @@
|
|||||||
{#each payment.splits as split}
|
{#each payment.splits as split}
|
||||||
<div class="split-item" class:current-user={split.username === data.session.user.nickname}>
|
<div class="split-item" class:current-user={split.username === data.session.user.nickname}>
|
||||||
<div class="split-user">
|
<div class="split-user">
|
||||||
|
<ProfilePicture username={split.username} size={24} />
|
||||||
|
<div class="user-info">
|
||||||
<span class="username">{split.username}</span>
|
<span class="username">{split.username}</span>
|
||||||
{#if split.username === data.session.user.nickname}
|
{#if split.username === data.session.user.nickname}
|
||||||
<span class="you-badge">You</span>
|
<span class="you-badge">You</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="split-amount" class:positive={split.amount < 0} class:negative={split.amount > 0}>
|
<div class="split-amount" class:positive={split.amount < 0} class:negative={split.amount > 0}>
|
||||||
{#if split.amount > 0}
|
{#if split.amount > 0}
|
||||||
owes {formatCurrency(split.amount)}
|
owes {formatCurrency(split.amount)}
|
||||||
@@ -332,6 +336,12 @@
|
|||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.split-user .user-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.username {
|
.username {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
|
Reference in New Issue
Block a user