dashboard.create()
Creates a comprehensive library management dashboard with tabbed navigation and multiple workspaces.Signature
Parameters
Async callback triggered when user scans a book ISBN in the checkout workspace (Enter key on
checkout_input).Expected behavior:- Fetch book data by ISBN/barcode
- Validate book is available
- Add to cart and update UI
- Show book preview (cover, title, author, due date)
Async callback triggered when user clicks the “CONFIRM CHECKOUT” button.Expected behavior:
- Process all items in cart
- Update database (mark books as checked out)
- Show success notification
- Clear cart UI
- Refresh catalog to reflect new availability
Async callback triggered when user scans a book barcode in the return workspace (Enter key on
return_input).Expected behavior:- Fetch book data
- Validate book is checked out
- Process return in database
- Update return preview (cover, title, status badge)
- Show success notification
Callback triggered on search input value changes.Parameters:
- Receives search query string as argument
- Filter catalog by title or author
- Reset to page 1
- Refresh catalog display
Async callback triggered when “MY BOOKS” tab is clicked.Expected behavior:
- Fetch user’s active loans and history
- Populate
active_loans_containerwith current checkouts - Populate
history_containerwith returned books - Show/hide empty state messages
- Enable/disable renew buttons based on overdue status
Async callback for catalog pagination - advance to next page.Expected behavior:
- Increment page counter
- Refresh catalog grid
- Update page label
- Enable/disable prev/next buttons as needed
Async callback for catalog pagination - go to previous page.Expected behavior:
- Decrement page counter (minimum 1)
- Refresh catalog grid
- Update page label
- Enable/disable prev/next buttons as needed
Returns
Returns a tuple of 21 UI elements for programmatic access:Root container with class
scsu-bg w-full h-screen items-center pt-28 overflow-y-auto.Initially hidden (visible = False) - set to True after successful login.ISBN/barcode input field in checkout workspace. Placeholder: “Scan ISBN…”Bound to
on_checkout_scan via keydown.enter event.Book cover preview in checkout workspace. Default source: placeholder image.Update with
checkout_cover.source = book['cover']Book title display in checkout workspace. Default: ”---”Update with
checkout_title.text = book['title']Book author display in checkout workspace. Default: ”---”Update with
checkout_author.text = book['author']Scrollable container for cart items. Clear with
cart_container.clear() and populate with book rows.“CONFIRM CHECKOUT (0)” button. Initially disabled.Update count and enable when items added to cart.
Barcode input field in return workspace. Placeholder: “Scan barcode to return…”Bound to
on_return_scan via keydown.enter event.Book cover preview in return workspace.
Book title display in return workspace.
Status badge in return workspace. Default: “WAITING FOR SCAN”Update to “RETURNED SUCCESSFULLY” and change styling on successful return.
Empty state message for cart. Contains shopping cart icon and “Cart is empty” text.Set
visible = False when items are added.Flex-wrap container for book cards in catalog workspace.Clear and repopulate with
catalog_grid.clear() and context manager.Due date display in checkout preview. Initially empty.Set with
checkout_due_date.text = f'Due: {due_date}'Container for active/checked-out books in “MY BOOKS” workspace.
Empty state for active loans (“No books currently checked out”).
Container for returned books history in “MY BOOKS” workspace.
Empty state for history (“No borrowing history yet”).
“PREV PAGE” button in catalog pagination.
“NEXT PAGE” button in catalog pagination.
Page indicator (e.g., “Page 1”).
UI Structure
The dashboard contains four main workspaces accessed via a sticky navigation bar:Navigation Bar (Sticky Top)
- BROWSE button → Shows catalog workspace
- CHECKOUT button → Shows checkout workspace
- RETURN button → Shows return workspace
- MY BOOKS button → Shows user’s loans
- SEARCH toggle → Reveals search input (catalog only)
Catalog Workspace (Default)
- “Current Collection” heading
- Grid of book cards (200px wide each)
- Book cover image
- Title and author
- Availability badge (green “AVAILABLE” or red “CHECKED OUT”)
- Hover scale effect
- Pagination controls (PREV/NEXT buttons, page label)
Checkout Workspace
Two-column layout: Left Column - Scanner- “SCAN TO ADD TO CART” heading
- ISBN barcode input
- Book preview (cover, title, author, due date)
- Updates on each scan
- “YOUR CART” heading
- Empty state message (cart icon) or list of scanned items
- Each item shows: thumbnail, title, author, due date
- “CONFIRM CHECKOUT (N)” button at bottom
- Disabled when cart empty (gray)
- Enabled when items present (blue glow)
Return Workspace
Single centered card:- “QUICK RETURN” heading
- Barcode input
- Horizontal layout:
- Book cover preview (left)
- Status badge + title (right)
- Status badge changes color on successful return
My Books Workspace
Scrollable card with two sections: Currently Checked Out- Count display (“Total Books Checked Out: N”)
- List of active loans with:
- Thumbnail, title, author
- Due date (red if overdue, blue otherwise)
- “RENEW” button (disabled if overdue)
- Empty state: “No books currently checked out”
- List of returned books with:
- Thumbnail, title, author
- Return date
- Reduced opacity for historical items
- Empty state: “No borrowing history yet”
Usage Example
Navigation State Management
The dashboard uses internal state to manage tab switching:visible property:
catalog_workspace.visible = Truecheckout_workspace.visible = False- etc.
Styling Classes
Key Tailwind classes used:- Nav bar:
bg-slate-900/40 border border-white/5 backdrop-blur-2xl rounded-full - Cards:
bg-[#151924]/80 border border-slate-700/50 rounded-[32px] - Buttons (active):
bg-white/5 shadow-[0_0_20px_rgba(59,130,246,0.5)] border-white/10 - Buttons (hover):
hover:bg-blue-600/40 hover:shadow-[0_0_30px_-5px_rgba(59,130,246,0.5)]
See Also
- Login Components - Authentication interfaces
- Register Component - Account creation
- Database Module - Book and loan management functions