6
Storefront
360 rowsA shop page that's really a LiveTable: the cards, sidebar and empty state are all yours.
Pick a category or two, then sort by price.
Nothing matches those filters.
# In your LiveView
def fields do
[
name: %{label: "Name", searchable: true},
category: %{label: "Category", searchable: true},
price: %{label: "Price", sortable: true},
rating: %{label: "Rating", sortable: true},
reviews: %{label: "Reviews", sortable: true},
image: %{label: "Image", hidden: true},
in_stock: %{label: "In stock", hidden: true},
is_new: %{label: "New", hidden: true}
]
end
def filters do
[
category: Select.new(:category, "category", %{label: "Category", options: []}),
price:
Range.new(:price, "price", %{
label: "Price",
unit: "₹",
min: 0,
max: 150_000,
step: 1
}),
in_stock:
Boolean.new(:in_stock, "in_stock", %{
label: "In stock",
condition: dynamic([p], p.in_stock)
}),
top_rated:
Boolean.new(:rating, "top_rated", %{
label: "4.5 and up",
condition: dynamic([p], p.rating >= 4.5)
}),
new:
Boolean.new(:is_new, "new", %{label: "New arrivals", condition: dynamic([p], p.is_new)})
]
end
def table_options do
%{
mode: :card,
card_component: &product/1,
custom_controls: {__MODULE__, :sidebar},
empty_state: ¬hing_found/1,
pagination: %{sizes: [12], default_size: 12},
sorting: %{default_sort: [reviews: :desc]},
exports: %{enabled: false}
}
end