-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpellList.jsx
42 lines (39 loc) · 1.14 KB
/
SpellList.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from "react";
import Spell from './Spell';
import { DSAGrid, DSAGridRow, DSAGridItem} from '../controls/DSAGrid';
import DSAInfoBox from '../controls/DSAInfoBox';
function SpellListMetaInfo(num_spells) {
const text = <span> Es wurden <strong>{num_spells + " Zauber"}</strong> gefunden </span>
return (
<DSAInfoBox text={text} />
);
}
function createSpell(spell, id, favoriteSpells, onFavoriteChange) {
const {name, spellclass, properties, spellextensions} = spell;
return (
<DSAGridItem xs={12} sm={6} md={4} lg={4} key={id}>
<Spell
name={name}
spellclass={spellclass}
properties={properties}
extensions={spellextensions}
onUserInput={onFavoriteChange}
favorites={favoriteSpells}
/>
</DSAGridItem>
);
}
export default function SpellList(props) {
const {onFavoriteChange, favoriteSpells} = props;
const spells = props.spells.map((s, id) => {
return createSpell(s, id, favoriteSpells, onFavoriteChange);
})
return (
<DSAGrid>
<DSAGridRow>
{SpellListMetaInfo(props.spells.length)}
</DSAGridRow>
{spells}
</DSAGrid>
);
}