This commit is contained in:
Danilo Reyes
2025-11-02 01:01:38 -06:00
parent b0e22af242
commit 48020b6f42
8 changed files with 2473 additions and 17 deletions

View File

@@ -0,0 +1,218 @@
<script lang="ts">
import { onMount } from 'svelte';
import { goto } from '$app/navigation';
import { boards, boardsList, boardsLoading, boardsError } from '$lib/stores/boards';
import BoardCard from '$lib/components/boards/BoardCard.svelte';
import CreateBoardModal from '$lib/components/boards/CreateBoardModal.svelte';
let showCreateModal = false;
let deleteConfirmId: string | null = null;
onMount(() => {
boards.load();
});
function openCreateModal() {
showCreateModal = true;
}
function closeCreateModal() {
showCreateModal = false;
}
async function handleCreate(event: CustomEvent<{ title: string; description?: string }>) {
try {
const board = await boards.create(event.detail);
closeCreateModal();
goto(`/boards/${board.id}`);
} catch (error) {
console.error('Failed to create board:', error);
}
}
async function handleDelete(boardId: string) {
if (!confirm('Are you sure you want to delete this board? This action cannot be undone.')) {
return;
}
try {
await boards.delete(boardId);
} catch (error) {
console.error('Failed to delete board:', error);
}
}
</script>
<div class="boards-page">
<header class="page-header">
<h1>My Boards</h1>
<button on:click={openCreateModal} class="btn-primary">
<span class="icon">+</span>
New Board
</button>
</header>
{#if $boardsError}
<div class="error-banner">
<span class="error-icon"></span>
{$boardsError}
<button on:click={() => boards.clearError()} class="close-btn">×</button>
</div>
{/if}
{#if $boardsLoading}
<div class="loading">
<div class="spinner"></div>
<p>Loading boards...</p>
</div>
{:else if $boardsList.length === 0}
<div class="empty-state">
<div class="empty-icon">📋</div>
<h2>No boards yet</h2>
<p>Create your first reference board to get started</p>
<button on:click={openCreateModal} class="btn-primary">Create Board</button>
</div>
{:else}
<div class="boards-grid">
{#each $boardsList as board (board.id)}
<BoardCard {board} on:delete={() => handleDelete(board.id)} />
{/each}
</div>
{/if}
</div>
{#if showCreateModal}
<CreateBoardModal on:create={handleCreate} on:close={closeCreateModal} />
{/if}
<style>
.boards-page {
max-width: 1200px;
margin: 0 auto;
padding: 2rem;
}
.page-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
}
.page-header h1 {
font-size: 2rem;
font-weight: 700;
color: #1f2937;
margin: 0;
}
.btn-primary {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.75rem 1.5rem;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.icon {
font-size: 1.25rem;
}
.error-banner {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 1rem;
background: #fee2e2;
border: 1px solid #fca5a5;
border-radius: 8px;
color: #991b1b;
margin-bottom: 1.5rem;
}
.error-icon {
font-size: 1.25rem;
}
.close-btn {
margin-left: auto;
background: none;
border: none;
font-size: 1.5rem;
color: #991b1b;
cursor: pointer;
padding: 0;
line-height: 1;
}
.loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 4rem;
color: #6b7280;
}
.spinner {
width: 48px;
height: 48px;
border: 4px solid #e5e7eb;
border-top-color: #667eea;
border-radius: 50%;
animation: spin 0.8s linear infinite;
margin-bottom: 1rem;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 4rem;
text-align: center;
}
.empty-icon {
font-size: 4rem;
margin-bottom: 1rem;
opacity: 0.5;
}
.empty-state h2 {
font-size: 1.5rem;
font-weight: 600;
color: #374151;
margin: 0 0 0.5rem 0;
}
.empty-state p {
color: #6b7280;
margin: 0 0 2rem 0;
}
.boards-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 1.5rem;
}
</style>

View File

@@ -0,0 +1,381 @@
<script lang="ts">
import { onMount } from 'svelte';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { boards, currentBoard } from '$lib/stores/boards';
let title = '';
let description = '';
let isLoading = true;
let isSubmitting = false;
let errors: Record<string, string> = {};
$: boardId = $page.params.id;
onMount(async () => {
try {
await boards.loadBoard(boardId);
if ($currentBoard) {
title = $currentBoard.title;
description = $currentBoard.description || '';
}
} catch (error) {
console.error('Failed to load board:', error);
errors.general = 'Failed to load board';
} finally {
isLoading = false;
}
});
function validate(): boolean {
errors = {};
if (!title.trim()) {
errors.title = 'Title is required';
} else if (title.length > 255) {
errors.title = 'Title must be 255 characters or less';
}
if (description.length > 1000) {
errors.description = 'Description must be 1000 characters or less';
}
return Object.keys(errors).length === 0;
}
async function handleSubmit() {
if (!validate()) return;
isSubmitting = true;
try {
await boards.update(boardId, {
title: title.trim(),
description: description.trim() || undefined,
});
// Navigate back to board view
goto(`/boards/${boardId}`);
} catch (error) {
console.error('Failed to update board:', error);
errors.general = error instanceof Error ? error.message : 'Failed to update board';
} finally {
isSubmitting = false;
}
}
function handleCancel() {
goto(`/boards/${boardId}`);
}
</script>
<svelte:head>
<title>Edit Board - Reference Board Viewer</title>
</svelte:head>
<div class="edit-board-page">
<div class="page-container">
<header class="page-header">
<button class="back-btn" on:click={handleCancel} aria-label="Go back">
← Back to Board
</button>
<h1>Edit Board</h1>
</header>
{#if isLoading}
<div class="loading">
<div class="spinner"></div>
<p>Loading board...</p>
</div>
{:else if errors.general}
<div class="error-banner">
<span class="error-icon"></span>
{errors.general}
<button class="back-btn-inline" on:click={() => goto('/boards')}>
Return to Boards
</button>
</div>
{:else}
<form on:submit|preventDefault={handleSubmit} class="board-form">
<div class="form-group">
<label for="title">Board Title <span class="required">*</span></label>
<input
id="title"
type="text"
bind:value={title}
disabled={isSubmitting}
placeholder="e.g., Character Design References"
class:error={errors.title}
maxlength="255"
required
/>
{#if errors.title}
<span class="error-text">{errors.title}</span>
{:else}
<span class="help-text">{title.length}/255 characters</span>
{/if}
</div>
<div class="form-group">
<label for="description">Description (optional)</label>
<textarea
id="description"
bind:value={description}
disabled={isSubmitting}
placeholder="Add a description to help organize your boards..."
rows="4"
maxlength="1000"
class:error={errors.description}
/>
{#if errors.description}
<span class="error-text">{errors.description}</span>
{:else}
<span class="help-text">{description.length}/1000 characters</span>
{/if}
</div>
<div class="form-actions">
<button
type="button"
class="btn-secondary"
on:click={handleCancel}
disabled={isSubmitting}
>
Cancel
</button>
<button type="submit" class="btn-primary" disabled={isSubmitting}>
{#if isSubmitting}
<span class="spinner-small"></span>
Saving...
{:else}
Save Changes
{/if}
</button>
</div>
</form>
{/if}
</div>
</div>
<style>
.edit-board-page {
min-height: 100vh;
background: #f9fafb;
padding: 2rem;
}
.page-container {
max-width: 600px;
margin: 0 auto;
}
.page-header {
margin-bottom: 2rem;
}
.back-btn {
background: none;
border: none;
color: #667eea;
font-size: 0.95rem;
cursor: pointer;
padding: 0.5rem 0;
margin-bottom: 1rem;
display: inline-flex;
align-items: center;
transition: color 0.2s;
}
.back-btn:hover {
color: #764ba2;
}
.page-header h1 {
font-size: 2rem;
font-weight: 700;
color: #1f2937;
margin: 0;
}
.loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 4rem;
color: #6b7280;
}
.spinner {
width: 48px;
height: 48px;
border: 4px solid #e5e7eb;
border-top-color: #667eea;
border-radius: 50%;
animation: spin 0.8s linear infinite;
margin-bottom: 1rem;
}
.error-banner {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 1rem;
background: #fee2e2;
border: 1px solid #fca5a5;
border-radius: 8px;
color: #991b1b;
margin-bottom: 1.5rem;
}
.error-icon {
font-size: 1.25rem;
}
.back-btn-inline {
margin-left: auto;
background: none;
border: none;
color: #991b1b;
text-decoration: underline;
cursor: pointer;
padding: 0;
}
.board-form {
background: white;
border-radius: 12px;
padding: 2rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.form-group {
margin-bottom: 1.5rem;
}
label {
display: block;
font-weight: 500;
color: #374151;
margin-bottom: 0.5rem;
font-size: 0.95rem;
}
.required {
color: #ef4444;
}
input,
textarea {
width: 100%;
padding: 0.75rem;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 1rem;
font-family: inherit;
transition: all 0.2s;
}
input:focus,
textarea:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
input.error,
textarea.error {
border-color: #ef4444;
}
input:disabled,
textarea:disabled {
background-color: #f9fafb;
cursor: not-allowed;
}
textarea {
resize: vertical;
min-height: 100px;
}
.error-text {
display: block;
color: #ef4444;
font-size: 0.875rem;
margin-top: 0.25rem;
}
.help-text {
display: block;
color: #6b7280;
font-size: 0.875rem;
margin-top: 0.25rem;
}
.form-actions {
display: flex;
gap: 1rem;
justify-content: flex-end;
margin-top: 2rem;
padding-top: 1.5rem;
border-top: 1px solid #e5e7eb;
}
.btn-primary,
.btn-secondary {
padding: 0.75rem 1.5rem;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
border: none;
display: flex;
align-items: center;
gap: 0.5rem;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover:not(:disabled) {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.btn-primary:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.btn-secondary {
background: white;
color: #374151;
border: 1px solid #d1d5db;
}
.btn-secondary:hover:not(:disabled) {
background: #f9fafb;
}
.spinner-small {
width: 16px;
height: 16px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-top-color: white;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
</style>

View File

@@ -0,0 +1,319 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { boards } from '$lib/stores/boards';
let title = '';
let description = '';
let isSubmitting = false;
let errors: Record<string, string> = {};
function validate(): boolean {
errors = {};
if (!title.trim()) {
errors.title = 'Title is required';
} else if (title.length > 255) {
errors.title = 'Title must be 255 characters or less';
}
if (description.length > 1000) {
errors.description = 'Description must be 1000 characters or less';
}
return Object.keys(errors).length === 0;
}
async function handleSubmit() {
if (!validate()) return;
isSubmitting = true;
try {
const board = await boards.create({
title: title.trim(),
description: description.trim() || undefined,
});
// Navigate to the new board
goto(`/boards/${board.id}`);
} catch (error) {
console.error('Failed to create board:', error);
errors.general = error instanceof Error ? error.message : 'Failed to create board';
} finally {
isSubmitting = false;
}
}
function handleCancel() {
goto('/boards');
}
</script>
<svelte:head>
<title>New Board - Reference Board Viewer</title>
</svelte:head>
<div class="new-board-page">
<div class="page-container">
<header class="page-header">
<button class="back-btn" on:click={handleCancel} aria-label="Go back">
← Back to Boards
</button>
<h1>Create New Board</h1>
</header>
{#if errors.general}
<div class="error-banner">
<span class="error-icon"></span>
{errors.general}
</div>
{/if}
<form on:submit|preventDefault={handleSubmit} class="board-form">
<div class="form-group">
<label for="title">Board Title <span class="required">*</span></label>
<input
id="title"
type="text"
bind:value={title}
disabled={isSubmitting}
placeholder="e.g., Character Design References"
class:error={errors.title}
maxlength="255"
required
autofocus
/>
{#if errors.title}
<span class="error-text">{errors.title}</span>
{:else}
<span class="help-text">{title.length}/255 characters</span>
{/if}
</div>
<div class="form-group">
<label for="description">Description (optional)</label>
<textarea
id="description"
bind:value={description}
disabled={isSubmitting}
placeholder="Add a description to help organize your boards..."
rows="4"
maxlength="1000"
class:error={errors.description}
/>
{#if errors.description}
<span class="error-text">{errors.description}</span>
{:else}
<span class="help-text">{description.length}/1000 characters</span>
{/if}
</div>
<div class="form-actions">
<button type="button" class="btn-secondary" on:click={handleCancel} disabled={isSubmitting}>
Cancel
</button>
<button type="submit" class="btn-primary" disabled={isSubmitting}>
{#if isSubmitting}
<span class="spinner"></span>
Creating...
{:else}
Create Board
{/if}
</button>
</div>
</form>
</div>
</div>
<style>
.new-board-page {
min-height: 100vh;
background: #f9fafb;
padding: 2rem;
}
.page-container {
max-width: 600px;
margin: 0 auto;
}
.page-header {
margin-bottom: 2rem;
}
.back-btn {
background: none;
border: none;
color: #667eea;
font-size: 0.95rem;
cursor: pointer;
padding: 0.5rem 0;
margin-bottom: 1rem;
display: inline-flex;
align-items: center;
transition: color 0.2s;
}
.back-btn:hover {
color: #764ba2;
}
.page-header h1 {
font-size: 2rem;
font-weight: 700;
color: #1f2937;
margin: 0;
}
.error-banner {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 1rem;
background: #fee2e2;
border: 1px solid #fca5a5;
border-radius: 8px;
color: #991b1b;
margin-bottom: 1.5rem;
}
.error-icon {
font-size: 1.25rem;
}
.board-form {
background: white;
border-radius: 12px;
padding: 2rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.form-group {
margin-bottom: 1.5rem;
}
label {
display: block;
font-weight: 500;
color: #374151;
margin-bottom: 0.5rem;
font-size: 0.95rem;
}
.required {
color: #ef4444;
}
input,
textarea {
width: 100%;
padding: 0.75rem;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 1rem;
font-family: inherit;
transition: all 0.2s;
}
input:focus,
textarea:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
input.error,
textarea.error {
border-color: #ef4444;
}
input:disabled,
textarea:disabled {
background-color: #f9fafb;
cursor: not-allowed;
}
textarea {
resize: vertical;
min-height: 100px;
}
.error-text {
display: block;
color: #ef4444;
font-size: 0.875rem;
margin-top: 0.25rem;
}
.help-text {
display: block;
color: #6b7280;
font-size: 0.875rem;
margin-top: 0.25rem;
}
.form-actions {
display: flex;
gap: 1rem;
justify-content: flex-end;
margin-top: 2rem;
padding-top: 1.5rem;
border-top: 1px solid #e5e7eb;
}
.btn-primary,
.btn-secondary {
padding: 0.75rem 1.5rem;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
border: none;
display: flex;
align-items: center;
gap: 0.5rem;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover:not(:disabled) {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.btn-primary:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.btn-secondary {
background: white;
color: #374151;
border: 1px solid #d1d5db;
}
.btn-secondary:hover:not(:disabled) {
background: #f9fafb;
}
.spinner {
width: 16px;
height: 16px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-top-color: white;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
</style>