मुख्य सामग्री पर जाएँ
Skillpedia
वेबसाइट और UI (frontend)7.8k · #13053

enhance-typescript-ui-components

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

यह स्किल AI एजेंट को TypeScript कंपोनेंट में थंबनेल, बैज और डेटा के अनुसार रंग जैसे दृश्य फ़ीचर जोड़ने का मार्गदर्शन देती है। यह उन डेवलपर्स के लिए है जो सूची आइटम और कार्ड को अधिक जानकारीपूर्ण दिखाना चाहते हैं।

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

  • ✓जब आप मौजूदा सूची आइटम या कार्ड में बैज या लेबल जोड़ना चाहते हों।
  • ✓जब आइटम में थंबनेल चाहिए और इमेज न होने पर प्लेसहोल्डर दिखे।
  • ✓जब रंग या स्टाइल डेटा के आधार पर बदलने चाहिए।

Skill का लिंक

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/enhance-typescript-ui-components/SKILL.md

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

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

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

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

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

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

“मेरी न्यूज़ सूची के हर आइटम में रंगीन श्रेणी बैज और थंबनेल जोड़िए। इमेज न हो तो प्लेसहोल्डर दिखाइए।”

हर हफ़्ते 5 नई skills, 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
अपडेट की गई
1/11/2026

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

0

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

कमेंट

  • …

इस repository की और skills

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