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

dynamic-panel-component

What it does

This skill guides the AI agent to build dashboard panel components in plain TypeScript, with no framework. It is for developers who want interactive panels that update and recover from errors.

When to use it

  • βœ“When you want dashboard panels built without React or another framework.
  • βœ“When panel content must update dynamically and recover from errors.
  • βœ“When panels need retry logic and clear state handling.

Skill link

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/dynamic-panel-component/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/dynamic-panel-component/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 in plain TypeScript that refreshes its content and retries when the data request fails.”

5 new skills a week. 1 minute to read.

How it works

The agent creates a Panel base class with a header, content area and resize handle. Each panel class extends it and updates its content, with retry logic and state tracking for loading and error states.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Dynamic Panel Component Pattern

Create dashboard panel components using vanilla TypeScript (no framework, no JSX). Each panel is a class extending a Panel base class, with enhanced dynamic content updates and error handling.

Architecture Overview

Panel (base class)
β”œβ”€β”€ element: HTMLElement (outer container, .panel)
β”‚   β”œβ”€β”€ header: HTMLElement (.panel-header)
β”‚   β”‚   β”œβ”€β”€ headerLeft (.panel-header-left)
β”‚   β”‚   β”‚   β”œβ”€β”€ title (.panel-title)
β”‚   β”‚   β”‚   └── newBadge (.panel-new-badge) [optional]
β”‚   β”‚   β”œβ”€β”€ statusBadge (.panel-data-badge) [optional]
β”‚   β”‚   └── countEl (.panel-count) [optional]
β”‚   β”œβ”€β”€ content: HTMLElement (.panel-content)
β”‚   └── resizeHandle (.panel-resize-handle)

Base Panel Class (Enhanced)

Create src/components/Panel.ts:

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

export class Panel {
  protected element: HTMLElement;
  protected content: HTMLElement;
  protected header: HTMLElement;
  protected countEl: HTMLElement | null = null;
  protected panelId: string;
  private _fetching = false;
  private _errorState = false;

  constructor(options: PanelOptions) {
    this.panelId = options.id;
    this.element = document.createElement('div');
    this.element.className = `panel ${options.className || ''}`;
    this.element.dataset.panel = options.id;

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

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

    const title = document.createElement('span');
    title.className = 'panel-title';
    title.textContent = options.title;
    headerLeft.appendChild(title);
    this.header.appendChild(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`;

    this.element.appendChild(this.header);
    this.element.appendChild(this.content);
    this.showLoading();
  }

  public getElement(): HTMLElement { return this.element; }

  public showLoading(message = 'Loading...'): void {
    this._errorState = false;
    this.content.innerHTML = `
     <div class="panel-loading">
        <div class="panel-loading-spinner"></div>
        <div class="panel-loading-text">${message}</div>
      </div>`;
  }

  public showError(message = 'Failed to load', onRetry?: () => void): void {
    this._errorState = true;
    this.content.innerHTML = `
      <div class="panel-error-state">
        <div class="panel-error-msg">${message}</div>
        ${onRetry ? '<button class="panel-retry-btn" data-panel-retry>Retry</button>' : ''}
      </div>`;
    if (onRetry) {
      this.content.querySelector('[data-panel-retry]')?.addEventListener('click', onRetry);
    }
  }

  public setContent(html: string): void {
    this._errorState = false;
    this.content.innerHTML = html;
  }

  public setCount(count: number): void {
    if (this.countEl) this.countEl.textContent = count.toString();
  }

  public show(): void { this.element.classList.remove('hidden'); }
  public hide(): void { this.element.classList.add('hidden'); }

  protected setFetching(v: boolean): void { this._fetching = v; }
  protected get isFetching(): boolean { return this._fetching; }
  protected get isErrorState(): boolean { return this._errorState; }

  public destroy(): void {
    this.element.remove();
  }
}

Creating a Concrete Panel (Example: StockPanel with Enhanced Error Handling)

import { Panel } from './Panel';

interface StockQuote {
  symbol: string;
  name: string;
  price: number | null;
  change: number | null;
  sparkline?: number[];
}

export class StockPanel extends Panel {
  private refreshTimer: ReturnType<typeof setInterval> | null = null;
  private retryCount = 0;
  private maxRetries = 3;

  constructor() {
    super({ id: 'stocks', title: 'Stock Market', showCount: true });
    this.fetchData();
    this.refreshTimer = setInterval(() => this.fetchData(), 60_000);
  }

  private async fetchData(): Promise<void> {
    if (this.isFetching || this.isErrorState) return;
    this.setFetching(true);
    try {
    
FAQ

Does this need a framework?

No, the skill uses the vanilla TypeScript DOM API with no framework or JSX.

What elements does the panel have?

It has a header with a title and optional badges, a content area and a resize handle.

How are errors handled?

The panel tracks an error state and retries failed requests with a limit.

Details

Original description by the author

Create a dashboard panel component with advanced dynamic content updates and robust error handling, including retry logic and state management, using vanilla TypeScript DOM API.

repo: HKUDS/AgentPilot

Popularity

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

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills