enhance-typescript-ui-components
Skill này làm gì
Skill này hướng dẫn AI agent thêm các tính năng trực quan như ảnh thu nhỏ, huy hiệu và màu theo dữ liệu vào component TypeScript. Nó dành cho nhà phát triển muốn các mục danh sách và thẻ hiển thị thông tin rõ hơn.
Khi nào nên dùng
- ✓Khi bạn muốn thêm huy hiệu hoặc nhãn vào các mục danh sách hoặc thẻ hiện có.
- ✓Khi các mục cần ảnh thu nhỏ với ảnh giữ chỗ khi thiếu hình.
- ✓Khi màu sắc hoặc style nên thay đổi theo dữ liệu.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/enhance-typescript-ui-components/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thêm một huy hiệu danh mục có màu và một ảnh thu nhỏ cho mỗi mục trong danh sách tin tức của tôi, với ảnh giữ chỗ khi không có hình.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent thêm bảng màu và hằng số kích thước ở đầu file TypeScript, rồi viết các phương thức hỗ trợ cho màu động và biến đổi. Sau đó nó cập nhật CSS để các phần trực quan mới hiển thị đúng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Cài đặt màu được giữ ở đâu?
Skill đặt bảng ánh xạ màu và hằng số kích thước gần đầu file để dễ thay đổi.
Điều gì xảy ra nếu thiếu ảnh?
Skill có một ảnh giữ chỗ dự phòng cho ảnh thu nhỏ.
Nó có cập nhật CSS không?
Có, skill phối hợp các thay đổi TypeScript với cập nhật CSS tương ứng.
Chi tiết
Mô tả gốc của tác giả
Add visual features (thumbnails, badges, dynamic styling) to TypeScript components by coordinating TypeScript logic changes with CSS updates
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #13053
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.