enhance-typescript-ui-components
できること
このスキルは、AIエージェントがサムネイル、バッジ、データに応じた色などの視覚的な機能を、TypeScriptのコンポーネントに追加するよう導きます。リストの項目やカードを、より情報的に見せたい開発者向けです。
使う場面
- ✓既存のリストの項目やカードに、バッジやラベルを追加したいとき。
- ✓画像がないときにプレースホルダーを表示する、サムネイルが必要な項目があるとき。
- ✓データに応じて、色やスタイルを変えたいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/enhance-typescript-ui-components/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
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
コメント
- …
このリポジトリの他のスキル
agentpilot
7.8kエージェントが、作業を準備し、変更案を提案してテストし、評価するAgentPilotのループを実行することで、プロジェクトを段階的に改善できるよう支援します。
openspace
7.8kエージェントが、スキルを保存し取り出すツールであるOpenSpaceをセットアップし、MCPを通じてAIアプリに接続できるよう支援します。
rsi-arena
7.8kエージェントが、AIMEやTerminal-Benchなどの標準的なAIベンチマークテストをセットアップして実行し、異なる改善方法を比較できるよう支援します。
experiment-guide
7.8kエージェントが、プログラムを改善する方法を調べる間に、小さな実験を計画し、その結果を読み、発見を記録できるよう支援します。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。