Calendar/wwwroot/poc-checkout.html
Janus C. H. Knudsen e0419f1f61 Adds proof-of-concept checkout page prototype
Creates an interactive HTML-based checkout overlay with dynamic cart functionality

Implements features:
- Product catalog with search capability
- Add/remove cart items
- Total price calculation
- Responsive design with modern UI components
2025-12-18 15:30:53 +01:00

635 lines
18 KiB
HTML

<!DOCTYPE html>
<html lang="da">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Checkout POC</title>
<style>
/* Design tokens fra calendar-base.css */
:root {
/* Colors - UI */
--color-border: #e0e0e0;
--color-surface: #fff;
--color-background: #f5f5f5;
--color-background-hover: #f0f0f0;
--color-background-alt: #fafafa;
--color-text: #333333;
--color-text-secondary: #666;
--color-primary: #1976d2;
/* Named color palette */
--b-color-blue: #1e88e5;
--b-color-green: #43a047;
--b-color-red: #e53935;
--b-color-amber: #ffb300;
--b-color-purple: #8e24aa;
--b-color-teal: #00897b;
--b-mix: #fff;
/* Shadows */
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
/* Transitions */
--transition-fast: 150ms ease;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: var(--color-background);
}
/* Demo layout */
.demo-container {
padding: 16px;
}
.demo-btn {
padding: 8px 16px;
border: 1px solid var(--color-border);
border-radius: 4px;
cursor: pointer;
background: var(--color-primary);
color: white;
font-size: 14px;
font-weight: 500;
transition: background var(--transition-fast);
}
.demo-btn:hover {
background: #1565c0;
}
/* ==========================================
CHECKOUT OVERLAY
========================================== */
swp-checkout-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.3);
opacity: 0;
visibility: hidden;
transition: opacity 200ms ease, visibility 200ms ease;
z-index: 1000;
}
swp-checkout-overlay.open {
opacity: 1;
visibility: visible;
}
swp-checkout-panel {
position: fixed;
top: 0;
right: 0;
bottom: 0;
width: 800px;
max-width: 100%;
background: var(--color-surface);
border-left: 1px solid var(--color-border);
box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
transform: translateX(100%);
transition: transform 200ms ease;
display: flex;
flex-direction: column;
z-index: 1001;
}
swp-checkout-panel.open {
transform: translateX(0);
}
/* Header */
swp-checkout-header {
display: flex;
align-items: center;
gap: 16px;
padding: 16px 20px;
border-bottom: 1px solid var(--color-border);
background: var(--color-background-alt);
}
swp-customer-name {
font-size: 18px;
font-weight: 600;
color: var(--color-text);
}
swp-header-separator {
width: 1px;
height: 20px;
background: var(--color-border);
}
swp-checkout-date {
font-size: 14px;
color: var(--color-text-secondary);
}
swp-checkout-resource {
font-size: 14px;
color: var(--color-text-secondary);
}
swp-close-btn {
margin-left: auto;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border: none;
background: none;
cursor: pointer;
border-radius: 4px;
font-size: 18px;
color: var(--color-text-secondary);
transition: background var(--transition-fast);
}
swp-close-btn:hover {
background: var(--color-background-hover);
}
/* Main content - two columns */
swp-checkout-content {
flex: 1;
display: grid;
grid-template-columns: 280px 1fr;
overflow: hidden;
}
/* Left: Product catalog */
swp-product-catalog {
display: flex;
flex-direction: column;
border-right: 1px solid var(--color-border);
background: var(--color-background-alt);
}
swp-catalog-header {
padding: 12px;
border-bottom: 1px solid var(--color-border);
}
swp-search-input {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
background: var(--color-surface);
border: 1px solid var(--color-border);
border-radius: 4px;
}
swp-search-input input {
flex: 1;
border: none;
outline: none;
font-size: 14px;
background: transparent;
}
swp-search-input input::placeholder {
color: var(--color-text-secondary);
}
swp-catalog-list {
flex: 1;
overflow-y: auto;
padding: 12px;
display: flex;
flex-direction: column;
gap: 8px;
}
swp-product-card {
display: block;
padding: 12px;
background: var(--color-surface);
border: 1px solid var(--color-border);
border-radius: 4px;
cursor: pointer;
transition: all var(--transition-fast);
}
swp-product-card:hover {
border-color: var(--color-primary);
box-shadow: var(--shadow-sm);
}
swp-product-name {
display: block;
font-size: 14px;
font-weight: 500;
color: var(--color-text);
margin-bottom: 4px;
}
swp-product-meta {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
color: var(--color-text-secondary);
}
swp-product-price {
font-weight: 500;
color: var(--color-text);
}
swp-product-duration {
opacity: 0.8;
}
/* Right: Cart */
swp-cart-section {
display: flex;
flex-direction: column;
background: var(--color-surface);
}
swp-cart-header {
padding: 12px 16px;
border-bottom: 1px solid var(--color-border);
font-size: 13px;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--color-text-secondary);
}
swp-cart-list {
flex: 1;
overflow-y: auto;
padding: 16px;
display: flex;
flex-direction: column;
gap: 12px;
}
swp-cart-item {
--b-primary: var(--b-color-blue);
display: flex;
align-items: flex-start;
gap: 12px;
padding: 12px;
background: color-mix(in srgb, var(--b-primary) 5%, var(--b-mix));
border-left: 3px solid var(--b-primary);
border-radius: 4px;
}
swp-cart-item-content {
flex: 1;
}
swp-cart-item-name {
display: block;
font-size: 15px;
font-weight: 500;
color: var(--color-text);
margin-bottom: 4px;
}
swp-cart-item-meta {
display: flex;
align-items: center;
gap: 6px;
font-size: 13px;
color: var(--color-text-secondary);
}
swp-cart-item-resource {
font-weight: 500;
}
swp-cart-item-price {
font-size: 15px;
font-weight: 600;
color: var(--color-text);
white-space: nowrap;
}
swp-cart-item-remove {
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
border: none;
background: none;
cursor: pointer;
border-radius: 4px;
font-size: 14px;
color: var(--color-text-secondary);
opacity: 0.6;
transition: all var(--transition-fast);
}
swp-cart-item-remove:hover {
opacity: 1;
background: color-mix(in srgb, var(--b-color-red) 15%, var(--b-mix));
color: var(--b-color-red);
}
/* Cart total */
swp-cart-total {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px;
margin: 0 16px 16px;
background: var(--color-text);
color: var(--color-surface);
border-radius: 4px;
}
swp-total-label {
font-size: 14px;
opacity: 0.7;
}
swp-total-amount {
font-size: 22px;
font-weight: 600;
}
/* Footer */
swp-checkout-footer {
display: flex;
gap: 12px;
padding: 16px 20px;
border-top: 1px solid var(--color-border);
background: var(--color-surface);
}
swp-footer-btn {
flex: 1;
padding: 14px 20px;
border: 1px solid var(--color-border);
border-radius: 4px;
font-size: 15px;
font-weight: 500;
font-family: inherit;
cursor: pointer;
transition: all var(--transition-fast);
}
swp-footer-btn.btn-secondary {
background: var(--color-surface);
color: var(--color-text);
}
swp-footer-btn.btn-secondary:hover {
background: var(--color-background-hover);
}
swp-footer-btn.btn-primary {
background: var(--b-color-green);
color: white;
border-color: var(--b-color-green);
}
swp-footer-btn.btn-primary:hover {
background: #388e3c;
}
/* Empty cart state */
swp-cart-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
padding: 40px;
color: var(--color-text-secondary);
text-align: center;
}
swp-cart-empty-icon {
font-size: 48px;
margin-bottom: 12px;
opacity: 0.5;
}
swp-cart-empty-text {
font-size: 14px;
}
</style>
</head>
<body>
<div class="demo-container">
<p style="font-size: 14px; color: var(--color-text-secondary); margin-bottom: 12px;">
Klik for at åbne checkout overlay
</p>
<button class="demo-btn" onclick="openCheckout()">Gå til betaling</button>
</div>
<!-- Overlay -->
<swp-checkout-overlay id="checkoutOverlay" onclick="closeCheckout()"></swp-checkout-overlay>
<!-- Checkout Panel -->
<swp-checkout-panel id="checkoutPanel" onclick="event.stopPropagation()">
<swp-checkout-header>
<swp-customer-name>Sofie Nielsen</swp-customer-name>
<swp-header-separator></swp-header-separator>
<swp-checkout-date>9. dec 2025</swp-checkout-date>
<swp-header-separator></swp-header-separator>
<swp-checkout-resource>Emma</swp-checkout-resource>
<swp-close-btn onclick="closeCheckout()"></swp-close-btn>
</swp-checkout-header>
<swp-checkout-content>
<!-- Product Catalog -->
<swp-product-catalog>
<swp-catalog-header>
<swp-search-input>
<span>🔍</span>
<input type="text" placeholder="Søg produkt eller service..." id="searchInput" oninput="filterProducts()">
</swp-search-input>
</swp-catalog-header>
<swp-catalog-list id="catalogList">
<swp-product-card onclick="addToCart('klipning', 'Klipning og styling', 500, '60 min')">
<swp-product-name>Klipning og styling</swp-product-name>
<swp-product-meta>
<swp-product-price>500 DKK</swp-product-price>
<swp-product-duration>60 min</swp-product-duration>
</swp-product-meta>
</swp-product-card>
<swp-product-card onclick="addToCart('bundfarve', 'Bundfarve', 800, '90 min')">
<swp-product-name>Bundfarve</swp-product-name>
<swp-product-meta>
<swp-product-price>800 DKK</swp-product-price>
<swp-product-duration>90 min</swp-product-duration>
</swp-product-meta>
</swp-product-card>
<swp-product-card onclick="addToCart('olaplex', 'Olaplex behandling', 350, '30 min')">
<swp-product-name>Olaplex behandling</swp-product-name>
<swp-product-meta>
<swp-product-price>350 DKK</swp-product-price>
<swp-product-duration>30 min</swp-product-duration>
</swp-product-meta>
</swp-product-card>
<swp-product-card onclick="addToCart('highlights', 'Highlights', 1200, '120 min')">
<swp-product-name>Highlights</swp-product-name>
<swp-product-meta>
<swp-product-price>1.200 DKK</swp-product-price>
<swp-product-duration>120 min</swp-product-duration>
</swp-product-meta>
</swp-product-card>
<swp-product-card onclick="addToCart('vask', 'Vask og føn', 150, '20 min')">
<swp-product-name>Vask og føn</swp-product-name>
<swp-product-meta>
<swp-product-price>150 DKK</swp-product-price>
<swp-product-duration>20 min</swp-product-duration>
</swp-product-meta>
</swp-product-card>
<swp-product-card onclick="addToCart('shampoo', 'Olaplex Shampoo', 299)">
<swp-product-name>Olaplex Shampoo</swp-product-name>
<swp-product-meta>
<swp-product-price>299 DKK</swp-product-price>
</swp-product-meta>
</swp-product-card>
<swp-product-card onclick="addToCart('conditioner', 'Olaplex Conditioner', 319)">
<swp-product-name>Olaplex Conditioner</swp-product-name>
<swp-product-meta>
<swp-product-price>319 DKK</swp-product-price>
</swp-product-meta>
</swp-product-card>
<swp-product-card onclick="addToCart('hairoil', 'Hair Oil Treatment', 199)">
<swp-product-name>Hair Oil Treatment</swp-product-name>
<swp-product-meta>
<swp-product-price>199 DKK</swp-product-price>
</swp-product-meta>
</swp-product-card>
</swp-catalog-list>
</swp-product-catalog>
<!-- Cart -->
<swp-cart-section>
<swp-cart-header>Kurv</swp-cart-header>
<swp-cart-list id="cartList">
<!-- Pre-filled from booking -->
<swp-cart-item data-id="klipning">
<swp-cart-item-content>
<swp-cart-item-name>Klipning og styling</swp-cart-item-name>
<swp-cart-item-meta>
<swp-cart-item-resource>Emma</swp-cart-item-resource>
<span>·</span>
<span>60 min</span>
</swp-cart-item-meta>
</swp-cart-item-content>
<swp-cart-item-price>500 DKK</swp-cart-item-price>
<swp-cart-item-remove onclick="removeFromCart('klipning')"></swp-cart-item-remove>
</swp-cart-item>
<swp-cart-item data-id="bundfarve">
<swp-cart-item-content>
<swp-cart-item-name>Bundfarve</swp-cart-item-name>
<swp-cart-item-meta>
<swp-cart-item-resource>Emma</swp-cart-item-resource>
<span>·</span>
<span>90 min</span>
</swp-cart-item-meta>
</swp-cart-item-content>
<swp-cart-item-price>800 DKK</swp-cart-item-price>
<swp-cart-item-remove onclick="removeFromCart('bundfarve')"></swp-cart-item-remove>
</swp-cart-item>
</swp-cart-list>
<swp-cart-total>
<swp-total-label>Total</swp-total-label>
<swp-total-amount id="totalAmount">1.300 DKK</swp-total-amount>
</swp-cart-total>
</swp-cart-section>
</swp-checkout-content>
<swp-checkout-footer>
<swp-footer-btn class="btn-secondary" onclick="closeCheckout()">Annuller</swp-footer-btn>
<swp-footer-btn class="btn-primary" onclick="registerPayment()">Registrer betaling</swp-footer-btn>
</swp-checkout-footer>
</swp-checkout-panel>
<script>
// Cart state
let cart = [
{ id: 'klipning', name: 'Klipning og styling', price: 500, duration: '60 min', resource: 'Emma' },
{ id: 'bundfarve', name: 'Bundfarve', price: 800, duration: '90 min', resource: 'Emma' }
];
function openCheckout() {
document.getElementById('checkoutOverlay').classList.add('open');
document.getElementById('checkoutPanel').classList.add('open');
}
function closeCheckout() {
document.getElementById('checkoutOverlay').classList.remove('open');
document.getElementById('checkoutPanel').classList.remove('open');
}
function addToCart(id, name, price, duration) {
if (cart.find(item => item.id === id)) return; // Already in cart
cart.push({ id, name, price, duration, resource: 'Emma' });
renderCart();
}
function removeFromCart(id) {
cart = cart.filter(item => item.id !== id);
renderCart();
}
function renderCart() {
const cartList = document.getElementById('cartList');
if (cart.length === 0) {
cartList.innerHTML = `
<swp-cart-empty>
<swp-cart-empty-icon>🛒</swp-cart-empty-icon>
<swp-cart-empty-text>Kurven er tom</swp-cart-empty-text>
</swp-cart-empty>
`;
} else {
cartList.innerHTML = cart.map(item => `
<swp-cart-item data-id="${item.id}">
<swp-cart-item-content>
<swp-cart-item-name>${item.name}</swp-cart-item-name>
<swp-cart-item-meta>
<swp-cart-item-resource>${item.resource}</swp-cart-item-resource>
${item.duration ? `<span>·</span><span>${item.duration}</span>` : ''}
</swp-cart-item-meta>
</swp-cart-item-content>
<swp-cart-item-price>${item.price.toLocaleString('da-DK')} DKK</swp-cart-item-price>
<swp-cart-item-remove onclick="removeFromCart('${item.id}')">✕</swp-cart-item-remove>
</swp-cart-item>
`).join('');
}
// Update total
const total = cart.reduce((sum, item) => sum + item.price, 0);
document.getElementById('totalAmount').textContent = total.toLocaleString('da-DK') + ' DKK';
}
function filterProducts() {
const query = document.getElementById('searchInput').value.toLowerCase();
const cards = document.querySelectorAll('swp-product-card');
cards.forEach(card => {
const name = card.querySelector('swp-product-name').textContent.toLowerCase();
card.style.display = name.includes(query) ? 'block' : 'none';
});
}
function registerPayment() {
alert('Betaling registreret!');
closeCheckout();
}
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') closeCheckout();
});
</script>
</body>
</html>