@inherits LayoutComponentBase @inject NavigationManager Navigation
@* --- CART SYSTEM SIDE PANEL BACKDROP LAYER --- *@
YOUR CART (@CartItems.Sum(i => i.Quantity))
@if (!CartItems.Any()) {
Your collection is empty.
} else {
@foreach (var item in CartItems) {
[ COVER ]
@item.Title

by @item.Author

@item.Quantity
R @(item.Price * item.Quantity)
}
}
@if (CartItems.Any()) { }
@* --- TOP FIXED LAYOUT AREA --- *@
@* Decorative Background SVG Watermark Line Graphic *@
@* --- MAIN INDEPENDENT SCROLL LAYER --- *@
@Body
@code { private string GlobalSearchQuery { get; set; } = string.Empty; private bool IsSearchActive { get; set; } = false; private bool IsCartOpen { get; set; } = false; private List CartItems = new() { new CartItem { Id = 1, Title = "Letters from M/M (Paris)", Author = "M/M Paris", Price = 720, Quantity = 1 }, new CartItem { Id = 2, Title = "Daan Paans: Floating Signifiers", Author = "Daan Paans", Price = 540, Quantity = 1 }, new CartItem { Id = 3, Title = "Album Architectures, Maputo", Author = "Guedes Archive", Price = 350, Quantity = 1 } }; private void ToggleGlobalSearch() => IsSearchActive = !IsSearchActive; private void ToggleCart() => IsCartOpen = !IsCartOpen; private void OnSearchInput(ChangeEventArgs e) { GlobalSearchQuery = e.Value?.ToString() ?? string.Empty; } private void ChangeQuantity(CartItem item, int delta) { item.Quantity += delta; if (item.Quantity <= 0) { CartItems.Remove(item); } } private void RemoveFromCart(CartItem item) => CartItems.Remove(item); private int GetCartTotal() => CartItems.Sum(item => item.Price * item.Quantity); private void RedirectToCart() { IsCartOpen = false; Navigation.NavigateTo("/cart"); } private void RedirectToCheckout() { IsCartOpen = false; Navigation.NavigateTo("/checkout"); } public class CartItem { public int Id { get; set; } public string Title { get; set; } = string.Empty; public string Author { get; set; } = string.Empty; public int Price { get; set; } public int Quantity { get; set; } } }