본문으로 건너뛰기
Skillpedia
인터페이스 (UI/UX)7.8k · #13075

panel-visual-badges

하는 일

이 스킬은 대시보드 패널에 상태 배지, 작은 썸네일, 색으로 구분된 라벨 같은 시각적 요소를 더합니다. 재시도와 저장된 설정이 있는 패널 패턴 위에 만들어집니다. 한눈에 살펴볼 수 있는 데이터 대시보드를 만드는 사람을 위한 스킬입니다.

사용하는 경우

  • ✓대시보드 항목이 출처나 상태를 색 배지로 보여 주기를 원할 때.
  • ✓대시보드 목록의 항목 옆에 작은 썸네일을 두고 싶을 때.
  • ✓상태나 출처 같은 데이터에 따라 색이 바뀌기를 원할 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/panel-visual-badges/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 대시보드의 뉴스 패널에 색이 있는 상태 배지와 작은 썸네일을 추가해 주실 수 있나요?”

매주 새 스킬 5개. 읽는 데 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
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬