code cleanup
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
---
|
||||
// src/components/ToolCard.astro (Updated)
|
||||
import ContributionButton from './ContributionButton.astro';
|
||||
// src/components/ToolCard.astro (ENHANCED - Added data attributes for filtering)
|
||||
import ShareButton from './ShareButton.astro';
|
||||
|
||||
export interface Props {
|
||||
@@ -43,9 +42,27 @@ const cardClass = isConcept ? 'card card-concept tool-card' :
|
||||
isMethod ? 'card card-method tool-card' :
|
||||
hasValidProjectUrl ? 'card card-hosted tool-card' :
|
||||
(tool.license !== 'Proprietary' ? 'card card-oss tool-card' : 'card tool-card');
|
||||
|
||||
// ENHANCED: Data attributes for filtering
|
||||
const toolDataAttributes = {
|
||||
'data-tool-name': tool.name.toLowerCase(),
|
||||
'data-tool-type': tool.type,
|
||||
'data-tool-domains': (tool.domains || []).join(','),
|
||||
'data-tool-phases': (tool.phases || []).join(','),
|
||||
'data-tool-tags': (tool.tags || []).join(',').toLowerCase(),
|
||||
'data-tool-platforms': (tool.platforms || []).join(','),
|
||||
'data-tool-license': tool.license || '',
|
||||
'data-tool-skill': tool.skillLevel,
|
||||
'data-tool-description': tool.description.toLowerCase()
|
||||
};
|
||||
---
|
||||
|
||||
<div class={cardClass} onclick={`window.showToolDetails('${tool.name}')`} style="cursor: pointer; border-left: 4px solid {isMethod ? 'var(--color-method)' : hasValidProjectUrl ? 'var(--color-hosted)' : tool.license !== 'Proprietary' ? 'var(--color-oss)' : 'var(--color-border)'};">
|
||||
<div
|
||||
class={cardClass}
|
||||
{...toolDataAttributes}
|
||||
style="cursor: pointer;"
|
||||
onclick={`window.showToolDetails('${tool.name}')`}
|
||||
>
|
||||
<!-- Card Header with Fixed Height -->
|
||||
<div class="tool-card-header">
|
||||
<h3>
|
||||
@@ -94,7 +111,7 @@ const cardClass = isConcept ? 'card card-concept tool-card' :
|
||||
<polyline points="14 2 14 8 20 8"></polyline>
|
||||
</svg>
|
||||
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;">
|
||||
{isMethod ? 'Methode' : tool.license === 'Proprietary' ? 'Prop.' : tool.license?.split(' ')[0]}
|
||||
{isConcept ? 'Konzept' : isMethod ? 'Methode' : tool.license === 'Proprietary' ? 'Prop.' : tool.license?.split(' ')[0]}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -106,45 +123,29 @@ const cardClass = isConcept ? 'card card-concept tool-card' :
|
||||
))}
|
||||
</div>
|
||||
|
||||
<!-- Buttons - Fixed at Bottom with Contribution Button -->
|
||||
<!-- Buttons - Fixed at Bottom (NO EDIT BUTTONS - Available in modals) -->
|
||||
<div class="tool-card-buttons" onclick="event.stopPropagation();">
|
||||
{isConcept ? (
|
||||
<!-- Concept buttons with edit -->
|
||||
<div class="button-row">
|
||||
<a href={tool.url} target="_blank" rel="noopener noreferrer" class="btn btn-primary" style="background-color: var(--color-concept); border-color: var(--color-concept); flex: 2;">
|
||||
Mehr erfahren
|
||||
</a>
|
||||
<ContributionButton type="edit" toolName={tool.name} variant="secondary" text="Edit" style="flex: 1; font-size: 0.75rem;" />
|
||||
</div>
|
||||
<a href={tool.url} target="_blank" rel="noopener noreferrer" class="btn btn-primary single-button" style="background-color: var(--color-concept); border-color: var(--color-concept);">
|
||||
Mehr erfahren
|
||||
</a>
|
||||
) : isMethod ? (
|
||||
<!-- Method buttons with edit -->
|
||||
<div class="button-row">
|
||||
<a href={tool.projectUrl || tool.url} target="_blank" rel="noopener noreferrer" class="btn btn-primary" style="background-color: var(--color-method); border-color: var(--color-method); flex: 2;">
|
||||
Zur Methode
|
||||
</a>
|
||||
<ContributionButton type="edit" toolName={tool.name} variant="secondary" text="Edit" style="flex: 1; font-size: 0.75rem;" />
|
||||
</div>
|
||||
<a href={tool.projectUrl || tool.url} target="_blank" rel="noopener noreferrer" class="btn btn-primary single-button" style="background-color: var(--color-method); border-color: var(--color-method);">
|
||||
Zur Methode
|
||||
</a>
|
||||
) : hasValidProjectUrl ? (
|
||||
<!-- Three buttons for hosted tools -->
|
||||
<div style="display: flex; flex-direction: column; gap: 0.5rem;">
|
||||
<div class="button-row">
|
||||
<a href={tool.url} target="_blank" rel="noopener noreferrer" class="btn btn-secondary">
|
||||
Homepage
|
||||
</a>
|
||||
<a href={tool.projectUrl} target="_blank" rel="noopener noreferrer" class="btn btn-primary">
|
||||
Zugreifen
|
||||
</a>
|
||||
</div>
|
||||
<ContributionButton type="edit" toolName={tool.name} variant="secondary" text="Edit Entry" className="single-button" />
|
||||
<div class="button-row">
|
||||
<a href={tool.url} target="_blank" rel="noopener noreferrer" class="btn btn-secondary">
|
||||
Homepage
|
||||
</a>
|
||||
<a href={tool.projectUrl} target="_blank" rel="noopener noreferrer" class="btn btn-primary">
|
||||
Zugreifen
|
||||
</a>
|
||||
</div>
|
||||
) : (
|
||||
<!-- Two buttons for external tools -->
|
||||
<div class="button-row">
|
||||
<a href={tool.url} target="_blank" rel="noopener noreferrer" class="btn btn-primary" style="flex: 2;">
|
||||
Software-Homepage
|
||||
</a>
|
||||
<ContributionButton type="edit" toolName={tool.name} variant="secondary" text="Edit" style="flex: 1; font-size: 0.75rem;" />
|
||||
</div>
|
||||
<a href={tool.url} target="_blank" rel="noopener noreferrer" class="btn btn-primary single-button">
|
||||
Software-Homepage
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,11 +1,9 @@
|
||||
---
|
||||
import { getToolsData } from '../utils/dataService.js';
|
||||
|
||||
|
||||
// Load tools data
|
||||
const data = await getToolsData();
|
||||
|
||||
|
||||
const domains = data.domains;
|
||||
const phases = data.phases;
|
||||
|
||||
@@ -106,7 +104,6 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
</div>
|
||||
|
||||
<!-- View Toggle -->
|
||||
<!--<div style="display: flex; gap: 1rem; margin-bottom: 1.5rem; align-items: center; flex-wrap: wrap;">-->
|
||||
<div style="display: flex; gap: 1rem; margin-bottom: 1.5rem; align-items: center;">
|
||||
<button class="btn btn-secondary view-toggle active" style="height:50px" data-view="grid">Kachelansicht</button>
|
||||
<button class="btn btn-secondary view-toggle" style="height:50px" data-view="matrix">Matrix-Ansicht</button>
|
||||
@@ -127,7 +124,6 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script define:vars={{ toolsData: data.tools, tagFrequency, sortedTags }}>
|
||||
// Store tools data globally for filtering
|
||||
window.toolsData = toolsData;
|
||||
@@ -286,7 +282,7 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
}
|
||||
}
|
||||
|
||||
// Filter function
|
||||
// ENHANCED: Filter function with better performance for show/hide pattern
|
||||
function filterTools() {
|
||||
const searchTerm = searchInput.value.toLowerCase();
|
||||
const selectedDomain = domainSelect.value;
|
||||
@@ -298,7 +294,7 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
const phases = tool.phases || [];
|
||||
const tags = tool.tags || [];
|
||||
|
||||
// Search filter
|
||||
// Search filter - more comprehensive
|
||||
if (searchTerm && !(
|
||||
tool.name.toLowerCase().includes(searchTerm) ||
|
||||
tool.description.toLowerCase().includes(searchTerm) ||
|
||||
@@ -317,12 +313,12 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Proprietary filter (skip for methods since they don't have licenses)
|
||||
if (!includeProprietary && !isMethod(tool) && tool.license === 'Proprietary') {
|
||||
// Proprietary filter (skip for methods and concepts since they don't have licenses)
|
||||
if (!includeProprietary && !isMethod(tool) && tool.type !== 'concept' && tool.license === 'Proprietary') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Tag filter
|
||||
// Tag filter - ensure all selected tags are present
|
||||
if (selectedTags.size > 0 && !Array.from(selectedTags).every(tag => tags.includes(tag))) {
|
||||
return false;
|
||||
}
|
||||
@@ -332,6 +328,7 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
|
||||
// Update matrix highlighting
|
||||
updateMatrixHighlighting();
|
||||
|
||||
// Emit custom event with filtered results
|
||||
window.dispatchEvent(new CustomEvent('toolsFiltered', { detail: filtered }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user