testcasemaster-pro / components /test-case-item.js
ShadowWolf1999's picture
还可以继续优化一下吗? 比如点击一个view all 可以看到一些case示例?
289af61 verified
class TestCaseItem extends HTMLElement {
connectedCallback() {
const data = JSON.parse(this.getAttribute('data') || '{}');
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
margin-bottom: 1rem;
}
.test-case {
background-color: white;
border-radius: 0.5rem;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
padding: 1.5rem;
transition: all 0.2s;
}
.test-case:hover {
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.test-case-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}
.test-case-title {
font-size: 1.125rem;
font-weight: 600;
color: #2d3748;
margin: 0;
}
.test-case-id {
color: #718096;
font-size: 0.875rem;
}
.test-case-description {
color: #4a5568;
margin-bottom: 1rem;
}
.test-case-meta {
display: flex;
flex-wrap: wrap;
gap: 1rem;
margin-bottom: 1rem;
}
.meta-item {
display: flex;
align-items: center;
font-size: 0.875rem;
}
.meta-item i {
margin-right: 0.5rem;
color: #718096;
}
.status-badge {
padding: 0.25rem 0.5rem;
border-radius: 0.25rem;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
}
.status-passed {
background-color: #f0fff4;
color: #38a169;
}
.status-failed {
background-color: #fff5f5;
color: #e53e3e;
}
.status-warning {
background-color: #fffaf0;
color: #dd6b20;
}
.status-pending {
background-color: #ebf8ff;
color: #3182ce;
}
.test-case-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 1rem;
border-top: 1px solid #edf2f7;
}
.test-case-actions {
display: flex;
gap: 0.5rem;
}
.action-btn {
padding: 0.375rem 0.75rem;
border-radius: 0.25rem;
font-size: 0.875rem;
display: flex;
align-items: center;
}
.action-btn i {
margin-right: 0.25rem;
}
.view-btn {
background-color: #ebf8ff;
color: #3182ce;
}
.edit-btn {
background-color: #fffaf0;
color: #dd6b20;
}
.delete-btn {
background-color: #fff5f5;
color: #e53e3e;
}
</style>
<div class="test-case">
<div class="test-case-header">
<h3 class="test-case-title">${data.title}</h3>
<span class="test-case-id">TC-${data.id}</span>
</div>
<p class="test-case-description">${data.description}</p>
<div class="test-case-meta">
<div class="meta-item">
<i data-feather="alert-triangle"></i>
Priority: ${data.priority}
</div>
<div class="meta-item">
<i data-feather="tag"></i>
Type: ${data.type}
</div>
<div class="meta-item">
<i data-feather="clock"></i>
Last Run: ${data.lastRun}
</div>
</div>
<div class="test-case-footer">
<span class="status-badge status-${data.status.toLowerCase()}">
${data.status}
</span>
<div class="test-case-actions">
<a href="/test-case-detail.html?id=${data.id}" class="action-btn view-btn">
<i data-feather="eye"></i> View
</a>
<button class="action-btn edit-btn">
<i data-feather="edit"></i> Edit
</button>
<button class="action-btn delete-btn">
<i data-feather="trash"></i> Delete
</button>
</div>
</div>
</div>
`;
// Replace feather icons after component is rendered
setTimeout(() => {
if (window.feather) {
window.feather.replace({ class: 'feather-inline' });
}
}, 0);
}
}
customElements.define('test-case-item', TestCaseItem);