Skip to content

Commit 2accaa5

Browse files
authored
feat(ui): add select all button to category headers (#30)
1 parent fc74222 commit 2accaa5

1 file changed

Lines changed: 51 additions & 9 deletions

File tree

src/components/SoftwareSelector/CategorySection.jsx

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,80 @@
11
import { useState } from 'react';
22
import SoftwareCard from './SoftwareCard';
3+
import { useSelection } from '../../context/SelectionContext';
34

45
const CategorySection = ({ category, software }) => {
56
const [expanded, setExpanded] = useState(true);
7+
const { isAllCategorySelected, selectAllInCategory, deselectAllInCategory } = useSelection();
8+
9+
const allSelected = isAllCategorySelected(category.id);
10+
11+
const handleSelectAll = (e) => {
12+
e.stopPropagation();
13+
if (allSelected) {
14+
deselectAllInCategory(category.id);
15+
} else {
16+
selectAllInCategory(category.id);
17+
}
18+
};
619

720
return (
821
<section id={`category-${category.id}`} style={{ marginBottom: '16px' }}>
9-
<div className="win98-raised" style={{ padding: '8px', marginBottom: '8px' }}>
22+
<div className="win98-raised" style={{ padding: '6px', marginBottom: '8px', display: 'flex', gap: '6px', alignItems: 'stretch' }}>
1023
<button
1124
onClick={() => setExpanded(!expanded)}
1225
className="win98-button"
1326
style={{
14-
width: '100%',
15-
minHeight: '50px',
27+
flex: 1,
28+
minHeight: '52px',
1629
display: 'flex',
1730
alignItems: 'center',
18-
gap: '8px',
31+
gap: '10px',
1932
justifyContent: 'flex-start',
20-
padding: '8px 12px'
33+
padding: '8px 12px',
34+
textAlign: 'left'
2135
}}
2236
aria-expanded={expanded}
2337
aria-label={`${expanded ? 'Collapse' : 'Expand'} ${category.name} category`}
2438
>
2539
<span style={{ fontSize: '20px', flexShrink: 0 }}>{category.icon}</span>
26-
<div style={{ textAlign: 'left', flex: 1, overflow: 'hidden' }}>
27-
<div style={{ fontSize: '13px', fontWeight: 'bold', marginBottom: '3px', lineHeight: '1.2' }}>
40+
<div style={{ flex: 1, overflow: 'hidden' }}>
41+
<div style={{ fontSize: '13px', fontWeight: 'bold', marginBottom: '2px', lineHeight: '1.2' }}>
2842
{category.name}
43+
<span style={{ fontSize: '10px', marginLeft: '8px', verticalAlign: 'middle', fontWeight: 'normal', color: 'var(--win98-gray-dark)' }}>
44+
{expanded ? '▼' : '▶'}
45+
</span>
2946
</div>
3047
<div className="category-description" style={{ fontSize: '11px', fontWeight: 'normal', color: 'var(--win95-black)', lineHeight: '1.3' }}>
3148
{category.description}
3249
</div>
3350
</div>
34-
<span style={{ fontSize: '10px', marginLeft: 'auto', flexShrink: 0 }}>
35-
{expanded ? '▼' : '▶'}
51+
</button>
52+
53+
<button
54+
onClick={handleSelectAll}
55+
className={`win98-button ${allSelected ? 'win98-button-danger' : ''}`}
56+
style={{
57+
minWidth: '100px',
58+
minHeight: '52px',
59+
display: 'flex',
60+
flexDirection: 'column',
61+
alignItems: 'center',
62+
justifyContent: 'center',
63+
gap: '4px',
64+
padding: '4px 12px',
65+
flexShrink: 0
66+
}}
67+
title={allSelected ? "Deselect all items in this category" : "Select all items in this category"}
68+
>
69+
<input
70+
type="checkbox"
71+
checked={allSelected}
72+
readOnly
73+
className="win98-checkbox"
74+
style={{ pointerEvents: 'none', marginBottom: '2px' }}
75+
/>
76+
<span style={{ fontSize: '10px', fontWeight: 'bold', textTransform: 'uppercase', letterSpacing: '0.5px' }}>
77+
{allSelected ? 'Deselect All' : 'Select All'}
3678
</span>
3779
</button>
3880
</div>

0 commit comments

Comments
 (0)