Market Components

Mobile-first e-commerce components designed for local farmers markets. Each component is optimized for touch interactions and accessibility.

Product Cards

The core component for displaying products. Features responsive design, touch-optimized interactions, and real-time stock status.

Fresh Basil Bunches
New Organic
Sunny Field Gardens Sunny Field Gardens 7.3 mi

Fresh Basil Bunches

Aromatic fresh basil, perfect for pesto or caprese

$3.50 /bunch
In Stock
Rainbow Chard
Organic
Happy Acres Farm Happy Acres Farm 7.6 mi

Rainbow Chard

Colorful and nutritious chard, great for sautΓ©ing

$3.99 /bunch
Only 4 left!
Local Honey
Organic
Morning Dew Farm Morning Dew Farm 0.6 mi

Local Honey

Raw, unfiltered honey from local wildflowers

$12.00 /jar
Out of Stock

Enhanced ProductCard with Edit Mode

The enhanced ProductCard supports an edit mode for growers and market managers, allowing in-place editing of product information directly from the market page.

πŸ‘οΈ Customer View
πŸš— 12 miles New 🌱 Organic
Fresh Basil Bunches
Happy Acres Farm Happy Acres Farm

Fresh Basil Bunches

$3.50 /bunch 🌱 Harvested to order
Aromatic fresh basil, perfect for pesto or caprese
Available for Pre-order

Edit Mode Features

πŸ› οΈ Management Controls

  • Edit - Opens full product modal
  • Duplicate - Creates a copy
  • Toggle availability/featured
  • Delete (admin only)
  • Shows product copy code

✏️ In-place Editing

  • Click product name to edit
  • Click price/unit to edit
  • Edit quantity (if allowed)
  • Edit surcharge (admin)
  • Auto-saves with debounce

πŸ“ Rich Features

  • Expandable descriptions
  • Markdown support
  • Nutritional info links
  • Inactive product styling
  • Touch-optimized controls

Key Features

πŸ“±

Mobile First

48px minimum touch targets and optimized for small screens

⚑

Performance

GPU-accelerated animations and lazy-loaded images

β™Ώ

Accessible

WCAG AAA compliant with full keyboard and screen reader support

🎨

Themeable

CSS custom properties for easy market customization

πŸ”„

Real-time

Live stock updates and reactive state management

🌐

Responsive

Adapts seamlessly from mobile to desktop layouts

Usage Example

// Import the component
import ProductCard from '$lib/components/market/ProductCard.svelte';

// Example product data
const product = {
  id: 1,
  name: 'Organic Tomatoes',
  price: 4.99,
  unit: 'lb',
  quantity: 25,
  growerId: 1,
  categoryId: 15,
  // ... other properties
};

// Example grower data
const grower = {
  id: 1,
  name: 'Happy Acres Farm',
  location: 'Watkinsville, GA',
  growingMethod: 'organic',
  // ... other properties
};

// In your component template:
<ProductCard
  {product}
  {grower}
  featured={true}
  onAddToCart={(product) => addToCart(product)}
  onQuickView={(product) => showQuickView(product)}
/>

Props Documentation

PropTypeDefaultDescription
product *Productβ€”Product data object containing id, name, price, unit, quantity, etc.
grower *GrowerInfoβ€”Grower information including name, location, growingMethod, etc.
featured booleanfalseHighlights the product with a special badge and styling
distance numberβ€”Distance to the grower in miles (optional)
loading booleanfalseShows skeleton loading state
onAddToCart (product: Product) => voidβ€”Callback fired when add to cart button is clicked
onQuickView (product: Product) => voidβ€”Callback fired when quick view button is clicked

Component States

Featured Product

Out of Stock

Local Honey
Organic
Morning Dew Farm Morning Dew Farm

Local Honey

Raw, unfiltered honey from local wildflowers

$12.00 /jar
Out of Stock

Low Stock Warning

Rainbow Chard
Organic
Happy Acres Farm Happy Acres Farm

Rainbow Chard

Colorful and nutritious chard, great for sautΓ©ing

$3.99 /bunch
Only 3 left!

Loading State

Organic Heirloom Tomatoes
New Organic
Happy Acres Farm Happy Acres Farm

Organic Heirloom Tomatoes

Sweet and juicy heirloom tomatoes, perfect for salads or sandwiches

$4.99 /lb
In Stock

Category Tree Selector

Hierarchical category selector with multi-level navigation, search, and bulk selection. Supports keyboard navigation and screen readers for accessibility.

Category Tree Usage

// Import the component
import CategoryTreeSelector from '$lib/components/market/CategoryTreeSelector.svelte';

// Define your category data
let selectedCategories = [];
const categories = [
  { id: 1, parentId: null, name: 'Produce', productCount: 45 },
  { id: 11, parentId: 1, name: 'Vegetables', productCount: 22 },
  { id: 111, parentId: 11, name: 'Root Vegetables', productCount: 7 },
  // ... more categories
];

// Handle category selection changes
function handleCategoryChange(ids) {
  // Update your state or filter products
}

// In your component template:
<CategoryTreeSelector
  {categories}
  bind:selectedCategories
  mode="multiple"
  searchable={true}
  expandedByDefault={false}
  onCategoryChange={handleCategoryChange}
/>

CategoryTreeSelector Props

PropTypeDefaultDescription
categories *Category[]β€”Array of category objects with hierarchical structure (id, name, parentId, etc.)
selectedCategories number[][]Array of selected category IDs (bindable with bind:selectedCategories)
mode 'single' | 'multiple' | 'navigation''multiple'Selection mode: single selection, multiple selection, or navigation only
loading booleanfalseShows loading skeleton state
onCategoryChange (ids: number[]) => voidβ€”Callback fired when selection changes
onCategoryNavigate (id: number) => voidβ€”Callback fired in navigation mode when a category is clicked
expandedByDefault booleanfalseStart with all nodes expanded
showProductCounts booleantrueDisplay product counts for each category
searchable booleantrueEnable search functionality with highlighting
compactMode booleanfalseReduced spacing for dense layouts

Events & Callbacks

onCategoryChange

Fired when category selection changes. Receives array of selected category IDs.

onCategoryChange={(ids) => {
  // Update your state or filter products
}}

onCategoryNavigate

Fired in navigation mode when a category is clicked. Receives the category ID.

onCategoryNavigate={(id) => {
  // Navigate to category page
  goto(`/market/category/${id}`);
}}