Skip to content

Commit bf2d198

Browse files
committed
MVP working
1 parent 5879f1e commit bf2d198

File tree

11 files changed

+415
-903
lines changed

11 files changed

+415
-903
lines changed

src/App.js

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,88 @@
11
import React from 'react';
22

33
import Character from './components/Character';
4-
import bodies from './components/Character/bodies';
54
import {
5+
numBodies,
6+
numHeads,
7+
numFaces,
8+
numAccessories,
69
skinColors,
710
clothesColors,
811
} from './components/Character/constants';
912

13+
const range = (n) => [...Array(n).keys()];
14+
1015
function App() {
1116
const [bodyIndex, setBodyIndex] = React.useState(0);
17+
const [headIndex, setHeadIndex] = React.useState(0);
18+
const [faceIndex, setFaceIndex] = React.useState(0);
19+
const [accessoryIndex, setAccessoryIndex] = React.useState(0);
1220
const [skinColor, setSkinColor] = React.useState(skinColors[0]);
1321
const [clothesColor, setClothesColor] = React.useState(
1422
clothesColors[0]
1523
);
1624

1725
return (
1826
<div>
19-
{bodies.map((_, index) => (
20-
<button key={index} onClick={() => setBodyIndex(index)}>
21-
Body {index + 1}
27+
<div>
28+
{range(numBodies).map((index) => (
29+
<button key={index} onClick={() => setBodyIndex(index)}>
30+
Body {index + 1}
31+
</button>
32+
))}
33+
</div>
34+
<div>
35+
{range(numHeads).map((index) => (
36+
<button key={index} onClick={() => setHeadIndex(index)}>
37+
Head {index + 1}
38+
</button>
39+
))}
40+
</div>
41+
<div>
42+
{range(numFaces).map((index) => (
43+
<button key={index} onClick={() => setFaceIndex(index)}>
44+
Face {index + 1}
45+
</button>
46+
))}
47+
</div>
48+
<div>
49+
<button onClick={() => setAccessoryIndex(-1)}>
50+
No Accessory
2251
</button>
23-
))}
52+
{range(numAccessories).map((index) => (
53+
<button
54+
key={index}
55+
onClick={() => setAccessoryIndex(index)}
56+
>
57+
Accessory {index + 1}
58+
</button>
59+
))}
60+
</div>
61+
<div>
62+
{clothesColors.map(({ label, color }) => (
63+
<button
64+
onClick={() => setClothesColor(color)}
65+
style={{ backgroundColor: color, width: 50, height: 50 }}
66+
>
67+
<span className="visually-hidden">{label}</span>
68+
</button>
69+
))}
70+
</div>
71+
<div>
72+
{skinColors.map(({ label, color }) => (
73+
<button
74+
onClick={() => setSkinColor(color)}
75+
style={{ backgroundColor: color, width: 50, height: 50 }}
76+
>
77+
<span className="visually-hidden">{label}</span>
78+
</button>
79+
))}
80+
</div>
2481
<Character
2582
bodyIndex={bodyIndex}
83+
headIndex={headIndex}
84+
faceIndex={faceIndex}
85+
accessoryIndex={accessoryIndex}
2686
skinColor={skinColor}
2787
clothesColor={clothesColor}
2888
/>

src/components/Character/CharacterSvg.js

Lines changed: 0 additions & 464 deletions
This file was deleted.

src/components/Character/bodies/01.jsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)