Skip to content

Commit 101eb8d

Browse files
Merge pull request #117 from NourAlSalhi/feat/group-astronauts-by-craft
Style Astronauts List with Craft Grouping in Space.jsx #5
2 parents 7d6f2cc + fc5c5e4 commit 101eb8d

File tree

1 file changed

+21
-39
lines changed

1 file changed

+21
-39
lines changed

src/pages/Space.jsx

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ useEffect(() => {
9292
const listBg = isDark ? '#334155' : '#f1f5f9';
9393
const borderColor = isDark ? '#334155' : '#e2e8f0';
9494

95+
const groupedCrew = crew.reduce((acc, p) => {
96+
if (!acc[p.craft]) acc[p.craft] = [];
97+
acc[p.craft].push(p);
98+
return acc;
99+
}, {});
100+
95101
return (
96102
<>
97103
<HeroSection
@@ -205,47 +211,23 @@ useEffect(() => {
205211
border: `1px solid ${borderColor}`,
206212
}}
207213
>
208-
<ul style={{
209-
paddingLeft: '0',
210-
listStyleType: 'none',
211-
margin: '0',
212-
display: 'flex',
213-
flexDirection: 'column',
214-
gap: '0.5rem'
215-
}}>
216-
{crew.map((p) => (
217-
<li
218-
key={p.name}
219-
style={{
220-
backgroundColor: listBg,
221-
padding: '0.75rem 1rem',
222-
borderRadius: '8px',
223-
display: 'flex',
224-
justifyContent: 'space-between',
225-
alignItems: 'center',
226-
transition: 'all 0.3s ease',
227-
border: `1px solid ${borderColor}`,
228-
}}
229-
>
230-
<span style={{
231-
fontWeight: '500',
232-
color: textColor
233-
}}>
234-
{p.name}
235-
</span>
236-
<span style={{
237-
fontSize: '0.9rem',
238-
color: subText,
239-
backgroundColor: isDark ? '#475569' : '#e2e8f0',
240-
padding: '0.25rem 0.75rem',
241-
borderRadius: '6px',
242-
fontWeight: '500'
243-
}}>
244-
🚀 {p.craft}
245-
</span>
214+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
215+
{Object.entries(groupedCrew).map(([craft, members]) => (
216+
<div key={craft} style={{ border: `1px solid ${borderColor}`, borderRadius: '8px', padding: '1rem', backgroundColor: listBg }}>
217+
<h3 style={{ fontWeight: '600', marginBottom: '0.5rem', color: accent }}>
218+
🚀 {craft} ({members.length})
219+
</h3>
220+
<ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
221+
{members.map((p) => (
222+
<li key={p.name} style={{ display: 'flex', justifyContent: 'space-between', padding: '0.5rem 0.75rem', borderRadius: '6px', backgroundColor: isDark ? '#475569' : '#e2e8f0' }}>
223+
<span style={{ fontWeight: '500', color: textColor }}>{p.name}</span>
246224
</li>
247225
))}
248-
</ul>
226+
</ul>
227+
</div>
228+
))}
229+
</div>
230+
249231
</Card>
250232
</div>
251233

0 commit comments

Comments
 (0)