मुख्य सामग्री पर जाएँ
Skillpedia
इंटरफ़ेस (UI/UX)7.8k · #13075

panel-visual-badges

यह क्या करती है

यह स्किल डैशबोर्ड पैनलों में दृश्य तत्व जोड़ती है, जैसे स्टेटस बैज, छोटे थंबनेल और रंग-कोडित लेबल। यह रीट्राई और सहेजी सेटिंग वाले पैनल पैटर्न पर बनती है। यह उन लोगों के लिए है जो ऐसे डेटा डैशबोर्ड बना रहे हैं जिन्हें जल्दी पढ़ा जा सके।

कब इस्तेमाल करें

  • ✓जब आप चाहते हैं कि डैशबोर्ड का कोई आइटम अपना स्रोत या स्टेटस रंगीन बैज से दिखाए।
  • ✓जब आप डैशबोर्ड सूची के आइटम के साथ छोटे थंबनेल दिखाना चाहते हैं।
  • ✓जब आप चाहते हैं कि रंग डेटा के आधार पर बदलें, जैसे स्टेटस या स्रोत के अनुसार।

Skill का लिंक

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

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/panel-visual-badges/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“क्या आप मेरे डैशबोर्ड के समाचार पैनल में रंगीन स्टेटस बैज और छोटे थंबनेल जोड़ सकते हैं?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

बैज के रंग और स्रोत की सेटिंग एक ही जगह रखी जाती हैं। पैनल उस डेटा को पढ़ता है और हर आइटम में बैज या इमेज जोड़ता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Robust UI Panel Components

Build visually rich, robust TypeScript UI components using a panel architecture pattern. This skill combines enhanced panel features (retry logic, state persistence) with a systematic workflow for adding visual enhancements (badges, thumbnails, dynamic styling).

Architecture Overview

Core Panel Features

  • Retry Logic: Automatically retries failed data fetches with exponential backoff.
  • State Persistence: Saves panel state (expanded/collapsed, size) to localStorage.
  • Detailed Error Handling: Provides granular error messages and recovery options.
  • Visual Enhancements: Systematic approach for adding badges, thumbnails, and dynamic styling.
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)

Implementation Workflow

1. Define Constants and Configuration

// Panel configuration
const PANEL_DEFAULTS = {
  maxRetries: 3,
  initialRetryDelay: 1000, // 1s
};

// Visual configuration
const SOURCE_COLORS: { [key: string]: string } = {
  'Category A': '#FF6B6B',
  'Category B': '#4ECDC4',
  'default': '#95A5A6'
};

const THUMBNAIL_SIZE = 48; // pixels

2. Base Panel Class with Enhanced Features

export class Panel {
  protected element: HTMLElement;
  protected content: HTMLElement;
  protected panelId: string;
  private retryAttempts = 0;
  private retryDelay = PANEL_DEFAULTS.initialRetryDelay;

  constructor(options: PanelOptions) {
    // ... existing constructor code ...
    this.loadState();
  }

  protected async fetchWithRetry(url: string):<any> {
    while (this.retryAttempts < PANEL_DEFAULTS.maxRetries) {
      try {
        const response = await fetch(url);
        if (!response.ok) throw new Error(`HTTP ${response.status}`);
        return await response.json();
      } catch (error) {
        this.retryAttempts++;
        if (this.retryAttempts >= PANEL_DEFAULTS.maxRetries) {
          throw new Error(`Failed after ${PANEL_DEFAULTS.maxRetries} attempts: ${error.message}`);
        }
        await new Promise(resolve => setTimeout(resolve, this.retryDelay));
        this.retryDelay *= 2;
      }
    }
  }

  public saveState(): void {
    localStorage.setItem(`panelState_${this.panelId}`, JSON.stringify({
      isExpanded: !this.element.classList.contains('collapsed'),
      width: this.element.style.width,
      height: this.element.style.height
    }));
  }

  public loadState(): void {
    const savedState = localStorage.getItem(`panelState_${this.panelId}`);
    if (savedState) {
      const { isExpanded, width, height } = JSON.parse(savedState);
      if (!isExpanded) this.element.classList.add('collapsed');
      if (width) this.element.style.width = width;
      if (height) this.element.style.height = height;
    }
  }

  // Visual enhancement helpers
  protected getColorForSource(source: string): string {
    return SOURCE_COLORS[source] || SOURCE_COLORS['default'];
  }

  protected getThumbnailUrl(imageUrl?: string): string {
    return imageUrl || `https://via.placeholder.com/${THUMBNAIL_SIZE}`;
  }
}

3. Creating Enhanced Components

export class NewsPanel extends Panel {
  private refreshTimer: ReturnType<typeof setInterval> | null = null;

  constructor() {
    super({ id: 'news', title: 'News Feed', showCount: true });
    this.fetchData();
    this.refreshTimer = setInterval(() => this.fetchData(), 60_000);
  }

  private async fetchData(): Promise<void> {
    try {
      const newsItems = await this.fetchWithRetry('/api/news');
      this.render(newsItems);
      this.setCount(newsItems.length);
      this.saveState();
    } catch (err) {
      this.showError(`Failed to load news: ${err.message}`, () => {
        this.retryAttempts = 0;
        this.retryDelay = PANEL_DEFAULTS.initialRetryDelay;
        this.fetchData();
      });
    }
  }

  private render(items: NewsItem[]): void {
    const html = items.map(item => `
      <div class="news-item">
        <img src="${this.getThumbnailUrl(item.imageUrl)}" class="news-thumbnail">
        <div class="news-content">
          <h3>${item.tit
अक्सर पूछे जाने वाले सवाल

बैज के रंग कहां तय करें?

रंग एक ही कॉन्फ़िगरेशन ऑब्जेक्ट में सूचीबद्ध हैं, इसलिए आप उन्हें वहीं बदल सकते हैं।

क्या इसके लिए रीट्राई और सेटिंग वाला पैटर्न चाहिए?

बैज अकेले भी काम करते हैं, पर यह स्किल रीट्राई और सहेजी सेटिंग वाले पैनल पैटर्न पर बनने के लिए लिखी गई है।

क्या आप अपने बैज प्रकार जोड़ सकते हैं?

हां। कॉन्फ़िगरेशन में नई प्रविष्टि जोड़िए और फिर उसे पैनल में इस्तेमाल कीजिए।

जानकारी

लेखक का मूल विवरण

Create visually rich, robust TypeScript UI components with panel architecture, combining enhanced features like retry logic, state persistence, and dynamic styling with a systematic workflow for visual enhancements.

repo: HKUDS/AgentPilot

लोकप्रियता

GitHub स्टार
7.8k
रैंकिंग में स्थान
#13075
लाइसेंस
MIT
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills