JSFiddle - React, Tailwind, and code Playground

by bendikb88

HTML

<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<div id="root"></div>

CSS

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f5f7fb;
  color: #122029;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.header-left h1 {
  margin: 0 0 4px;
  font-size: 24px;
  color: #193750;
}

.header-left p {
  margin: 0;
  color: #64748b;
  font-size: 14px;
}

.header-right {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #64748b;
}

select,
input[type="date"] {
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 6px 10px;
  font-size: 14px;
  outline: none;
  background: #ffffff;
}

select:focus,
input[type="date"]:focus {
  border-color: #193750;
  box-shadow: 0 0 0 1px rgba(25, 55, 80, 0.2);
}

.date-range {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.multiselect {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  padding: 4px 10px;
  font-size: 12px;
  background: #ffffff;
  cursor: pointer;
}

.chip-selected {
  background: #193750;
  color: white;
  border-color: #193750;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

.kpi-card {
  display: flex;
  flex-direction: column;
 ...

Babel + JSX

const { useState, useMemo, useEffect, useRef } = React;

/** ---------- KONSTANTER & MOCK DATA ---------- */

const WEEKDAYS = [
  { id: "mon", label: "Man" },
  { id: "tue", label: "Tir" },
  { id: "wed", label: "Ons" },
  { id: "thu", label: "Tor" },
  { id: "fri", label: "Fre" },
  { id: "sat", label: "Lør" },
  { id: "sun", label: "Søn" },
];

const MOCK_DEPARTMENTS = [
  {
    id: "bakery",
    name: "Bakeri",
    revenue: 350000,
    transactions: 2800,
    avgSale: 125,
    changePct: 8.5,
  },
  {
    id: "cafe",
    name: "Kafé",
    revenue: 210000,
    transactions: 1700,
    avgSale: 123,
    changePct: -3.2,
  },
  {
    id: "restaurant",
    name: "Restaurant",
    revenue: 500000,
    transactions: 1900,
    avgSale: 263,
    changePct: 12.1,
  },
];

const MOCK_PRODUCTS = [
  { id: "1", name: "Surdeigsbrød", quantity: 1200, revenue: 78000, changePct: 6.3 },
  { id: "2", name: "Cappuccino", quantity: 980, revenue: 49000, changePct: -1.8 },
  { id: "3", name: "Croissant", quantity: 860, revenue: 43000, changePct: 4.1 },
  { id: "4", name: "Latte", quantity: 820, revenue: 41000, changePct: 2.4 },
  { id: "5", name: "Baguette", quantity: 790, revenue: 36000, changePct: 5.7 },
  { id: "6", name: "Pizza slice", quantity: 650, revenue: 52000, changePct: 9.9 },
  { id: "7", name: "Focaccia", quantity: 540, revenue: 33000, changePct: -4.5 },
  { id: "8", name: "Kanelbolle", quantity: 520, revenue: 26000, changePct: 1.1 },
  { id: "9", name: "Espresso", quantity: 480, revenue: 24000, changePct: 3.6 },
  { id: "10", name: "Muffins", quantity: 450, revenue: 22500, changePct: -2.7 },
];

const MOCK_EMPLOYEES = [
  {
    id: "e1",
    name: "Anna",
    departmentId: "bakery",
    revenue: 120000,
    transactions: 900,
    avgSale: 133,
    changePct: 5.2,
  },
  {
    id: "e2",
    name: "Ola",
    departmentId: "bakery",
    revenue: 95000,
    transactions: 780,
    avgSale: 122,
   ...