Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | 14x 14x 14x 14x 14x 1x 13x 24x 24x 14x 2x 12x 24x 8x 8x 1x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 6x 5x 5x 9x 5x 6x 5x 5x 9x 5x 6x 5x 5x 14x 5x 6x 5x 6x 14x 14x | import { escapeHtml } from './utils.js';
/**
* Generates HTML for a status badge based on skill status
*
* @param {string} status - The skill status (installed, catalog, user-created, etc.)
* @returns {string} - HTML for the status badge
*/
function getStatusBadge(status) {
const normalized = status || 'unknown';
const badgeClass = `status-badge status-${normalized}`;
const label = normalized.charAt(0).toUpperCase() + normalized.slice(1);
return `<span class="${badgeClass}">${escapeHtml(label)}</span>`;
}
/**
* Generates HTML for IDE compatibility badges
*
* @param {Array<string>} ides - Array of IDE identifiers
* @returns {string} - HTML for IDE badges
*/
function renderIdeBadges(ides) {
if (!Array.isArray(ides) || ides.length === 0) {
return '<span class="ide-badge">All IDEs</span>';
}
return ides.map(ide => {
const label = ide.charAt(0).toUpperCase() + ide.slice(1).replace(/-/g, ' ');
return `<span class="ide-badge">${escapeHtml(label)}</span>`;
}).join('');
}
/**
* Generates HTML for domain/tag badges
*
* @param {Array<string>} domains - Array of domain or tag strings
* @returns {string} - HTML for domain badges
*/
function renderDomainTags(domains) {
if (!Array.isArray(domains) || domains.length === 0) {
return '<span class="domain-tag">None</span>';
}
return domains.map(domain => {
return `<span class="domain-tag">${escapeHtml(domain)}</span>`;
}).join('');
}
/**
* Truncates description to a specified length with ellipsis
*
* @param {string} description - The full description
* @param {number} maxLength - Maximum length before truncation
* @returns {string} - Truncated or full description
*/
function truncateDescription(description, maxLength = 150) {
Iif (!description) return '';
if (description.length <= maxLength) return description;
return description.slice(0, maxLength) + '...';
}
/**
* Renders a skill card as HTML
*
* Card has two modes:
* - Minimal (expanded=false): header, truncated description, IDE badges, domain tags
* - Expanded (expanded=true): full description, provides/requires sections, tags cloud, repo link, toggle button
*
* @param {Object} skill - The skill object to render
* @param {boolean} expanded - Whether to show expanded view
* @returns {string} - HTML string for the skill card
*
* @example
* renderSkillCard({ id: 'node-api', name: 'Node API', ... }, false)
* // Returns: <div class="skill-card" data-id="node-api" ...>...</div>
*/
export function renderSkillCard(skill, expanded = false) {
Iif (!skill || typeof skill !== 'object') {
return '';
}
const {
id = '',
name = '',
displayName,
description = '',
status = 'unknown',
ideCompatibility = [],
domains = [],
tags = [],
provides = [],
requires = [],
repoUrl = ''
} = skill;
const safeId = escapeHtml(id);
const safeName = escapeHtml(displayName || name);
const safeDescription = escapeHtml(description);
const safeStatus = escapeHtml(status);
const safeRepoUrl = escapeHtml(repoUrl);
// Determine first IDE for data-ide attribute
const firstIde = Array.isArray(ideCompatibility) && ideCompatibility.length > 0
? ideCompatibility[0]
: 'all';
const safeFirstIde = escapeHtml(firstIde);
// Start card container
let html = `<div class="skill-card" data-id="${safeId}" data-status="${safeStatus}" data-ide="${safeFirstIde}">`;
// Header: name + status badge
html += `<div class="card-header">
<h3 class="skill-name">${safeName}</h3>
${getStatusBadge(status)}
</div>`;
// Description (truncated for minimal, full for expanded)
const displayDescription = expanded ? safeDescription : truncateDescription(safeDescription);
html += `<div class="description">${displayDescription}</div>`;
// Metadata section (shown in minimal, hidden in expanded via CSS)
html += `<div class="metadata">
<div class="meta-section">
<span class="meta-label">IDE:</span>
${renderIdeBadges(ideCompatibility)}
</div>
<div class="meta-section">
<span class="meta-label">Domains:</span>
${renderDomainTags(domains)}
</div>
</div>`;
// Expanded sections (only shown when expanded=true)
if (expanded) {
// Provides section
if (Array.isArray(provides) && provides.length > 0) {
html += `<div class="provides-section">
<h4>Provides</h4>
<ul>`;
provides.forEach(provide => {
html += `<li>${escapeHtml(provide)}</li>`;
});
html += `</ul>
</div>`;
}
// Requires section
if (Array.isArray(requires) && requires.length > 0) {
html += `<div class="requires-section">
<h4>Requires</h4>
<ul>`;
requires.forEach(require => {
html += `<li>${escapeHtml(require)}</li>`;
});
html += `</ul>
</div>`;
}
// Tags cloud
if (Array.isArray(tags) && tags.length > 0) {
html += `<div class="tags-section">
<h4>Tags</h4>
<div class="tags">`;
tags.forEach(tag => {
html += `<span class="tag">${escapeHtml(tag)}</span>`;
});
html += `</div>
</div>`;
}
// Repository link
if (repoUrl) {
html += `<div class="repo-section">
<a href="${safeRepoUrl}" target="_blank" rel="noopener noreferrer" class="repo-link">
View Repository
</a>
</div>`;
}
// Toggle button
html += `<button class="toggle-btn" onclick="toggleCard('${safeId}')">Show less</button>`;
}
html += `</div>`;
return html;
}
|