본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)7.8k · #13053

enhance-typescript-ui-components

하는 일

이 스킬은 썸네일, 배지, 데이터 기반 색상 같은 시각 기능을 TypeScript 컴포넌트에 추가하도록 AI 에이전트를 안내합니다. 목록 항목과 카드가 더 많은 정보를 보여 주기를 원하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓기존 목록 항목이나 카드에 배지나 라벨을 추가하고 싶을 때.
  • ✓이미지가 없을 때 자리표시자를 보여 주는 썸네일이 필요할 때.
  • ✓데이터에 따라 색상이나 스타일이 바뀌어야 할 때.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/enhance-typescript-ui-components/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/enhance-typescript-ui-components/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분.

작동 방식

에이전트는 TypeScript 파일 맨 위에 색 매핑과 크기 상수를 추가한 다음, 동적 색상과 변환을 위한 도우미 메서드를 씁니다. 그 뒤 새 시각 요소가 올바르게 보이도록 CSS를 업데이트합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Enhance TypeScript UI Components

A systematic workflow for adding visual enhancements to TypeScript UI components, including thumbnails, color-coded badges, and dynamic styling. This pattern applies to component files that render data items (lists, panels, cards, etc.).

When to Use This Skill

  • Adding visual indicators (badges, labels, icons) to existing components
  • Implementing thumbnail images with fallback placeholders
  • Applying dynamic, data-driven colors or styles
  • Coordinating TypeScript component logic with CSS styling

Workflow Steps

1. Add Constants at File Top

Define color mappings, size constants, and configuration data near the top of the TypeScript file, after imports but before the class definition.

// Color mappings for categories/sources
const SOURCE_COLORS: { [key: string]: string } = {
  'Category A': '#FF6B6B',
  'Category B': '#4ECDC4',
  'Category C': '#45B7D1',
  'default': '#95A5A6'
};

// Size constants
const THUMBNAIL_SIZE = 48; // pixels
const BADGE_HEIGHT = 20;

Why: Centralizes configuration for easy maintenance and avoids magic values scattered throughout code.

2. Implement Helper Methods

Create private helper methods for dynamic style calculations and data transformations. Place these before the main render method.

private getColorForItem(item: DataItem): string {
  return SOURCE_COLORS[item.category] || SOURCE_COLORS['default'];
}

private sortItemsByDate(items: DataItem[]): DataItem[] {
  return [...items].sort((a, b) => 
    new Date(b.date).getTime() - new Date(a.date).getTime()
  );
}

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

Why: Separates logic from presentation, makes code testable, and improves readability.

3. Sort Data Before Rendering

If displaying lists, apply sorting transformations before building HTML.

public render(): void {
  const sortedItems = this.sortItemsByDate(this.items);
  const html = sortedItems.map(item => this.renderItem(item)).join('');
  this.container.innerHTML = html;
}

Why: Ensures consistent presentation order and separates data transformation from rendering.

4. Build HTML with Template Literals

Use template literals for HTML construction with conditional rendering for optional fields.

private renderItem(item: DataItem): string {
  const itemColor = this.getColorForItem(item);
  const thumbnailUrl = this.getThumbnailUrl(item);
  
  return `
    <div class="item-card">
      ${item.imageUrl ? `
        <img 
          src="${thumbnailUrl}" 
          alt="${item.title}"
          class="item-thumbnail"
        />
      ` : `
        <div class="item-thumbnail-placeholder"></div>
      `}
      
      <div class="item-content">
        <h3>${item.title}</h3>
        ${item.category ? `
          <span 
            class="item-badge" 
            style="background-color: ${itemColor};"
          >
            ${item.category}
          </span>
        ` : ''}
        <p>${item.description}</p>
      </div>
    </div>
  `;
}

Why: Enables conditional rendering and keeps HTML structure clear. Dynamic values can be safely interpolated.

5. Apply Inline Styles for Dynamic Values Only

Use inline style attributes only for data-driven dynamic values (colors, sizes from data). Keep structural/layout styles in CSS.

// ✅ Good - dynamic color from data
style="background-color: ${this.getColorForItem(item)};"

// ❌ Bad - structural styling should be in CSS
style="display: flex; padding: 10px; background-color: ${color};"

// ✅ Better - split concerns
class="item-badge" style="background-color: ${color};"

Why: Maintains separation of concerns—data-driven values in TS, structural styles in CSS.

6. Create or Update Corresponding CSS

For each new HTML element or class added in TypeScript, add corresponding CSS rules. Focus on:

  • Layout and positioning
  • Static colors and backgrounds
  • Sizing (when not dynamic)
  • Spacing (margin, padding)
  • Typography
/* Component container */
.item-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #eee;
}

/* Thumbnail styles */
.item-thumbnail {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.item-thumbnail-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background-color: #e0e0
자주 묻는 질문

색상 설정은 어디에 두나요?

쉽게 바꿀 수 있도록 색상 매핑과 크기 상수를 파일 위쪽에 둔다고 스킬은 설명합니다.

이미지가 없으면 어떻게 되나요?

스킬은 썸네일을 위한 대체 자리표시자를 포함합니다.

CSS도 업데이트하나요?

네, 스킬은 TypeScript 변경과 맞는 CSS 업데이트를 함께 조율합니다.

상세 정보

작성자의 원본 설명

Add visual features (thumbnails, badges, dynamic styling) to TypeScript components by coordinating TypeScript logic changes with CSS updates

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#13053
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬