Trace, Code Block and AI Elements
Building Blocks for the Web
Clean, modern building blocks. Copy and paste into your apps. Works with any WebJs app. Open Source. Free forever.
Files
-
app
-
dashboard
-
-
components
app/dashboard/page.ts
/**
* The dashboard-01 block's page: an inset sidebar beside a header, four
* metric cards, an interactive area chart and a data table.
*
* Installed by `npx @webjsdev/ui add dashboard-01` at `app/dashboard/page.ts`.
* It is app code you own, so edit it freely: replace `dashboardData` with
* rows from your own query. Ported from shadcn/ui's dashboard-01.
*/
import { html } from '@webjsdev/core';
import type { Metadata } from '@webjsdev/core';
import '../../components/ui/sidebar.ts';
import { appSidebar } from '../../components/app-sidebar.ts';
import { chartAreaInteractive } from '../../components/chart-area-interactive.ts';
import { dashboardData } from '../../components/dashboard-data.ts';
import { dataTable } from '../../components/data-table.ts';
import { sectionCards } from '../../components/section-cards.ts';
import { siteHeader } from '../../components/site-header.ts';
export const metadata: Metadata = { title: 'Dashboard' };
export default function DashboardPage() {
return html`
<ui-sidebar-provider class="[--header-height:calc(var(--spacing)*12)]">
${appSidebar({ variant: 'inset' })}
<ui-sidebar-inset>
${siteHeader()}
<div class="flex flex-1 flex-col">
<div class="@container/main flex flex-1 flex-col gap-2">
<div class="flex flex-col gap-4 py-4 md:gap-6 md:py-6">
${sectionCards()}
<div class="px-4 lg:px-6">${chartAreaInteractive()}</div>
${dataTable({ data: dashboardData })}
</div>
</div>
</div>
</ui-sidebar-inset>
</ui-sidebar-provider>
`;
}
components/app-sidebar.ts
/**
* The dashboard-01 app sidebar: the brand, the main nav with "Quick Create",
* the documents list, the secondary links pinned to the bottom, and the
* signed-in user, in an inset sidebar that slides off canvas (Ctrl+B or
* Cmd+B, or the header's trigger). A fragment helper, so the markup is
* rendered by the server; the sidebar and the menus are the kit's elements.
* Ported from shadcn/ui's dashboard-01.
*
* The data below is sample data. Replace it with your own, and point each
* `url` at a real route. The options shape the shell for other layouts:
* `collapsible` (`'offcanvas'` by default, `'none'` for a fixed column),
* `class` and `headerClass` added to the sidebar and its header, `logo` in
* place of the brand icon, `mainLabel` / `quickCreate` passed to the main
* nav, and `data` to replace any of the sample lists.
*/
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import {
sidebarContentClass,
sidebarFooterClass,
sidebarHeaderClass,
sidebarMenuButtonClass,
sidebarMenuClass,
sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { navDocuments, type NavDocument } from './nav-documents.ts';
import { navMain, type NavMainItem } from './nav-main.ts';
import { navSecondary, type NavSecondaryItem } from './nav-secondary.ts';
import { navUser } from './nav-user.ts';
import { ChartBarIcon, CircleHelpIcon, CommandIcon, DatabaseIcon, FileChartColumnIcon, FileIcon, FolderIcon, LayoutDashboardIcon, ListIcon, SearchIcon, Settings2Icon, UsersIcon } from '../lib/utils/icons.ts';
export interface AppSidebarData {
user: { name: string; email: string; avatar: string };
navMain: NavMainItem[];
navSecondary: NavSecondaryItem[];
documents: NavDocument[];
}
export interface AppSidebarOptions {
variant?: 'sidebar' | 'floating' | 'inset';
collapsible?: 'offcanvas' | 'icon' | 'none';
class?: string;
headerClass?: string;
logo?: TemplateResult;
mainLabel?: string;
quickCreate?: boolean;
data?: Partial<AppSidebarData>;
}
// This is sample data.
const data: AppSidebarData = {
user: {
name: 'vivek',
email: '[email protected]',
avatar: 'https://webjs.dev/avatars/vivek.jpg',
},
navMain: [
{ title: 'Dashboard', url: '#', icon: LayoutDashboardIcon },
{ title: 'Lifecycle', url: '#', icon: ListIcon },
{ title: 'Analytics', url: '#', icon: ChartBarIcon },
{ title: 'Projects', url: '#', icon: FolderIcon },
{ title: 'Team', url: '#', icon: UsersIcon },
],
navSecondary: [
{ title: 'Settings', url: '#', icon: Settings2Icon },
{ title: 'Get Help', url: '#', icon: CircleHelpIcon },
{ title: 'Search', url: '#', icon: SearchIcon },
],
documents: [
{ name: 'Data Library', url: '#', icon: DatabaseIcon },
{ name: 'Reports', url: '#', icon: FileChartColumnIcon },
{ name: 'Word Assistant', url: '#', icon: FileIcon },
],
};
/**
* The sidebar. shadcn's page widens it to 18rem through the provider's
* `--sidebar-width`; the kit's provider sets its own on the wrapper it
* renders, so the width rides on the sidebar itself here. A `class` that sets
* its own `--sidebar-width` replaces this one, as shadcn's merge would.
*/
export function appSidebar(opts: AppSidebarOptions = {}) {
const d = { ...data, ...opts.data };
const width = opts.class?.includes('[--sidebar-width:') ? '' : '[--sidebar-width:calc(var(--spacing)*72)]';
return html`
<ui-sidebar collapsible=${opts.collapsible ?? 'offcanvas'} variant=${opts.variant ?? 'sidebar'} class=${cn(width, opts.class)}>
<div data-slot="sidebar-header" data-sidebar="header" class=${cn(sidebarHeaderClass(), opts.headerClass)}>
<ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
<li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
<a href="#" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${cn(sidebarMenuButtonClass(), 'data-[slot=sidebar-menu-button]:p-1.5!')}>
${opts.logo ?? CommandIcon('size-5!')}
<span class="text-base font-semibold">Acme Inc.</span>
</a>
</li>
</ul>
</div>
<div data-slot="sidebar-content" data-sidebar="content" class=${sidebarContentClass()}>
${navMain({ items: d.navMain, label: opts.mainLabel, quickCreate: opts.quickCreate })}
${navDocuments({ items: d.documents })}
${navSecondary({ items: d.navSecondary, class: 'mt-auto' })}
</div>
<div data-slot="sidebar-footer" data-sidebar="footer" class=${sidebarFooterClass()}>
${navUser({ user: d.user })}
</div>
</ui-sidebar>
`;
}
components/nav-main.ts
/**
* The dashboard-01 main nav: the "Quick Create" button beside an inbox
* button, then one link per section. A fragment helper. Ported from
* shadcn/ui's dashboard-01.
*
* "Quick Create" and the inbox button are placeholders: point them at your
* own create flow and inbox route. `quickCreate: false` drops that row and
* `label` titles the group (shadcn's examples/dashboard has a "Home" group with
* no Quick Create row).
*/
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { buttonClass } from './ui/button.ts';
import {
sidebarGroupClass,
sidebarGroupContentClass,
sidebarGroupLabelClass,
sidebarMenuButtonClass,
sidebarMenuClass,
sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { CirclePlusIcon, MailIcon } from '../lib/utils/icons.ts';
export interface NavMainItem {
title: string;
url: string;
icon?: (cls?: string) => TemplateResult;
}
export function navMain({ items, label, quickCreate = true }: { items: NavMainItem[]; label?: string; quickCreate?: boolean }) {
return html`
<div data-slot="sidebar-group" data-sidebar="group" class=${sidebarGroupClass()}>
<div data-slot="sidebar-group-content" data-sidebar="group-content" class=${cn(sidebarGroupContentClass(), 'flex flex-col gap-2')}>
${label ? html`<div data-slot="sidebar-group-label" data-sidebar="group-label" class=${sidebarGroupLabelClass()}>${label}</div>` : ''}
${quickCreate ? html`<ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
<li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${cn(sidebarMenuItemClass(), 'flex items-center gap-2')}>
<button type="button" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${cn(sidebarMenuButtonClass(), 'min-w-8 bg-primary text-primary-foreground duration-200 ease-linear hover:bg-primary/90 hover:text-primary-foreground active:bg-primary/90 active:text-primary-foreground')}>
${CirclePlusIcon()}
<span>Quick Create</span>
</button>
<button type="button" data-slot="button" data-variant="outline" data-size="icon" class=${cn(buttonClass({ variant: 'outline', size: 'icon' }), 'size-8 group-data-[collapsible=icon]:opacity-0')}>
${MailIcon()}
<span class="sr-only">Inbox</span>
</button>
</li>
</ul>` : ''}
<ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
${items.map((item) => html`
<li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
<a href=${item.url} data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${sidebarMenuButtonClass()}>
${item.icon ? item.icon() : ''}
<span>${item.title}</span>
</a>
</li>
`)}
</ul>
</div>
</div>
`;
}
components/nav-documents.ts
/**
* The dashboard-01 documents list: one link per document, each with a "More"
* menu that shows on hover, and a trailing "More" item. Hidden while the
* sidebar is collapsed to icons. A fragment helper; the menus are the kit's
* `<ui-dropdown-menu>`. Ported from shadcn/ui's dashboard-01.
*
* Each "More" button sits right after its link, a sibling of it, because the
* kit's styles place it with `peer-*` selectors that need exactly that. The
* menu names it through `trigger="<id>"`, so the ids must be unique on the page.
*/
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import './ui/dropdown-menu.ts';
import {
sidebarGroupClass,
sidebarGroupLabelClass,
sidebarMenuActionClass,
sidebarMenuButtonClass,
sidebarMenuClass,
sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { FolderIcon, MoreHorizontalIcon, ShareIcon, Trash2Icon } from '../lib/utils/icons.ts';
export interface NavDocument {
name: string;
url: string;
icon: (cls?: string) => TemplateResult;
}
export function navDocuments({ items }: { items: NavDocument[] }) {
return html`
<div data-slot="sidebar-group" data-sidebar="group" class=${cn(sidebarGroupClass(), 'group-data-[collapsible=icon]:hidden')}>
<div data-slot="sidebar-group-label" data-sidebar="group-label" class=${sidebarGroupLabelClass()}>Documents</div>
<ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
${items.map((item, i) => html`
<li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
<a href=${item.url} data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${sidebarMenuButtonClass()}>
${item.icon()}
<span>${item.name}</span>
</a>
<button type="button" id=${`nav-document-more-${i}`} data-slot="sidebar-menu-action" data-sidebar="menu-action" class=${cn(sidebarMenuActionClass({ showOnHover: true }), 'rounded-sm aria-expanded:bg-accent')}>
${MoreHorizontalIcon()}
<span class="sr-only">More</span>
</button>
<ui-dropdown-menu trigger=${`nav-document-more-${i}`}>
<ui-dropdown-menu-content class="w-24 rounded-lg" side="right" align="start">
<ui-dropdown-menu-item>${FolderIcon()}<span>Open</span></ui-dropdown-menu-item>
<ui-dropdown-menu-item>${ShareIcon()}<span>Share</span></ui-dropdown-menu-item>
<ui-dropdown-menu-separator></ui-dropdown-menu-separator>
<ui-dropdown-menu-item variant="destructive">${Trash2Icon()}<span>Delete</span></ui-dropdown-menu-item>
</ui-dropdown-menu-content>
</ui-dropdown-menu>
</li>
`)}
<li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
<button type="button" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${cn(sidebarMenuButtonClass(), 'text-sidebar-foreground/70')}>
${MoreHorizontalIcon('text-sidebar-foreground/70')}
<span>More</span>
</button>
</li>
</ul>
</div>
`;
}
components/nav-secondary.ts
/**
* The dashboard-01 secondary nav: settings, help and search, pinned to the
* bottom of the sidebar by the `class` the app sidebar passes (`mt-auto`).
* A fragment helper. Ported from shadcn/ui's dashboard-01.
*/
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import {
sidebarGroupClass,
sidebarGroupContentClass,
sidebarMenuButtonClass,
sidebarMenuClass,
sidebarMenuItemClass,
} from './ui/sidebar.ts';
export interface NavSecondaryItem {
title: string;
url: string;
icon: (cls?: string) => TemplateResult;
}
export function navSecondary({ items, class: cls }: { items: NavSecondaryItem[]; class?: string }) {
return html`
<div data-slot="sidebar-group" data-sidebar="group" class=${cn(sidebarGroupClass(), cls)}>
<div data-slot="sidebar-group-content" data-sidebar="group-content" class=${sidebarGroupContentClass()}>
<ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
${items.map((item) => html`
<li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
<a href=${item.url} data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${sidebarMenuButtonClass()}>
${item.icon()}
<span>${item.title}</span>
</a>
</li>
`)}
</ul>
</div>
</div>
`;
}
components/nav-user.ts
/**
* The dashboard-01 user menu: the signed-in user's avatar, name and email,
* opening an account menu. A fragment helper; the menu is the kit's
* `<ui-dropdown-menu>`. Ported from shadcn/ui's dashboard-01.
*
* The menu items are placeholders. Make "Log out" a form that posts to your
* sign-out action, and the others links to your account pages.
*/
import { html } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { avatarClass, avatarFallbackClass, avatarImageClass } from './ui/avatar.ts';
import './ui/dropdown-menu.ts';
import {
sidebarMenuButtonClass,
sidebarMenuClass,
sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { BellIcon, CircleUserRoundIcon, CreditCardIcon, EllipsisVerticalIcon, LogOutIcon } from '../lib/utils/icons.ts';
function userAvatar(user: { name: string; avatar: string }) {
return html`<span data-slot="avatar" data-size="default" class=${cn(avatarClass(), 'h-8 w-8 rounded-lg grayscale')}>
<span data-slot="avatar-fallback" class=${cn(avatarFallbackClass(), 'rounded-lg')}>VK</span>
<img data-slot="avatar-image" src=${user.avatar} alt="@vivek" class=${avatarImageClass()}>
</span>`;
}
function userText(user: { name: string; email: string }) {
return html`<div class="grid flex-1 text-left text-sm leading-tight">
<span class="truncate font-medium">${user.name}</span>
<span class="truncate text-xs text-muted-foreground">${user.email}</span>
</div>`;
}
export function navUser({ user }: { user: { name: string; email: string; avatar: string } }) {
return html`
<ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
<li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
<ui-dropdown-menu>
<ui-dropdown-menu-trigger>
<button type="button" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="lg" class=${cn(sidebarMenuButtonClass({ size: 'lg' }), 'aria-expanded:bg-sidebar-accent aria-expanded:text-sidebar-accent-foreground')}>
${userAvatar(user)}
${userText(user)}
${EllipsisVerticalIcon('ml-auto size-4')}
</button>
</ui-dropdown-menu-trigger>
<ui-dropdown-menu-content class="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg" side="right" align="end">
<ui-dropdown-menu-label class="p-0 font-normal">
<div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
${userAvatar(user)}
${userText(user)}
</div>
</ui-dropdown-menu-label>
<ui-dropdown-menu-separator></ui-dropdown-menu-separator>
<ui-dropdown-menu-group>
<ui-dropdown-menu-item>${CircleUserRoundIcon()}Account</ui-dropdown-menu-item>
<ui-dropdown-menu-item>${CreditCardIcon()}Billing</ui-dropdown-menu-item>
<ui-dropdown-menu-item>${BellIcon()}Notifications</ui-dropdown-menu-item>
</ui-dropdown-menu-group>
<ui-dropdown-menu-separator></ui-dropdown-menu-separator>
<ui-dropdown-menu-item>${LogOutIcon()}Log out</ui-dropdown-menu-item>
</ui-dropdown-menu-content>
</ui-dropdown-menu>
</li>
</ul>
`;
}
components/site-header.ts
/**
* The dashboard-01 site header: the sidebar trigger and the page title, at
* the height the page sets through `--header-height`. A fragment helper.
* Ported from shadcn/ui's dashboard-01.
*
* Options: `title`, `trigger: false` for a sidebar that does not collapse,
* `quickCreate` for a "Quick Create" button at the end (`quickCreateIcon` its
* icon), and `sticky` to pin the header over the scrolling page, as shadcn's
* examples/dashboard does. The button is a placeholder for your create flow.
* `github` is the ghost link at the end, shadcn's "GitHub" button pointing at
* this block's source: point it at your own repository, or pass `false` to
* leave it out.
*/
import { html } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import type { TemplateResult } from '@webjsdev/core';
import { buttonClass } from './ui/button.ts';
import { separatorClass } from './ui/separator.ts';
import { CirclePlusIcon } from '../lib/utils/icons.ts';
import './ui/sidebar.ts';
export interface SiteHeaderOptions {
title?: string;
trigger?: boolean;
quickCreate?: boolean;
quickCreateIcon?: TemplateResult;
sticky?: boolean;
github?: string | false;
}
const GITHUB = 'https://github.com/webjsdev/webjs/tree/main/packages/ui/packages/registry/blocks/dashboard-01';
export function siteHeader(opts: SiteHeaderOptions = {}) {
const trigger = opts.trigger ?? true;
const github = opts.github ?? GITHUB;
return html`
<header class=${cn('flex h-(--header-height) shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-(--header-height)', opts.sticky && 'sticky top-0 z-10 bg-background/90')}>
<div class="flex w-full items-center gap-1 px-4 lg:gap-2 lg:px-6">
${trigger ? html`<ui-sidebar-trigger class="-ml-1"></ui-sidebar-trigger>
<div role="none" data-slot="separator" data-orientation="vertical" class=${cn(separatorClass(), 'mx-2 data-[orientation=vertical]:h-4')}></div>` : ''}
<h1 class="text-base font-medium">${opts.title ?? 'Documents'}</h1>
${opts.quickCreate || github ? html`<div class="ml-auto flex items-center gap-2">
${opts.quickCreate ? html`<button type="button" data-slot="button" data-variant="default" data-size="sm" class=${cn(buttonClass({ size: 'sm' }), 'hidden h-7 sm:flex')}>
${opts.quickCreateIcon ?? CirclePlusIcon()}
<span>Quick Create</span>
</button>` : ''}
${github ? html`<a href=${github} rel="noopener noreferrer" target="_blank" data-slot="button" data-variant="ghost" data-size="sm" class=${cn(buttonClass({ variant: 'ghost', size: 'sm' }), 'hidden no-underline sm:flex dark:text-foreground')}>GitHub</a>` : ''}
</div>` : ''}
</div>
</header>
`;
}
components/section-cards.ts
/**
* The dashboard-01 section cards: four headline metrics, each with its
* trend badge and a two-line footer. A fragment helper. Ported from
* shadcn/ui's dashboard-01.
*
* The figures are sample data. Compute them on the server (a query in a
* `'use server'` file) and pass them in.
*/
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { badgeClass } from './ui/badge.ts';
import {
cardActionClass,
cardClass,
cardDescriptionClass,
cardFooterClass,
cardHeaderClass,
cardTitleClass,
} from './ui/card.ts';
import { TrendingDownIcon, TrendingUpIcon } from '../lib/utils/icons.ts';
interface Metric {
label: string;
value: string;
change: string;
trend: (cls?: string) => TemplateResult;
summary: string;
detail: string;
}
const metrics: Metric[] = [
{ label: 'Total Revenue', value: '$1,250.00', change: '+12.5%', trend: TrendingUpIcon, summary: 'Trending up this month', detail: 'Visitors for the last 6 months' },
{ label: 'New Customers', value: '1,234', change: '-20%', trend: TrendingDownIcon, summary: 'Down 20% this period', detail: 'Acquisition needs attention' },
{ label: 'Active Accounts', value: '45,678', change: '+12.5%', trend: TrendingUpIcon, summary: 'Strong user retention', detail: 'Engagement exceed targets' },
{ label: 'Growth Rate', value: '4.5%', change: '+4.5%', trend: TrendingUpIcon, summary: 'Steady performance increase', detail: 'Meets growth projections' },
];
export function sectionCards() {
return html`
<div class="grid grid-cols-1 gap-4 px-4 *:data-[slot=card]:bg-gradient-to-t *:data-[slot=card]:from-primary/5 *:data-[slot=card]:to-card *:data-[slot=card]:shadow-xs lg:px-6 @xl/main:grid-cols-2 @5xl/main:grid-cols-4 dark:*:data-[slot=card]:bg-card">
${metrics.map((m) => html`
<div data-slot="card" data-size="default" class=${cn(cardClass(), '@container/card')}>
<div data-slot="card-header" class=${cardHeaderClass()}>
<div data-slot="card-description" class=${cardDescriptionClass()}>${m.label}</div>
<div data-slot="card-title" class=${cn(cardTitleClass(), 'text-2xl font-semibold tabular-nums @[250px]/card:text-3xl')}>${m.value}</div>
<div data-slot="card-action" class=${cardActionClass()}>
<span data-slot="badge" data-variant="outline" class=${badgeClass({ variant: 'outline' })}>${m.trend()}${m.change}</span>
</div>
</div>
<div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col items-start gap-1.5 text-sm')}>
<div class="line-clamp-1 flex gap-2 font-medium">${m.summary} ${m.trend('size-4')}</div>
<div class="text-muted-foreground">${m.detail}</div>
</div>
</div>
`)}
</div>
`;
}
components/chart-area-interactive.ts
/**
* The dashboard-01 visitors chart: a stacked area chart of desktop and mobile
* visitors, with a time-range control (a toggle group on a wide card, a
* select on a narrow one) that narrows it to the last 3 months, 30 days or 7
* days. Ported from shadcn/ui's dashboard-01.
*
* The server draws all three ranges with the kit's `areaChart` and shows the
* 3-month one, so the first paint is the complete chart and it reads with
* JavaScript off. The `<dashboard-01-chart-range>` element below only swaps
* which range is shown and keeps the two controls in step. shadcn also starts
* a phone on the 7-day range; here a phone starts on 3 months like any other
* screen, since the server cannot know the width.
*
* Options: `range` picks the range shown first (`'90d'` by default), and
* `tooltipIndex` shows the tooltip at that point from the first paint
* (Recharts' `defaultIndex`; none by default).
*
* The figures are sample data. Query your own on the server and pass them to
* the chart the same way.
*/
import { WebComponent, html, svg } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import {
cardActionClass,
cardClass,
cardContentClass,
cardDescriptionClass,
cardHeaderClass,
cardTitleClass,
} from './ui/card.ts';
import { areaChart, type ChartConfig } from './ui/chart.ts';
import { selectTriggerClass } from './ui/select.ts';
import './ui/select.ts';
import './ui/toggle-group.ts';
export const description = 'An interactive area chart';
const chartData: { date: string; desktop: number; mobile: number }[] = [
{ date: '2024-04-01', desktop: 222, mobile: 150 },
{ date: '2024-04-02', desktop: 97, mobile: 180 },
{ date: '2024-04-03', desktop: 167, mobile: 120 },
{ date: '2024-04-04', desktop: 242, mobile: 260 },
{ date: '2024-04-05', desktop: 373, mobile: 290 },
{ date: '2024-04-06', desktop: 301, mobile: 340 },
{ date: '2024-04-07', desktop: 245, mobile: 180 },
{ date: '2024-04-08', desktop: 409, mobile: 320 },
{ date: '2024-04-09', desktop: 59, mobile: 110 },
{ date: '2024-04-10', desktop: 261, mobile: 190 },
{ date: '2024-04-11', desktop: 327, mobile: 350 },
{ date: '2024-04-12', desktop: 292, mobile: 210 },
{ date: '2024-04-13', desktop: 342, mobile: 380 },
{ date: '2024-04-14', desktop: 137, mobile: 220 },
{ date: '2024-04-15', desktop: 120, mobile: 170 },
{ date: '2024-04-16', desktop: 138, mobile: 190 },
{ date: '2024-04-17', desktop: 446, mobile: 360 },
{ date: '2024-04-18', desktop: 364, mobile: 410 },
{ date: '2024-04-19', desktop: 243, mobile: 180 },
{ date: '2024-04-20', desktop: 89, mobile: 150 },
{ date: '2024-04-21', desktop: 137, mobile: 200 },
{ date: '2024-04-22', desktop: 224, mobile: 170 },
{ date: '2024-04-23', desktop: 138, mobile: 230 },
{ date: '2024-04-24', desktop: 387, mobile: 290 },
{ date: '2024-04-25', desktop: 215, mobile: 250 },
{ date: '2024-04-26', desktop: 75, mobile: 130 },
{ date: '2024-04-27', desktop: 383, mobile: 420 },
{ date: '2024-04-28', desktop: 122, mobile: 180 },
{ date: '2024-04-29', desktop: 315, mobile: 240 },
{ date: '2024-04-30', desktop: 454, mobile: 380 },
{ date: '2024-05-01', desktop: 165, mobile: 220 },
{ date: '2024-05-02', desktop: 293, mobile: 310 },
{ date: '2024-05-03', desktop: 247, mobile: 190 },
{ date: '2024-05-04', desktop: 385, mobile: 420 },
{ date: '2024-05-05', desktop: 481, mobile: 390 },
{ date: '2024-05-06', desktop: 498, mobile: 520 },
{ date: '2024-05-07', desktop: 388, mobile: 300 },
{ date: '2024-05-08', desktop: 149, mobile: 210 },
{ date: '2024-05-09', desktop: 227, mobile: 180 },
{ date: '2024-05-10', desktop: 293, mobile: 330 },
{ date: '2024-05-11', desktop: 335, mobile: 270 },
{ date: '2024-05-12', desktop: 197, mobile: 240 },
{ date: '2024-05-13', desktop: 197, mobile: 160 },
{ date: '2024-05-14', desktop: 448, mobile: 490 },
{ date: '2024-05-15', desktop: 473, mobile: 380 },
{ date: '2024-05-16', desktop: 338, mobile: 400 },
{ date: '2024-05-17', desktop: 499, mobile: 420 },
{ date: '2024-05-18', desktop: 315, mobile: 350 },
{ date: '2024-05-19', desktop: 235, mobile: 180 },
{ date: '2024-05-20', desktop: 177, mobile: 230 },
{ date: '2024-05-21', desktop: 82, mobile: 140 },
{ date: '2024-05-22', desktop: 81, mobile: 120 },
{ date: '2024-05-23', desktop: 252, mobile: 290 },
{ date: '2024-05-24', desktop: 294, mobile: 220 },
{ date: '2024-05-25', desktop: 201, mobile: 250 },
{ date: '2024-05-26', desktop: 213, mobile: 170 },
{ date: '2024-05-27', desktop: 420, mobile: 460 },
{ date: '2024-05-28', desktop: 233, mobile: 190 },
{ date: '2024-05-29', desktop: 78, mobile: 130 },
{ date: '2024-05-30', desktop: 340, mobile: 280 },
{ date: '2024-05-31', desktop: 178, mobile: 230 },
{ date: '2024-06-01', desktop: 178, mobile: 200 },
{ date: '2024-06-02', desktop: 470, mobile: 410 },
{ date: '2024-06-03', desktop: 103, mobile: 160 },
{ date: '2024-06-04', desktop: 439, mobile: 380 },
{ date: '2024-06-05', desktop: 88, mobile: 140 },
{ date: '2024-06-06', desktop: 294, mobile: 250 },
{ date: '2024-06-07', desktop: 323, mobile: 370 },
{ date: '2024-06-08', desktop: 385, mobile: 320 },
{ date: '2024-06-09', desktop: 438, mobile: 480 },
{ date: '2024-06-10', desktop: 155, mobile: 200 },
{ date: '2024-06-11', desktop: 92, mobile: 150 },
{ date: '2024-06-12', desktop: 492, mobile: 420 },
{ date: '2024-06-13', desktop: 81, mobile: 130 },
{ date: '2024-06-14', desktop: 426, mobile: 380 },
{ date: '2024-06-15', desktop: 307, mobile: 350 },
{ date: '2024-06-16', desktop: 371, mobile: 310 },
{ date: '2024-06-17', desktop: 475, mobile: 520 },
{ date: '2024-06-18', desktop: 107, mobile: 170 },
{ date: '2024-06-19', desktop: 341, mobile: 290 },
{ date: '2024-06-20', desktop: 408, mobile: 450 },
{ date: '2024-06-21', desktop: 169, mobile: 210 },
{ date: '2024-06-22', desktop: 317, mobile: 270 },
{ date: '2024-06-23', desktop: 480, mobile: 530 },
{ date: '2024-06-24', desktop: 132, mobile: 180 },
{ date: '2024-06-25', desktop: 141, mobile: 190 },
{ date: '2024-06-26', desktop: 434, mobile: 380 },
{ date: '2024-06-27', desktop: 448, mobile: 490 },
{ date: '2024-06-28', desktop: 149, mobile: 200 },
{ date: '2024-06-29', desktop: 103, mobile: 160 },
{ date: '2024-06-30', desktop: 446, mobile: 400 },
];
const chartConfig = {
visitors: {
label: 'Visitors',
},
desktop: {
label: 'Desktop',
color: 'var(--primary)',
},
mobile: {
label: 'Mobile',
color: 'var(--primary)',
},
} satisfies ChartConfig;
export type ChartRange = '90d' | '30d' | '7d';
const RANGES: { value: ChartRange; days: number; label: string }[] = [
{ value: '90d', days: 90, label: 'Last 3 months' },
{ value: '30d', days: 30, label: 'Last 30 days' },
{ value: '7d', days: 7, label: 'Last 7 days' },
];
const DAY = 24 * 60 * 60 * 1000;
const REFERENCE = Date.parse('2024-06-30');
// The dates are calendar dates, so they are read and written in UTC: a server
// west of Greenwich would otherwise print every tick a day early.
const shortDate = (value: unknown) =>
new Date(String(value)).toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' });
function rangeChart(range: (typeof RANGES)[number], tooltipIndex?: number) {
const start = REFERENCE - range.days * DAY;
const data = chartData.filter((item) => Date.parse(item.date) >= start);
// Gradient ids are per range, since all three charts sit on one page.
const desktop = `fillDesktop-${range.value}`;
const mobile = `fillMobile-${range.value}`;
return areaChart({
config: chartConfig,
data,
title: `Desktop and mobile visitors, ${range.label.toLowerCase()}`,
class: 'aspect-auto h-[250px] w-full',
width: 1046,
height: 250,
defs: svg`
<linearGradient id=${desktop} x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stop-color="var(--color-desktop)" stop-opacity="1"></stop>
<stop offset="95%" stop-color="var(--color-desktop)" stop-opacity="0.1"></stop>
</linearGradient>
<linearGradient id=${mobile} x1="0" y1="0" x2="0" y2="1">
<stop offset="5%" stop-color="var(--color-mobile)" stop-opacity="0.8"></stop>
<stop offset="95%" stop-color="var(--color-mobile)" stop-opacity="0.1"></stop>
</linearGradient>
`,
grid: { vertical: false },
xAxis: { dataKey: 'date', tickLine: false, axisLine: false, tickMargin: 8, minTickGap: 32, tickFormatter: shortDate },
tooltip: { cursor: false, indicator: 'dot', labelFormatter: shortDate, defaultIndex: tooltipIndex },
areas: [
{ dataKey: 'mobile', type: 'natural', fill: `url(#${mobile})`, stroke: 'var(--color-mobile)', stackId: 'a' },
{ dataKey: 'desktop', type: 'natural', fill: `url(#${desktop})`, stroke: 'var(--color-desktop)', stackId: 'a' },
],
});
}
export function chartAreaInteractive(opts: { range?: ChartRange; tooltipIndex?: number } = {}) {
const initial = RANGES.some((r) => r.value === opts.range) ? opts.range! : '90d';
return html`
<dashboard-01-chart-range>
<div data-slot="card" data-size="default" class=${cn(cardClass(), '@container/card')}>
<div data-slot="card-header" class=${cardHeaderClass()}>
<div data-slot="card-title" class=${cardTitleClass()}>Total Visitors</div>
<div data-slot="card-description" class=${cardDescriptionClass()}>
<span class="hidden @[540px]/card:block">Total for the last 3 months</span>
<span class="@[540px]/card:hidden">Last 3 months</span>
</div>
<div data-slot="card-action" class=${cardActionClass()}>
<ui-toggle-group type="single" value=${initial} variant="outline" spacing="0" class="hidden *:data-[slot=toggle-group-item]:px-4! @[767px]/card:flex">
${RANGES.map((r) => html`<ui-toggle-group-item value=${r.value}>${r.label}</ui-toggle-group-item>`)}
</ui-toggle-group>
<ui-select size="sm">
<select aria-label="Select a value" class=${cn(selectTriggerClass(), 'flex w-40 **:data-[slot=select-value]:block **:data-[slot=select-value]:truncate @[767px]/card:hidden')}>
${RANGES.map((r) => html`<option value=${r.value} ?selected=${r.value === initial}>${r.label}</option>`)}
</select>
</ui-select>
</div>
</div>
<div data-slot="card-content" class=${cn(cardContentClass(), 'px-2 pt-4 sm:px-6 sm:pt-6')}>
${RANGES.map((r) => html`<div data-range=${r.value} ?hidden=${r.value !== initial}>${rangeChart(r, opts.tooltipIndex)}</div>`)}
</div>
</div>
</dashboard-01-chart-range>
`;
}
/**
* `<dashboard-01-chart-range>`: shows the range the toggle group or the select
* picks, and moves the other control to match. The charts themselves are the
* server's; nothing is redrawn here.
*/
export class Dashboard01ChartRange extends WebComponent {
connectedCallback() {
super.connectedCallback();
this.addEventListener('ui-value-change', this._onToggle);
this.addEventListener('change', this._onSelect);
}
disconnectedCallback() {
this.removeEventListener('ui-value-change', this._onToggle);
this.removeEventListener('change', this._onSelect);
super.disconnectedCallback();
}
_show(value: string): void {
if (!RANGES.some((r) => r.value === value)) return;
for (const panel of Array.from(this.querySelectorAll<HTMLElement>('[data-range]'))) {
panel.hidden = panel.dataset.range !== value;
}
const group = this.querySelector('ui-toggle-group') as (HTMLElement & { value: string }) | null;
if (group && group.value !== value) group.value = value;
const select = this.querySelector<HTMLSelectElement>('ui-select select');
if (select && select.value !== value) {
select.value = value;
select.dispatchEvent(new Event('change', { bubbles: true }));
}
}
// A single toggle group can be emptied by pressing the active item; the
// range then stays where it was, so put the pressed state back.
_onToggle = (e: Event): void => {
const target = e.target as Element;
if (target.tagName !== 'UI-TOGGLE-GROUP') return;
const value = String((e as CustomEvent<{ value: string }>).detail?.value ?? '');
if (value) this._show(value);
else this._show(this.querySelector<HTMLElement>('[data-range]:not([hidden])')?.dataset.range ?? '90d');
};
_onSelect = (e: Event): void => {
const select = e.target as HTMLSelectElement;
if (select.tagName === 'SELECT') this._show(select.value);
};
render() {
return html`<slot></slot>`;
}
}
Dashboard01ChartRange.register('dashboard-01-chart-range');
components/data-table.ts
/**
* The dashboard-01 data table: the document's outline sections under a row of
* view tabs, with a columns menu, row selection, drag-to-reorder, inline
* target and limit fields, a reviewer picker, a row actions menu, pagination,
* and a drawer that opens a section for editing. Ported from shadcn/ui's
* dashboard-01, which builds it on TanStack Table and dnd-kit.
*
* The server renders the first page of 10 rows, so the first paint is
* shadcn's and reads with JavaScript off, and the document holds only the
* rows on screen. Every row rides on the element's `rows` attribute, and
* `<dashboard-01-data-table>` (below) renders the current page's rows from
* it on each change, with no third-party code: the page buttons and the page
* size, the row checkboxes with select-all and the "n of m row(s) selected"
* count, the columns menu, dragging a row by its handle (or moving it with
* the arrow keys while the handle has focus), the view select on a narrow
* card, and the one drawer that every row's title fills and opens. The order,
* the selection and the edited cells live in the element, so they hold across
* pages.
*
* The forms have no action yet. Bind a server action from a `'use server'`
* file to the inline target and limit forms and to the drawer's form
* (`<form action=${saveSection}>`), and render the rows from your own query
* in place of `dashboardData`. Until then the inline forms submit as a GET
* back to the page.
*/
import { WebComponent, html, prop, render, repeat, nothing } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { badgeClass } from './ui/badge.ts';
import { buttonClass } from './ui/button.ts';
import { areaChart, type ChartConfig } from './ui/chart.ts';
import { checkboxClass } from './ui/checkbox.ts';
import {
drawerDescriptionClass,
drawerFooterClass,
drawerHeaderClass,
drawerTitleClass,
} from './ui/drawer.ts';
import { inputClass } from './ui/input.ts';
import { labelClass } from './ui/label.ts';
import { selectTriggerClass } from './ui/select.ts';
import { separatorClass } from './ui/separator.ts';
import {
tableBodyClass,
tableCellClass,
tableClass,
tableContainerClass,
tableHeadClass,
tableHeaderClass,
tableRowClass,
} from './ui/table.ts';
import './ui/checkbox.ts';
import './ui/drawer.ts';
import './ui/dropdown-menu.ts';
import './ui/select.ts';
import './ui/tabs.ts';
import type { DashboardRow } from './dashboard-data.ts';
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronsLeftIcon, ChevronsRightIcon, CircleCheckIcon, Columns3Icon, EllipsisVerticalIcon, GripVerticalIcon, LoaderIcon, PlusIcon, TrendingUpIcon } from '../lib/utils/icons.ts';
/** The columns the columns menu can hide, shadcn's hideable accessor columns. */
const HIDEABLE = ['type', 'status', 'target', 'limit', 'reviewer'];
const VIEWS = [
{ value: 'outline', label: 'Outline' },
{ value: 'past-performance', label: 'Past Performance', count: 3 },
{ value: 'key-personnel', label: 'Key Personnel', count: 2 },
{ value: 'focus-documents', label: 'Focus Documents' },
];
const PAGE_SIZES = [10, 20, 30, 40, 50];
const SECTION_TYPES = ['Table of Contents', 'Executive Summary', 'Technical Approach', 'Design', 'Capabilities', 'Focus Documents', 'Narrative', 'Cover Page'];
const STATUSES = ['Done', 'In Progress', 'Not Started'];
const REVIEWERS = ['Eddie Lake', 'Jamik Tashpulatov', 'Emily Whalen'];
const INLINE_INPUT = 'h-8 w-16 border-transparent bg-transparent text-right shadow-none hover:bg-input/30 focus-visible:border focus-visible:bg-background dark:bg-transparent dark:hover:bg-input/30 dark:focus-visible:bg-input/30';
const head = (cls = '') => cn(tableHeadClass(), cls);
const cell = (cls = '') => cn(tableCellClass(), cls);
/** What the row edits in place: the inline fields and the reviewer pick. */
type RowEdit = Partial<Pick<DashboardRow, 'target' | 'limit' | 'reviewer'>>;
/** How one row renders: selected or not, its edits, the hidden columns. */
interface RowState {
selected: boolean;
edit: RowEdit;
hidden: ReadonlySet<string>;
}
const FIRST_PAINT: RowState = { selected: false, edit: {}, hidden: new Set() };
/** One inline field (target or limit), a form of its own as in shadcn. */
function inlineField(row: DashboardRow, key: 'target' | 'limit', label: string, edit: RowEdit) {
return html`<form>
<label for=${`${row.id}-${key}`} data-slot="label" class=${cn(labelClass(), 'sr-only')}>${label}</label>
<input id=${`${row.id}-${key}`} name=${key} value=${edit[key] ?? row[key]} data-row-edit=${key} data-slot="input" class=${cn(inputClass(), INLINE_INPUT)}>
</form>`;
}
function reviewerCell(row: DashboardRow, edit: RowEdit) {
if (row.reviewer !== 'Assign reviewer') return row.reviewer;
const picked = edit.reviewer ?? '';
return html`
<label for=${`${row.id}-reviewer`} data-slot="label" class=${cn(labelClass(), 'sr-only')}>Reviewer</label>
<ui-select size="sm" placeholder="Assign reviewer">
<select id=${`${row.id}-reviewer`} name="reviewer" data-row-edit="reviewer" class=${cn(selectTriggerClass(), 'w-38 **:data-[slot=select-value]:block **:data-[slot=select-value]:truncate')}>
<option value="" disabled hidden ?selected=${!picked}>Assign reviewer</option>
<option value="Eddie Lake" ?selected=${picked === 'Eddie Lake'}>Eddie Lake</option>
<option value="Jamik Tashpulatov" ?selected=${picked === 'Jamik Tashpulatov'}>Jamik Tashpulatov</option>
</select>
</ui-select>
`;
}
function row(r: DashboardRow, state: RowState) {
const { selected, edit, hidden } = state;
return html`
<tr data-slot="table-row" data-row-id=${String(r.id)} data-dragging="false" data-state=${selected ? 'selected' : nothing} class=${cn(tableRowClass(), 'relative z-0 data-[dragging=true]:z-10 data-[dragging=true]:opacity-80')}>
<td data-slot="table-cell" class=${cell()}>
<button type="button" draggable="true" data-drag-handle data-slot="button" data-variant="ghost" data-size="icon" class=${cn(buttonClass({ variant: 'ghost', size: 'icon' }), 'size-7 cursor-grab text-muted-foreground hover:bg-transparent')}>
${GripVerticalIcon('size-3 text-muted-foreground')}
<span class="sr-only">Drag to reorder</span>
</button>
</td>
<td data-slot="table-cell" class=${cell()}>
<div class="flex items-center justify-center">
${state === FIRST_PAINT
// The first paint is part of the PAGE's template (the page never
// hydrates), so it states the checkbox as an attribute; a page
// template may not carry a `.prop` binding. The element's own
// repaints set the live property, which a box the user has
// toggled still follows.
? html`<input type="checkbox" data-slot="checkbox" data-row-select class=${checkboxClass()} aria-label="Select row" ?checked=${selected}>`
: html`<input type="checkbox" data-slot="checkbox" data-row-select class=${checkboxClass()} aria-label="Select row" .checked=${selected}>`}
</div>
</td>
<td data-slot="table-cell" class=${cell()}>
<button type="button" data-row-open data-slot="button" data-variant="link" class=${cn(buttonClass({ variant: 'link' }), 'w-fit px-0 text-left text-foreground')}>${r.header}</button>
</td>
<td data-slot="table-cell" data-column="type" class=${cell()} ?hidden=${hidden.has('type')}>
<div class="w-32">
<span data-slot="badge" data-variant="outline" class=${cn(badgeClass({ variant: 'outline' }), 'px-1.5 text-muted-foreground')}>${r.type}</span>
</div>
</td>
<td data-slot="table-cell" data-column="status" class=${cell()} ?hidden=${hidden.has('status')}>
<span data-slot="badge" data-variant="outline" class=${cn(badgeClass({ variant: 'outline' }), 'px-1.5 text-muted-foreground')}>
${r.status === 'Done' ? CircleCheckIcon('fill-green-500 dark:fill-green-400') : LoaderIcon()}
${r.status}
</span>
</td>
<td data-slot="table-cell" data-column="target" class=${cell()} ?hidden=${hidden.has('target')}>${inlineField(r, 'target', 'Target', edit)}</td>
<td data-slot="table-cell" data-column="limit" class=${cell()} ?hidden=${hidden.has('limit')}>${inlineField(r, 'limit', 'Limit', edit)}</td>
<td data-slot="table-cell" data-column="reviewer" class=${cell()} ?hidden=${hidden.has('reviewer')}>${reviewerCell(r, edit)}</td>
<td data-slot="table-cell" class=${cell()}>
<ui-dropdown-menu>
<ui-dropdown-menu-trigger>
<button type="button" data-slot="button" data-variant="ghost" data-size="icon" class=${cn(buttonClass({ variant: 'ghost', size: 'icon' }), 'flex size-8 text-muted-foreground aria-expanded:bg-muted')}>
${EllipsisVerticalIcon()}
<span class="sr-only">Open menu</span>
</button>
</ui-dropdown-menu-trigger>
<ui-dropdown-menu-content align="end" class="w-32">
<ui-dropdown-menu-item>Edit</ui-dropdown-menu-item>
<ui-dropdown-menu-item>Make a copy</ui-dropdown-menu-item>
<ui-dropdown-menu-item>Favorite</ui-dropdown-menu-item>
<ui-dropdown-menu-separator></ui-dropdown-menu-separator>
<ui-dropdown-menu-item variant="destructive">Delete</ui-dropdown-menu-item>
</ui-dropdown-menu-content>
</ui-dropdown-menu>
</td>
</tr>
`;
}
/** The body's rows, keyed by id so a reorder moves the row's own element. */
const bodyRows = (rows: DashboardRow[], stateOf: (r: DashboardRow) => RowState) =>
html`${repeat(rows, (r) => r.id, (r) => row(r, stateOf(r)))}`;
const pageButton = (action: string, label: string, icon: unknown, cls: string, disabled: boolean) =>
html`<button type="button" data-page=${action} data-slot="button" data-variant="outline" class=${cn(buttonClass({ variant: 'outline', size: 'icon' }), cls)} ?disabled=${disabled}>
<span class="sr-only">${label}</span>${icon}
</button>`;
// The drawer's chart, shadcn's TableCellViewer chart.
const drawerChartData = [
{ month: 'January', desktop: 186, mobile: 80 },
{ month: 'February', desktop: 305, mobile: 200 },
{ month: 'March', desktop: 237, mobile: 120 },
{ month: 'April', desktop: 73, mobile: 190 },
{ month: 'May', desktop: 209, mobile: 130 },
{ month: 'June', desktop: 214, mobile: 140 },
];
const drawerChartConfig = {
desktop: { label: 'Desktop', color: 'var(--primary)' },
mobile: { label: 'Mobile', color: 'var(--primary)' },
} satisfies ChartConfig;
function drawerSelect(id: string, label: string, placeholder: string, options: string[], current: string) {
return html`<div class="flex flex-col gap-3">
<label for=${id} data-slot="label" class=${labelClass()}>${label}</label>
<ui-select placeholder=${placeholder}>
<select id=${id} name=${id.replace('drawer-', '')} class=${cn(selectTriggerClass(), 'w-full')}>
<option value="" disabled hidden ?selected=${!options.includes(current)}>${placeholder}</option>
${options.map((o) => html`<option value=${o} ?selected=${o === current}>${o}</option>`)}
</select>
</ui-select>
</div>`;
}
function drawerInput(id: string, label: string, value: string) {
return html`<div class="flex flex-col gap-3">
<label for=${id} data-slot="label" class=${labelClass()}>${label}</label>
<input id=${id} name=${id.replace('drawer-', '')} value=${value} data-slot="input" class=${inputClass()}>
</div>`;
}
/**
* shadcn's TableCellViewer, rendered once: every row's title opens this
* drawer, and the element fills it with that row's values first. shadcn hides
* the chart on a phone, where the drawer comes up from the bottom; here it
* always slides in from the right and the chart hides below md.
*/
function rowDrawer(first: DashboardRow) {
return html`
<ui-drawer data-row-drawer>
<ui-drawer-content direction="right">
<div data-slot="drawer-header" class=${cn(drawerHeaderClass(), 'gap-1')}>
<h2 data-slot="drawer-title" data-drawer-title class=${drawerTitleClass()}>${first.header}</h2>
<p data-slot="drawer-description" class=${drawerDescriptionClass()}>Showing total visitors for the last 6 months</p>
</div>
<div class="flex flex-col gap-4 overflow-y-auto px-4 text-sm">
<div class="hidden flex-col gap-4 md:flex">
${areaChart({
config: drawerChartConfig,
data: drawerChartData,
title: 'Desktop and mobile visitors, January to June',
margin: { left: 0, right: 10 },
grid: { vertical: false },
xAxis: { dataKey: 'month', tickLine: false, axisLine: false, tickMargin: 8, tickFormatter: (value) => String(value).slice(0, 3), hide: true },
tooltip: { cursor: false, indicator: 'dot' },
areas: [
{ dataKey: 'mobile', type: 'natural', fill: 'var(--color-mobile)', fillOpacity: 0.6, stroke: 'var(--color-mobile)', stackId: 'a' },
{ dataKey: 'desktop', type: 'natural', fill: 'var(--color-desktop)', fillOpacity: 0.4, stroke: 'var(--color-desktop)', stackId: 'a' },
],
})}
<div role="none" data-slot="separator" data-orientation="horizontal" class=${separatorClass()}></div>
<div class="grid gap-2">
<div class="flex gap-2 leading-none font-medium">Trending up by 5.2% this month ${TrendingUpIcon('size-4')}</div>
<div class="text-muted-foreground">Showing total visitors for the last 6 months. This is just some random text to test the layout. It spans multiple lines and should wrap around.</div>
</div>
<div role="none" data-slot="separator" data-orientation="horizontal" class=${separatorClass()}></div>
</div>
<form id="drawer-form" class="flex flex-col gap-4">
${drawerInput('drawer-header', 'Header', first.header)}
<div class="grid grid-cols-2 gap-4">
${drawerSelect('drawer-type', 'Type', 'Select a type', SECTION_TYPES, first.type)}
${drawerSelect('drawer-status', 'Status', 'Select a status', STATUSES, first.status)}
</div>
<div class="grid grid-cols-2 gap-4">
${drawerInput('drawer-target', 'Target', first.target)}
${drawerInput('drawer-limit', 'Limit', first.limit)}
</div>
${drawerSelect('drawer-reviewer', 'Reviewer', 'Select a reviewer', REVIEWERS, first.reviewer)}
</form>
</div>
<div data-slot="drawer-footer" class=${drawerFooterClass()}>
<button type="submit" form="drawer-form" data-slot="button" class=${buttonClass()}>Submit</button>
<ui-drawer-close><button type="button" data-slot="button" data-variant="outline" class=${cn(buttonClass({ variant: 'outline' }), 'w-full')}>Done</button></ui-drawer-close>
</div>
</ui-drawer-content>
</ui-drawer>
`;
}
export function dataTable({ data }: { data: DashboardRow[] }) {
const pageCount = Math.max(1, Math.ceil(data.length / PAGE_SIZES[0]));
return html`
<dashboard-01-data-table rows=${JSON.stringify(data)}>
<ui-tabs value="outline" class="w-full flex-col justify-start gap-6">
<div class="flex items-center justify-between px-4 lg:px-6">
<label for="view-selector" data-slot="label" class=${cn(labelClass(), 'sr-only')}>View</label>
<ui-select size="sm" placeholder="Select a view">
<select id="view-selector" data-view-select class=${cn(selectTriggerClass(), 'flex w-fit @4xl/main:hidden')}>
${VIEWS.map((v) => html`<option value=${v.value} ?selected=${v.value === 'outline'}>${v.label}</option>`)}
</select>
</ui-select>
<ui-tabs-list class="hidden **:data-[slot=badge]:size-5 **:data-[slot=badge]:rounded-full **:data-[slot=badge]:bg-muted-foreground/30 **:data-[slot=badge]:px-1 @4xl/main:flex">
${VIEWS.map((v) => html`<ui-tabs-trigger value=${v.value}>${v.label}${v.count ? html` <span data-slot="badge" data-variant="secondary" class=${badgeClass({ variant: 'secondary' })}>${v.count}</span>` : ''}</ui-tabs-trigger>`)}
</ui-tabs-list>
<div class="flex items-center gap-2">
<ui-dropdown-menu>
<ui-dropdown-menu-trigger>
<button type="button" data-slot="button" data-variant="outline" data-size="sm" class=${buttonClass({ variant: 'outline', size: 'sm' })}>
${Columns3Icon()}
Columns
${ChevronDownIcon()}
</button>
</ui-dropdown-menu-trigger>
<ui-dropdown-menu-content align="end" class="w-32">
${HIDEABLE.map((c) => html`<ui-dropdown-menu-item type="checkbox" value=${c} checked data-column-toggle class="capitalize">${c}</ui-dropdown-menu-item>`)}
</ui-dropdown-menu-content>
</ui-dropdown-menu>
<button type="button" data-slot="button" data-variant="outline" data-size="sm" class=${buttonClass({ variant: 'outline', size: 'sm' })}>
${PlusIcon()}
<span class="hidden lg:inline">Add Section</span>
</button>
</div>
</div>
<ui-tabs-content value="outline" class="relative flex flex-col gap-4 overflow-auto px-4 lg:px-6">
<div class="overflow-hidden rounded-lg border">
<div data-slot="table-container" class=${tableContainerClass()}>
<table data-slot="table" class=${tableClass()}>
<thead data-slot="table-header" class=${cn(tableHeaderClass(), 'sticky top-0 z-10 bg-muted')}>
<tr data-slot="table-row" class=${tableRowClass()}>
<th scope="col" data-slot="table-head" class=${head()}><span class="sr-only">Drag to reorder</span></th>
<th scope="col" data-slot="table-head" class=${head()}>
<div class="flex items-center justify-center">
<input type="checkbox" data-slot="checkbox" data-select-all class=${checkboxClass()} aria-label="Select all">
</div>
</th>
<th scope="col" data-slot="table-head" class=${head()}>Header</th>
<th scope="col" data-slot="table-head" data-column="type" class=${head()}>Section Type</th>
<th scope="col" data-slot="table-head" data-column="status" class=${head()}>Status</th>
<th scope="col" data-slot="table-head" data-column="target" class=${head()}><div class="w-full text-right">Target</div></th>
<th scope="col" data-slot="table-head" data-column="limit" class=${head()}><div class="w-full text-right">Limit</div></th>
<th scope="col" data-slot="table-head" data-column="reviewer" class=${head()}>Reviewer</th>
<th scope="col" data-slot="table-head" class=${head()}><span class="sr-only">Actions</span></th>
</tr>
</thead>
<tbody data-slot="table-body" data-rows class=${cn(tableBodyClass(), '**:data-[slot=table-cell]:first:w-8')}>
${data.length
? bodyRows(data.slice(0, PAGE_SIZES[0]), () => FIRST_PAINT)
: html`<tr data-slot="table-row" class=${tableRowClass()}><td colspan="9" data-slot="table-cell" class=${cell('h-24 text-center')}>No results.</td></tr>`}
</tbody>
</table>
</div>
</div>
<div class="flex items-center justify-between px-4">
<div class="hidden flex-1 text-sm text-muted-foreground lg:flex" aria-live="polite">
<span><span data-selected-count>0</span> of <span data-row-count>${data.length}</span> row(s) selected.</span>
</div>
<div class="flex w-full items-center gap-8 lg:w-fit">
<div class="hidden items-center gap-2 lg:flex">
<label for="rows-per-page" data-slot="label" class=${cn(labelClass(), 'text-sm font-medium')}>Rows per page</label>
<ui-select size="sm">
<select id="rows-per-page" data-page-size class=${cn(selectTriggerClass(), 'w-20')}>
${PAGE_SIZES.map((n) => html`<option value=${String(n)} ?selected=${n === PAGE_SIZES[0]}>${n}</option>`)}
</select>
</ui-select>
</div>
<div class="flex w-fit items-center justify-center text-sm font-medium" data-page-label>Page 1 of ${pageCount}</div>
<div class="ml-auto flex items-center gap-2 lg:ml-0">
${pageButton('first', 'Go to first page', ChevronsLeftIcon(), 'hidden h-8 w-8 p-0 lg:flex', true)}
${pageButton('previous', 'Go to previous page', ChevronLeftIcon(), 'size-8', true)}
${pageButton('next', 'Go to next page', ChevronRightIcon(), 'size-8', pageCount <= 1)}
${pageButton('last', 'Go to last page', ChevronsRightIcon(), 'hidden size-8 lg:flex', pageCount <= 1)}
</div>
</div>
</div>
</ui-tabs-content>
${VIEWS.slice(1).map((v) => html`<ui-tabs-content value=${v.value} class="flex flex-col px-4 lg:px-6">
<div class="aspect-video w-full flex-1 rounded-lg border border-dashed"></div>
</ui-tabs-content>`)}
</ui-tabs>
${data.length ? rowDrawer(data[0]) : ''}
</dashboard-01-data-table>
`;
}
type Valued = HTMLElement & { value: string };
type Openable = HTMLElement & { open: boolean };
/**
* `<dashboard-01-data-table>`: the table's behaviour. It holds every row (the
* `rows` attribute the server writes) in the order the reader set, with the
* selection and the edited cells, and renders the current page's rows into
* the body on each page, page-size, reorder, selection and column change, so
* the document only ever holds one page.
*/
export class Dashboard01DataTable extends WebComponent({
rows: prop<DashboardRow[]>(Array),
}) {
_pageIndex = 0;
_pageSize = PAGE_SIZES[0];
_order: DashboardRow[] | null = null;
_selected = new Set<number>();
_edits = new Map<number, RowEdit>();
_hidden = new Set<string>();
_dragged: number | null = null;
constructor() {
super();
this.rows = [];
}
connectedCallback() {
super.connectedCallback();
this.addEventListener('change', this._onChange);
this.addEventListener('input', this._onInput);
this.addEventListener('click', this._onClick);
this.addEventListener('ui-item-select', this._onItemSelect);
this.addEventListener('ui-value-change', this._onTabs);
this.addEventListener('dragstart', this._onDragStart);
this.addEventListener('dragover', this._onDragOver);
this.addEventListener('dragend', this._onDragEnd);
this.addEventListener('keydown', this._onKeyDown);
}
disconnectedCallback() {
this.removeEventListener('change', this._onChange);
this.removeEventListener('input', this._onInput);
this.removeEventListener('click', this._onClick);
this.removeEventListener('ui-item-select', this._onItemSelect);
this.removeEventListener('ui-value-change', this._onTabs);
this.removeEventListener('dragstart', this._onDragStart);
this.removeEventListener('dragover', this._onDragOver);
this.removeEventListener('dragend', this._onDragEnd);
this.removeEventListener('keydown', this._onKeyDown);
super.disconnectedCallback();
}
/** Every row, in the reader's order. */
_all(): DashboardRow[] {
return (this._order ??= [...(this.rows || [])]);
}
_pageCount(): number {
return Math.max(1, Math.ceil(this._all().length / this._pageSize));
}
_pageRows(): DashboardRow[] {
const start = this._pageIndex * this._pageSize;
return this._all().slice(start, start + this._pageSize);
}
_rowId(el: Element | null): number | null {
const id = el?.closest('tr[data-row-id]')?.getAttribute('data-row-id');
return id == null ? null : Number(id);
}
_stateOf = (r: DashboardRow): RowState => ({
selected: this._selected.has(r.id),
edit: this._edits.get(r.id) ?? {},
hidden: this._hidden,
});
/** Render the current page's rows, then the pager and the selection text. */
_update(): void {
const all = this._all();
const pageCount = this._pageCount();
this._pageIndex = Math.min(Math.max(0, this._pageIndex), pageCount - 1);
const body = this.querySelector<HTMLElement>('tbody[data-rows]');
if (body && all.length) render(bodyRows(this._pageRows(), this._stateOf), body);
const label = this.querySelector('[data-page-label]');
if (label) label.textContent = `Page ${this._pageIndex + 1} of ${pageCount}`;
const atStart = this._pageIndex === 0;
const atEnd = this._pageIndex >= pageCount - 1;
for (const b of Array.from(this.querySelectorAll<HTMLButtonElement>('button[data-page]'))) {
b.disabled = b.dataset.page === 'first' || b.dataset.page === 'previous' ? atStart : atEnd;
}
const count = this.querySelector('[data-selected-count]');
if (count) count.textContent = String(this._selected.size);
const total = this.querySelector('[data-row-count]');
if (total) total.textContent = String(all.length);
const box = this.querySelector<HTMLInputElement>('input[data-select-all]');
if (box) {
const page = this._pageRows().map((r) => this._selected.has(r.id));
box.checked = page.length > 0 && page.every(Boolean);
box.indeterminate = !box.checked && page.some(Boolean);
}
}
_onChange = (e: Event): void => {
const t = e.target as HTMLInputElement | HTMLSelectElement;
if (t.matches('input[data-select-all]')) {
for (const r of this._pageRows()) {
if ((t as HTMLInputElement).checked) this._selected.add(r.id);
else this._selected.delete(r.id);
}
this._update();
} else if (t.matches('input[data-row-select]')) {
const id = this._rowId(t);
if (id != null) {
if ((t as HTMLInputElement).checked) this._selected.add(id);
else this._selected.delete(id);
}
this._update();
} else if (t.matches('select[data-row-edit]')) {
this._edit(t);
} else if (t.matches('select[data-page-size]')) {
this._pageSize = Number(t.value) || PAGE_SIZES[0];
this._pageIndex = 0;
this._update();
} else if (t.matches('select[data-view-select]')) {
const tabs = this.querySelector('ui-tabs') as Valued | null;
if (tabs && tabs.value !== t.value) tabs.value = t.value;
}
};
// An edited cell is kept with its row, so it holds across pages.
_onInput = (e: Event): void => {
const t = e.target as HTMLInputElement;
if (t.matches?.('input[data-row-edit]')) this._edit(t);
};
_edit(field: HTMLInputElement | HTMLSelectElement): void {
const id = this._rowId(field);
const key = field.dataset.rowEdit as keyof RowEdit | undefined;
if (id == null || !key) return;
this._edits.set(id, { ...this._edits.get(id), [key]: field.value });
}
// A tab picked on a wide card moves the narrow card's view select with it.
_onTabs = (e: Event): void => {
if ((e.target as Element).tagName !== 'UI-TABS') return;
const value = String((e as CustomEvent<{ value: string }>).detail?.value ?? '');
const select = this.querySelector<HTMLSelectElement>('select[data-view-select]');
if (select && value && select.value !== value) {
select.value = value;
select.dispatchEvent(new Event('change', { bubbles: true }));
}
};
_onClick = (e: Event): void => {
const button = (e.target as Element).closest?.('button');
if (!button || !this.contains(button)) return;
const page = button.dataset.page;
if (page) {
const last = this._pageCount() - 1;
this._pageIndex = page === 'first' ? 0 : page === 'previous' ? this._pageIndex - 1 : page === 'next' ? this._pageIndex + 1 : last;
this._update();
} else if (button.hasAttribute('data-row-open')) {
this._openDrawer(button.closest('tr'));
}
};
// The columns menu: each checkbox item shows or hides its column, the
// header cell here and the body cells on every render.
_onItemSelect = (e: Event): void => {
const item = e.target as HTMLElement;
if (!item.hasAttribute('data-column-toggle')) return;
const { value, checked } = (e as CustomEvent<{ value: string; checked: boolean }>).detail;
if (checked) this._hidden.delete(value);
else this._hidden.add(value);
for (const c of Array.from(this.querySelectorAll<HTMLElement>(`[data-column="${value}"]`))) c.hidden = !checked;
this._update();
};
/** Fill the shared drawer with one row's values and open it. */
_openDrawer(row: HTMLTableRowElement | null): void {
const drawer = this.querySelector('ui-drawer[data-row-drawer]') as Openable | null;
const id = this._rowId(row);
const r = this._all().find((x) => x.id === id);
if (!r || !drawer) return;
const edit = this._edits.get(r.id) ?? {};
const values: Record<string, string> = {
'drawer-header': r.header,
'drawer-type': r.type,
'drawer-status': r.status,
'drawer-target': edit.target ?? r.target,
'drawer-limit': edit.limit ?? r.limit,
'drawer-reviewer': edit.reviewer ?? (r.reviewer === 'Assign reviewer' ? '' : r.reviewer),
};
const title = drawer.querySelector('[data-drawer-title]');
if (title) title.textContent = r.header;
for (const [field, value] of Object.entries(values)) {
const el = drawer.querySelector<HTMLInputElement | HTMLSelectElement>(`#${field}`);
if (!el) continue;
el.value = value;
if (el instanceof HTMLSelectElement) el.dispatchEvent(new Event('change', { bubbles: true }));
}
drawer.open = true;
}
/** Move the row with id `id` to `index` in the full order and re-render. */
_move(id: number, index: number): void {
const all = this._all();
const from = all.findIndex((r) => r.id === id);
if (from < 0) return;
const to = Math.min(Math.max(0, index), all.length - 1);
if (from === to) return;
const [moved] = all.splice(from, 1);
all.splice(to, 0, moved);
this._update();
}
_onDragStart = (e: DragEvent): void => {
const handle = (e.target as Element).closest?.('[data-drag-handle]');
const row = handle?.closest('tr') as HTMLTableRowElement | null;
const id = this._rowId(row);
if (!row || id == null) return;
this._dragged = id;
row.dataset.dragging = 'true';
if (e.dataTransfer) {
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('text/plain', String(id));
e.dataTransfer.setDragImage(row, 16, 16);
}
};
// Rows move within the body only, the vertical-axis restriction shadcn sets.
_onDragOver = (e: DragEvent): void => {
const dragged = this._dragged;
const over = (e.target as Element).closest?.('tbody[data-rows] > tr[data-row-id]') as HTMLTableRowElement | null;
const overId = this._rowId(over);
if (dragged == null || !over || overId == null) return;
e.preventDefault();
if (overId === dragged) return;
const box = over.getBoundingClientRect();
const all = this._all();
const from = all.findIndex((r) => r.id === dragged);
let to = all.findIndex((r) => r.id === overId);
if (e.clientY > box.top + box.height / 2) to += 1;
if (from < to) to -= 1;
this._move(dragged, to);
};
_onDragEnd = (): void => {
const row = this._dragged == null ? null : this.querySelector<HTMLElement>(`tr[data-row-id="${this._dragged}"]`);
if (row) row.dataset.dragging = 'false';
this._dragged = null;
};
// The keyboard way to reorder: the arrow keys move the row whose handle has
// focus, as dnd-kit's keyboard sensor does, across pages too.
_onKeyDown = (e: KeyboardEvent): void => {
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;
const handle = (e.target as Element).closest?.('[data-drag-handle]') as HTMLElement | null;
const id = this._rowId(handle);
if (!handle || id == null) return;
e.preventDefault();
const index = this._all().findIndex((r) => r.id === id) + (e.key === 'ArrowUp' ? -1 : 1);
if (index < 0 || index >= this._all().length) return;
this._pageIndex = Math.floor(index / this._pageSize);
this._move(id, index);
this.querySelector<HTMLElement>(`tr[data-row-id="${id}"] [data-drag-handle]`)?.focus();
};
render() {
return html`<slot></slot>`;
}
}
Dashboard01DataTable.register('dashboard-01-data-table');
components/dashboard-data.ts
/**
* The dashboard-01 sample data: the outline sections the data table lists.
* Installed by `npx @webjsdev/ui add dashboard-01` at
* `components/dashboard-data.ts`. Replace it with your own rows, typically a
* query in a `'use server'` file whose result the page passes to
* `dataTable({ data })`. Ported from shadcn/ui's dashboard-01 data.json.
*/
/** One row of the table, shadcn's zod `schema` as a type. */
export interface DashboardRow {
id: number;
header: string;
type: string;
status: string;
target: string;
limit: string;
reviewer: string;
}
export const dashboardData: DashboardRow[] = [
{ id: 1, header: 'Cover page', type: 'Cover page', status: 'In Process', target: '18', limit: '5', reviewer: 'Eddie Lake' },
{ id: 2, header: 'Table of contents', type: 'Table of contents', status: 'Done', target: '29', limit: '24', reviewer: 'Eddie Lake' },
{ id: 3, header: 'Executive summary', type: 'Narrative', status: 'Done', target: '10', limit: '13', reviewer: 'Eddie Lake' },
{ id: 4, header: 'Technical approach', type: 'Narrative', status: 'Done', target: '27', limit: '23', reviewer: 'Jamik Tashpulatov' },
{ id: 5, header: 'Design', type: 'Narrative', status: 'In Process', target: '2', limit: '16', reviewer: 'Jamik Tashpulatov' },
{ id: 6, header: 'Capabilities', type: 'Narrative', status: 'In Process', target: '20', limit: '8', reviewer: 'Jamik Tashpulatov' },
{ id: 7, header: 'Integration with existing systems', type: 'Narrative', status: 'In Process', target: '19', limit: '21', reviewer: 'Jamik Tashpulatov' },
{ id: 8, header: 'Innovation and Advantages', type: 'Narrative', status: 'Done', target: '25', limit: '26', reviewer: 'Assign reviewer' },
{ id: 9, header: 'Overview of EMR\'s Innovative Solutions', type: 'Technical content', status: 'Done', target: '7', limit: '23', reviewer: 'Assign reviewer' },
{ id: 10, header: 'Advanced Algorithms and Machine Learning', type: 'Narrative', status: 'Done', target: '30', limit: '28', reviewer: 'Assign reviewer' },
{ id: 11, header: 'Adaptive Communication Protocols', type: 'Narrative', status: 'Done', target: '9', limit: '31', reviewer: 'Assign reviewer' },
{ id: 12, header: 'Advantages Over Current Technologies', type: 'Narrative', status: 'Done', target: '12', limit: '0', reviewer: 'Assign reviewer' },
{ id: 13, header: 'Past Performance', type: 'Narrative', status: 'Done', target: '22', limit: '33', reviewer: 'Assign reviewer' },
{ id: 14, header: 'Customer Feedback and Satisfaction Levels', type: 'Narrative', status: 'Done', target: '15', limit: '34', reviewer: 'Assign reviewer' },
{ id: 15, header: 'Implementation Challenges and Solutions', type: 'Narrative', status: 'Done', target: '3', limit: '35', reviewer: 'Assign reviewer' },
{ id: 16, header: 'Security Measures and Data Protection Policies', type: 'Narrative', status: 'In Process', target: '6', limit: '36', reviewer: 'Assign reviewer' },
{ id: 17, header: 'Scalability and Future Proofing', type: 'Narrative', status: 'Done', target: '4', limit: '37', reviewer: 'Assign reviewer' },
{ id: 18, header: 'Cost-Benefit Analysis', type: 'Plain language', status: 'Done', target: '14', limit: '38', reviewer: 'Assign reviewer' },
{ id: 19, header: 'User Training and Onboarding Experience', type: 'Narrative', status: 'Done', target: '17', limit: '39', reviewer: 'Assign reviewer' },
{ id: 20, header: 'Future Development Roadmap', type: 'Narrative', status: 'Done', target: '11', limit: '40', reviewer: 'Assign reviewer' },
{ id: 21, header: 'System Architecture Overview', type: 'Technical content', status: 'In Process', target: '24', limit: '18', reviewer: 'Maya Johnson' },
{ id: 22, header: 'Risk Management Plan', type: 'Narrative', status: 'Done', target: '15', limit: '22', reviewer: 'Carlos Rodriguez' },
{ id: 23, header: 'Compliance Documentation', type: 'Legal', status: 'In Process', target: '31', limit: '27', reviewer: 'Sarah Chen' },
{ id: 24, header: 'API Documentation', type: 'Technical content', status: 'Done', target: '8', limit: '12', reviewer: 'Raj Patel' },
{ id: 25, header: 'User Interface Mockups', type: 'Visual', status: 'In Process', target: '19', limit: '25', reviewer: 'Leila Ahmadi' },
{ id: 26, header: 'Database Schema', type: 'Technical content', status: 'Done', target: '22', limit: '20', reviewer: 'Thomas Wilson' },
{ id: 27, header: 'Testing Methodology', type: 'Technical content', status: 'In Process', target: '17', limit: '14', reviewer: 'Assign reviewer' },
{ id: 28, header: 'Deployment Strategy', type: 'Narrative', status: 'Done', target: '26', limit: '30', reviewer: 'Eddie Lake' },
{ id: 29, header: 'Budget Breakdown', type: 'Financial', status: 'In Process', target: '13', limit: '16', reviewer: 'Jamik Tashpulatov' },
{ id: 30, header: 'Market Analysis', type: 'Research', status: 'Done', target: '29', limit: '32', reviewer: 'Sophia Martinez' },
{ id: 31, header: 'Competitor Comparison', type: 'Research', status: 'In Process', target: '21', limit: '19', reviewer: 'Assign reviewer' },
{ id: 32, header: 'Maintenance Plan', type: 'Technical content', status: 'Done', target: '16', limit: '23', reviewer: 'Alex Thompson' },
{ id: 33, header: 'User Personas', type: 'Research', status: 'In Process', target: '27', limit: '24', reviewer: 'Nina Patel' },
{ id: 34, header: 'Accessibility Compliance', type: 'Legal', status: 'Done', target: '18', limit: '21', reviewer: 'Assign reviewer' },
{ id: 35, header: 'Performance Metrics', type: 'Technical content', status: 'In Process', target: '23', limit: '26', reviewer: 'David Kim' },
{ id: 36, header: 'Disaster Recovery Plan', type: 'Technical content', status: 'Done', target: '14', limit: '17', reviewer: 'Jamik Tashpulatov' },
{ id: 37, header: 'Third-party Integrations', type: 'Technical content', status: 'In Process', target: '25', limit: '28', reviewer: 'Eddie Lake' },
{ id: 38, header: 'User Feedback Summary', type: 'Research', status: 'Done', target: '20', limit: '15', reviewer: 'Assign reviewer' },
{ id: 39, header: 'Localization Strategy', type: 'Narrative', status: 'In Process', target: '12', limit: '19', reviewer: 'Maria Garcia' },
{ id: 40, header: 'Mobile Compatibility', type: 'Technical content', status: 'Done', target: '28', limit: '31', reviewer: 'James Wilson' },
{ id: 41, header: 'Data Migration Plan', type: 'Technical content', status: 'In Process', target: '19', limit: '22', reviewer: 'Assign reviewer' },
{ id: 42, header: 'Quality Assurance Protocols', type: 'Technical content', status: 'Done', target: '30', limit: '33', reviewer: 'Priya Singh' },
{ id: 43, header: 'Stakeholder Analysis', type: 'Research', status: 'In Process', target: '11', limit: '14', reviewer: 'Eddie Lake' },
{ id: 44, header: 'Environmental Impact Assessment', type: 'Research', status: 'Done', target: '24', limit: '27', reviewer: 'Assign reviewer' },
{ id: 45, header: 'Intellectual Property Rights', type: 'Legal', status: 'In Process', target: '17', limit: '20', reviewer: 'Sarah Johnson' },
{ id: 46, header: 'Customer Support Framework', type: 'Narrative', status: 'Done', target: '22', limit: '25', reviewer: 'Jamik Tashpulatov' },
{ id: 47, header: 'Version Control Strategy', type: 'Technical content', status: 'In Process', target: '15', limit: '18', reviewer: 'Assign reviewer' },
{ id: 48, header: 'Continuous Integration Pipeline', type: 'Technical content', status: 'Done', target: '26', limit: '29', reviewer: 'Michael Chen' },
{ id: 49, header: 'Regulatory Compliance', type: 'Legal', status: 'In Process', target: '13', limit: '16', reviewer: 'Assign reviewer' },
{ id: 50, header: 'User Authentication System', type: 'Technical content', status: 'Done', target: '28', limit: '31', reviewer: 'Eddie Lake' },
{ id: 51, header: 'Data Analytics Framework', type: 'Technical content', status: 'In Process', target: '21', limit: '24', reviewer: 'Jamik Tashpulatov' },
{ id: 52, header: 'Cloud Infrastructure', type: 'Technical content', status: 'Done', target: '16', limit: '19', reviewer: 'Assign reviewer' },
{ id: 53, header: 'Network Security Measures', type: 'Technical content', status: 'In Process', target: '29', limit: '32', reviewer: 'Lisa Wong' },
{ id: 54, header: 'Project Timeline', type: 'Planning', status: 'Done', target: '14', limit: '17', reviewer: 'Eddie Lake' },
{ id: 55, header: 'Resource Allocation', type: 'Planning', status: 'In Process', target: '27', limit: '30', reviewer: 'Assign reviewer' },
{ id: 56, header: 'Team Structure and Roles', type: 'Planning', status: 'Done', target: '20', limit: '23', reviewer: 'Jamik Tashpulatov' },
{ id: 57, header: 'Communication Protocols', type: 'Planning', status: 'In Process', target: '15', limit: '18', reviewer: 'Assign reviewer' },
{ id: 58, header: 'Success Metrics', type: 'Planning', status: 'Done', target: '30', limit: '33', reviewer: 'Eddie Lake' },
{ id: 59, header: 'Internationalization Support', type: 'Technical content', status: 'In Process', target: '23', limit: '26', reviewer: 'Jamik Tashpulatov' },
{ id: 60, header: 'Backup and Recovery Procedures', type: 'Technical content', status: 'Done', target: '18', limit: '21', reviewer: 'Assign reviewer' },
{ id: 61, header: 'Monitoring and Alerting System', type: 'Technical content', status: 'In Process', target: '25', limit: '28', reviewer: 'Daniel Park' },
{ id: 62, header: 'Code Review Guidelines', type: 'Technical content', status: 'Done', target: '12', limit: '15', reviewer: 'Eddie Lake' },
{ id: 63, header: 'Documentation Standards', type: 'Technical content', status: 'In Process', target: '27', limit: '30', reviewer: 'Jamik Tashpulatov' },
{ id: 64, header: 'Release Management Process', type: 'Planning', status: 'Done', target: '22', limit: '25', reviewer: 'Assign reviewer' },
{ id: 65, header: 'Feature Prioritization Matrix', type: 'Planning', status: 'In Process', target: '19', limit: '22', reviewer: 'Emma Davis' },
{ id: 66, header: 'Technical Debt Assessment', type: 'Technical content', status: 'Done', target: '24', limit: '27', reviewer: 'Eddie Lake' },
{ id: 67, header: 'Capacity Planning', type: 'Planning', status: 'In Process', target: '21', limit: '24', reviewer: 'Jamik Tashpulatov' },
{ id: 68, header: 'Service Level Agreements', type: 'Legal', status: 'Done', target: '26', limit: '29', reviewer: 'Assign reviewer' },
];
A dashboard with sidebar, charts and data table.
dashboard-01