Skip to content

Commit 5a67b76

Browse files
committed
More demo updates
1 parent 3b42776 commit 5a67b76

File tree

5 files changed

+25
-44
lines changed

5 files changed

+25
-44
lines changed

demos/bookstore/app/books.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default {
2626
type="search"
2727
name="q"
2828
placeholder="Search books by title, author, or description..."
29-
style="flex: 1;"
29+
css={{ flex: 1, padding: '0.5rem' }}
3030
/>
3131
<button type="submit" class="btn">
3232
Search
@@ -89,20 +89,10 @@ export default {
8989

9090
<div class="grid" style="margin-top: 2rem;">
9191
{books.map((book) => (
92-
<div class="book-card">
93-
<img
94-
src={`https://via.placeholder.com/280x300?text=${encodeURIComponent(book.title)}`}
95-
alt={book.title}
96-
/>
97-
<div class="book-card-body">
98-
<h3>{book.title}</h3>
99-
<p class="author">by {book.author}</p>
100-
<p class="price">${book.price.toFixed(2)}</p>
101-
<a href={routes.books.show.href({ slug: book.slug })} class="btn">
102-
View Details
103-
</a>
104-
</div>
105-
</div>
92+
<Frame
93+
fallback={<div>Loading...</div>}
94+
src={routes.fragments.bookCard.href({ slug: book.slug })}
95+
/>
10696
))}
10797
</div>
10898
</Layout>,

demos/bookstore/app/components/book-card.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { routes } from '../../routes.ts'
22

3-
import { ImageCarousel } from '../assets/image-carousel.tsx'
43
import { CartButton } from '../assets/cart-button.tsx'
54
import type { Book } from '../models/books.ts'
65

@@ -17,11 +16,13 @@ export function BookCard({ book, inCart }: BookCardProps) {
1716
<h3>{book.title}</h3>
1817
<p class="author">by {book.author}</p>
1918
<p class="price">${book.price.toFixed(2)}</p>
20-
<a href={routes.books.show.href({ slug: book.slug })} class="btn">
21-
View Details
22-
</a>
19+
<div style={{ display: 'flex', gap: '0.5rem', alignItems: 'center' }}>
20+
<a href={routes.books.show.href({ slug: book.slug })} class="btn">
21+
View Details
22+
</a>
2323

24-
<CartButton inCart={inCart} id={book.id} slug={book.slug} />
24+
<CartButton inCart={inCart} id={book.id} slug={book.slug} />
25+
</div>
2526
</div>
2627
</div>
2728
)

demos/bookstore/app/layout.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ export function Document({
2020
<script type="module" async src={routes.assets.href({ path: 'entry.js' })} />
2121
<style
2222
innerHTML={`
23-
* { margin: 0; padding: 0; box-sizing: border-box; }
23+
/* CSS Reset */
24+
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
25+
button, input, select, textarea { font: inherit; color: inherit; line-height: inherit; }
26+
button { background: none; border: none; cursor: pointer; }
27+
img { display: block; max-width: 100%; }
28+
a { color: inherit; }
29+
30+
/* Base Styles */
2431
body { font-family: system-ui, -apple-system, sans-serif; line-height: 1.6; color: #333; background: #f5f5f5; }
2532
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
2633
header { background: #2c3e50; color: white; padding: 1rem 0; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

demos/bookstore/app/marketing.tsx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,8 @@ export let contact: RouteHandlers<typeof routes.contact> = {
155155

156156
export let search: InferRouteHandler<typeof routes.search> = {
157157
use: [loadAuth],
158-
handler({ request }) {
159-
let url = new URL(request.url)
160-
let query = url.searchParams.get('q') || ''
161-
158+
handler({ url }) {
159+
let query = url.searchParams.get('q') ?? ''
162160
let books = query ? searchBooks(query) : []
163161

164162
return render(
@@ -172,7 +170,7 @@ export let search: InferRouteHandler<typeof routes.search> = {
172170
name="q"
173171
placeholder="Search books..."
174172
value={query}
175-
style="flex: 1;"
173+
css={{ flex: 1, padding: '0.5rem' }}
176174
/>
177175
<button type="submit" class="btn">
178176
Search
@@ -188,22 +186,7 @@ export let search: InferRouteHandler<typeof routes.search> = {
188186

189187
<div class="grid">
190188
{books.length > 0 ? (
191-
books.map((book) => (
192-
<div class="book-card">
193-
<img
194-
src={`https://via.placeholder.com/280x300?text=${encodeURIComponent(book.title)}`}
195-
alt={book.title}
196-
/>
197-
<div class="book-card-body">
198-
<h3>{book.title}</h3>
199-
<p class="author">by {book.author}</p>
200-
<p class="price">${book.price.toFixed(2)}</p>
201-
<a href={routes.books.show.href({ slug: book.slug })} class="btn">
202-
View Details
203-
</a>
204-
</div>
205-
</div>
206-
))
189+
books.map((book) => <Frame src={routes.fragments.bookCard.href({ slug: book.slug })} />)
207190
) : (
208191
<p>No books found matching your search.</p>
209192
)}

demos/bookstore/app/models/books.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ const booksData: Book[] = [
5151
id: '003',
5252
slug: 'three-ways',
5353
title: 'Three Ways to Change Your Life',
54-
author: 'The Great Change Wizard',
54+
author: 'Britney Spears',
5555
description: 'A practical guide to changing your life for the better.',
5656
price: 28.99,
57-
genre: 'science-fiction',
57+
genre: 'self-help',
5858
coverUrl: '/images/three-ways-1.png',
5959
imageUrls: ['/images/three-ways-1.png', '/images/three-ways-2.png', '/images/three-ways-3.png'],
6060
isbn: '978-0593135204',

0 commit comments

Comments
 (0)