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 4.9 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.8 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 5.7 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
15 expected (harvest estimate)

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
  • Grower's Notes links
  • Inactive product styling
  • Touch-optimized controls
๐Ÿ”ฌ Feature Planning Phase

Product Varieties (Proposed Feature)

This is a planning phase mockup of the proposed Product Varieties feature. The design allows products to have multiple variations (sizes, colors, or units) managed as a single product with selectable options.

Why Product Varieties?

โœจ

Better UX

Customers see one product with options instead of cluttered listings

โšก

Easier Management

Growers manage 1 product with varieties instead of 5 separate products

๐Ÿ“ฆ

Shared Resources

One description, one image, one category for all size/color variations

๐Ÿ’ฐ

Flexible Pricing

Each variety can have its own price, unit, and inventory

Customer View - Interactive Examples

Try selecting different varieties and adjusting quantities. Each variety has its own price, unit, and stock level.

Low-Variety Products (โ‰ค5 varieties) - Dropdown Selector

For products with a few varieties, customers use a simple dropdown to select their option.

Farm Fresh Eggs

Farm Fresh Eggs

Sunny Field Gardens 12.0 mi

Free-range eggs from happy chickens, available by the half dozen or dozen

From $3.50 - $6.00
Price: $3.50/half dozen
Stock: In Stock
Bell Peppers

Bell Peppers

Green Thumb Produce 5.8 mi

Crisp bell peppers in assorted colors

From $1.50 - $2.25
Price: $1.50/each
Stock: In Stock

High-Variety Products (6+ varieties) - Button Grid Layout

For products with many varieties, the system automatically switches to a grouped button layout for better usability. This example shows reusable shopping bags with 9 varieties (3 sizes ร— 3 colors). Try selecting different combinations - sold out options are automatically disabled.

Reusable Shopping Bags

Reusable Shopping Bags

Sunny Field Gardens 4.2 mi

Eco-friendly reusable shopping bags in various sizes and colors

From $8.00 - $16.00
Size:
Color:
Selected: Small / Black
Price: $8.00/bag
Stock: 12 available

Grower Edit Mode - Variety Management

Growers have two ways to manage varieties: quick edits on the product card, or full editing in the product modal.

Option 1: Product Card Quick Edit

For products with varieties, the product card in edit mode shows a summary with a link to manage varieties in the modal.

Tomatoes
โœ๏ธ Edit Mode
๐ŸŽฏ 3 Varieties
Small โš ๏ธ Low $3.99/lb โ€ข 3 in stock
Medium $4.49/lb โ€ข 20 in stock
Large (Inactive) $4.99/lb โ€ข 10 in stock
Total Stock: 45

Option 2: Product Modal - Full Variety Editor

Clicking "Manage Varieties" opens the modal where growers can add, remove, reorder, and edit all variety details.

โœ๏ธ Edit Product: Heirloom Tomatoes
Varieties
Active
Order
Name
Unit
Price
Stock
โ‹ฎโ‹ฎ
โ‹ฎโ‹ฎ
โ‹ฎโ‹ฎ

Option 3: Grower Editor - Variety Grouping

Growers can set up variety groups (like "Size" and "Color") to automatically generate the button grid layout. The system detects the pattern from variety names.

โœ๏ธ Edit Product: Reusable Shopping Bags
Variety Groups (Optional)

๐Ÿ’ก Group varieties by attributes like size, color, or flavor. The system will automatically create a button grid for customers when 6+ varieties are detected.

Small Medium Large
Black Green Blue
Varieties (9 total)
๐Ÿ’ก Name varieties as "GroupValue / GroupValue" (e.g., "Small / Black") to auto-detect groups
Small / Black $8.00 12 in stock
Small / Green $8.00 8 in stock
Small / Blue $8.00 Sold Out
Medium / Black $12.00 10 in stock
Medium / Green $12.00 6 in stock
Medium / Blue $12.00 4 in stock
Large / Black $16.00 5 in stock
Large / Green $16.00 โš ๏ธ 3 left
Large / Blue $16.00 Sold Out

Design Decisions & Patterns

๐ŸŽฏ Variety Selector

  • Touch-friendly dropdown (48px minimum height)
  • Shows price and unit for each option
  • Indicates stock status (sold out, low stock)
  • Disabled options are grayed out

๐Ÿ’ก Selected Variety Details

  • Highlights current price and stock
  • Clear visual feedback on selection
  • Color-coded stock indicators
  • Updates cart controls dynamically

๐Ÿ“Š Stock Management

  • Each variety tracks its own inventory
  • Product quantity is sum of all varieties
  • Low stock warnings per variety
  • Prevents ordering out-of-stock varieties

โœ๏ธ Grower Edit Modes

  • Card Edit: Quick name/description edits + varieties summary
  • Modal Edit: Full variety management (add/remove/reorder)
  • "Manage Varieties" button opens modal from card
  • Shows total stock across all varieties

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}`);
}}