Skip to content
Skillpedia
Websites & UI (frontend)7.8k Β· #13062

panel-base-advanced

What it does

This skill shows the AI agent how to build a full dashboard panel base class in plain TypeScript. It is for developers who want panels with resize handles, saved layout, error countdowns and proper cleanup.

When to use it

  • βœ“When you want dashboard panels that remember their size and layout after a reload.
  • βœ“When a panel should show an error countdown and retry with exponential backoff.
  • βœ“When panels need a clean destroy step that removes timers and listeners.

Skill link

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/panel-base-advanced/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/panel-base-advanced/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œBuild a dashboard panel base class in TypeScript that remembers its size, shows a retry countdown on errors, and cleans up when removed.”

5 new skills a week. 1 minute to read.

How it works

The agent creates a Panel class with a header, content area and two resize handles. It saves layout to localStorage, retries failed fetches with growing delays, shows an error countdown, and clears timers in a destroy method.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Resilient Panel β€” Unified Pattern (v2)

Create dashboard panel components using vanilla TypeScript (no framework, no JSX). Each panel is a class extending a Panel base class and optionally wraps its data source with a CircuitBreaker.


Architecture Overview

Panel (base class)
β”œβ”€β”€ element: HTMLElement (.panel)
β”‚   β”œβ”€β”€ header: HTMLElement (.panel-header)
β”‚   β”‚   β”œβ”€β”€ headerLeft (.panel-header-left)
β”‚   β”‚   β”‚   β”œβ”€β”€ title (.panel-title)
β”‚   β”‚   β”‚   └── newBadge (.panel-new-badge) [optional, via setNewBadge()]
β”‚   β”‚   β”œβ”€β”€ statusBadge (.panel-data-badge) [optional, via setDataBadge()]
β”‚   β”‚   └── countEl (.panel-count) [optional]
β”‚   β”œβ”€β”€ content: HTMLElement (.panel-content)
β”‚   β”œβ”€β”€ resizeHandleRow (.panel-resize-handle-row)   [bottom edge]
β”‚   └── resizeHandleCol (.panel-resize-handle-col)   [right edge]

Resilience layers (choose what you need)

Layer File When to use
isFetching guard Panel base class Always β€” prevents concurrent duplicate requests
Exponential-backoff retry Panel.fetchWithRetry() When you own the fetch call and want per-request retry before surfacing an error
Error countdown in showError() Panel base class Automatic retry countdown rendered inside the error state UI
CircuitBreaker src/utils/circuit-breaker.ts When a service may fail repeatedly; stops hammering the API and serves stale cache instead
localStorage persistence Panel.saveMap() / loadMap() When you want grid-span (not pixel size) state to survive page reloads

Wrapping an existing service call with CircuitBreaker is a one-liner:

// Before
const data = await fetchStockQuotes();
// After β€” adds caching + cooldown with zero refactor
const data = await breaker.execute(() => fetchStockQuotes(), []);

File 1 β€” src/components/Panel.ts

Authoritative implementation. Use this verbatim; do not revert to the older saveState()/loadState() width/height approach.

export interface PanelOptions {
  id: string;
  title: string;
  showCount?: boolean;
  className?: string;
}

export class Panel {
  protected element: HTMLElement;
  protected content: HTMLElement;
  protected header: HTMLElement;
  protected headerLeft: HTMLElement;
  protected countEl: HTMLElement | null = null;
  protected statusBadge: HTMLElement | null = null;
  protected newBadge: HTMLElement | null = null;
  protected panelId: string;

  private _fetching = false;
  private _countdownInterval: ReturnType<typeof setInterval> | null = null;
  private _resizeListeners: Array<{ target: EventTarget; type: string; fn: EventListenerOrEventListenerObject }> = [];

  // Retry state (used by fetchWithRetry)
  protected retryAttempts = 0;
  protected retryDelay = 1000; // ms; doubles each attempt
  private maxRetries = 3;

  constructor(options: PanelOptions) {
    this.panelId = options.id;

    this.element = document.createElement('div');
    this.element.className = `panel${options.className ? ' ' + options.className : ''}`;
    this.element.dataset.panel = options.id;

    // Header
    this.header = document.createElement('div');
    this.header.className = 'panel-header';

    this.headerLeft = document.createElement('div');
    this.headerLeft.className = 'panel-header-left';

    const title = document.createElement('span');
    title.className = 'panel-title';
    title.textContent = options.title;
    this.headerLeft.appendChild(title);
    this.header.appendChild(this.headerLeft);

    // Count badge (optional)
    if (options.showCount) {
      this.countEl = document.createElement('span');
      this.countEl.className = 'panel-count';
      this.countEl.textContent = '0';
      this.header.appendChild(this.countEl);
    }

    // Content area
    this.content = document.createElement('div');
    this.content.className = 'panel-content';
    this.content.id = `${options.id}Content`;

    // Dual resize handles
    const resizeHandleRow = document.createElement('div');
    resizeHandleRow.className = 'panel-resize-handle-row';

    const resizeHandleCol = document.createElement('div');
    resizeHandleCol.className = 'panel-resize-handle-col';

    this.element.appendChild(this.header);
    this.element.appendChild(this.content);
    this.element.appendChild(resizeHandleRow);
    this.element.appendChild(resizeHandleCol);

    this._initResizeHandles(resizeHandleRow, resizeHandleCol);
    this.sh
FAQ

What does the destroy method do?

The skill says it cleans up timers and event handlers so removed panels do not keep running.

How does retry work?

The skill uses exponential backoff, so each retry waits longer than the one before.

Where is the layout saved?

The skill saves layout state in localStorage, which keeps it between page loads in that browser.

Details

Original description by the author

Unified guide for authoring dashboard panel components in vanilla TypeScript β€” covers the authoritative Panel base class (grid-span persistence, dual resize handles, radar loading animation, exponential-backoff error countdown, data/new badge helpers, full destroy() cleanup), localStorage state via loadMap/saveMap, exponential-backoff retry, and CircuitBreaker integration. Shows how to wrap any existing fetchX() service call with CircuitBreaker.execute() as a one-liner and clarifies when each resilience layer is appropriate.

repo: HKUDS/AgentPilot

Popularity

GitHub stars
7.8k
Ranking position
#13062
License
MIT
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills