feat: collapsible area groups in machine list (30+ auto-collapsed)
All checks were successful
Deploy to Production / deploy (push) Successful in 1m7s

This commit is contained in:
Johngreen
2026-02-11 09:31:07 +09:00
parent bfd66703fd
commit b619355763
2 changed files with 34 additions and 4 deletions

View File

@@ -2459,6 +2459,22 @@ a {
font-weight: 400;
}
.machine-group-chevron {
font-size: 20px;
color: var(--md-on-surface-variant);
transition: transform 0.2s ease;
transform: rotate(-90deg);
margin-left: 4px;
}
.machine-group-chevron-open {
transform: rotate(0deg);
}
.machine-group-header:hover {
opacity: 0.85;
}
.machine-card-top {
display: flex;
justify-content: space-between;

View File

@@ -1,5 +1,6 @@
'use client';
import { useState, useCallback } from 'react';
import { useRouter } from 'next/navigation';
import type { Machine, Criticality } from '@/lib/types';
@@ -73,26 +74,39 @@ export function MachineList({ machines, tenantId, onEdit, onDelete, onBatchInspe
}
};
const [collapsed, setCollapsed] = useState<Record<string, boolean>>(() => {
const init: Record<string, boolean> = {};
Object.keys(groupedMachines).forEach(area => {
init[area] = groupedMachines[area].length > 30;
});
return init;
});
const toggleArea = useCallback((area: string) => {
setCollapsed(prev => ({ ...prev, [area]: !prev[area] }));
}, []);
return (
<div className="machine-list-container">
{sortedAreas.map(area => (
<div key={area} className="machine-group">
<div className="machine-group-header">
<div className="machine-group-header" onClick={() => toggleArea(area)} style={{ cursor: 'pointer' }}>
<h2 className="machine-group-title">
<span className="material-symbols-outlined">location_on</span>
{area} <span className="machine-count">({groupedMachines[area].length})</span>
<span className={`material-symbols-outlined machine-group-chevron ${collapsed[area] ? '' : 'machine-group-chevron-open'}`}>expand_more</span>
</h2>
{onBatchInspect && (
<button
className="btn-outline btn-sm"
onClick={() => onBatchInspect(area, groupedMachines[area].map(m => m.id))}
onClick={(e) => { e.stopPropagation(); onBatchInspect(area, groupedMachines[area].map(m => m.id)); }}
>
<span className="material-symbols-outlined">playlist_add_check</span>
</button>
)}
</div>
<div className="machine-grid">
{!collapsed[area] && <div className="machine-grid">
{groupedMachines[area].map((machine) => (
<div key={machine.id} className="machine-card">
<div
@@ -142,7 +156,7 @@ export function MachineList({ machines, tenantId, onEdit, onDelete, onBatchInspe
</div>
</div>
))}
</div>
</div>}
</div>
))}
{sortedAreas.length === 0 && (