Skip to content

Commit cf5928e

Browse files
committed
feat: add new option hat
1 parent 15e4be2 commit cf5928e

File tree

10 files changed

+137
-66
lines changed

10 files changed

+137
-66
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ The options can be passed into genConfig or as React props
6868
| `faceColor` | string | | | |
6969
| `earSize` | string | | small, big | |
7070
| `hairColor` | string | | | |
71-
| `hairStyle` | string | | normal, thick, mohawk, womanLong, womanShort, beanie | |
71+
| `hairStyle` | string | | normal, thick, mohawk, womanLong, womanShort | |
7272
| `hairColorRandom` | boolean | false | | thick,mohawk default only be black |
73+
| `hatColor` | string | | | |
74+
| `hatStyle` | string | | none, beanie, turban | Usually is none |
7375
| `eyeStyle` | string | | circle, oval, smile | |
7476
| `glassesStyle` | string | | none, round, square | Usually is none |
7577
| `noseStyle` | string | | short, long, round | |

demo/Single.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default class Single extends Component {
1717
size: 25, // rem
1818
faceColorPanelOpen: false,
1919
hairColorPanelOpen: false,
20+
hatColorPanelOpen: false,
2021
shirtColorPanelOpen: false,
2122
bgColorPanelOpen: false
2223
};
@@ -59,6 +60,7 @@ export default class Single extends Component {
5960
closeAllColorPanel() {
6061
this.setState({
6162
hairColorPanelOpen: false,
63+
hatColorPanelOpen: false,
6264
faceColorPanelOpen: false,
6365
shirtColorPanelOpen: false,
6466
bgColorPanelOpen: false
@@ -104,6 +106,7 @@ export default class Single extends Component {
104106
bgShape,
105107
faceColorPanelOpen,
106108
hairColorPanelOpen,
109+
hatColorPanelOpen,
107110
shirtColorPanelOpen,
108111
bgColorPanelOpen
109112
} = this.state;
@@ -225,14 +228,37 @@ export default class Single extends Component {
225228
onClick={this.updateConfig.bind(this, "hairStyle", "womanShort")}>
226229
Woman Short
227230
</p>
231+
</div>
232+
233+
{/* Hat */}
234+
<div className="field">
235+
<p>Hat</p>
236+
<div className="colorPanelWrapper" onClick={(e) => e.nativeEvent.stopImmediatePropagation()}>
237+
<i
238+
className="iconfont icon-color"
239+
onClick={this.toggleColorPanel.bind(this, "hatColorPanelOpen")} />
240+
{hatColorPanelOpen &&
241+
<ChromePicker
242+
className="colorPanel"
243+
color={config.hatColor}
244+
onChange={this.onChangeColor.bind(this, "hatColor")} />
245+
}
246+
</div>
247+
</div>
248+
<div className="opts">
249+
<p
250+
className={classnames("opt", { active: config.hatStyle === "none" })}
251+
onClick={this.updateConfig.bind(this, "hatStyle", "none")}>
252+
None
253+
</p>
228254
<p
229-
className={classnames("opt", { active: config.hairStyle === "turban" })}
230-
onClick={this.updateConfig.bind(this, "hairStyle", "turban")}>
255+
className={classnames("opt", { active: config.hatStyle === "turban" })}
256+
onClick={this.updateConfig.bind(this, "hatStyle", "turban")}>
231257
Turban
232258
</p>
233259
<p
234-
className={classnames("opt", { active: config.hairStyle === "beanie" })}
235-
onClick={this.updateConfig.bind(this, "hairStyle", "beanie")}>
260+
className={classnames("opt", { active: config.hatStyle === "beanie" })}
261+
onClick={this.updateConfig.bind(this, "hatStyle", "beanie")}>
236262
Beanie
237263
</p>
238264
</div>

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"description": "react library for generating avatar",
55
"main": "dist/index.js",
66
"types": "dist/react-nice-avatar.d.ts",
7-
"scripts": {},
7+
"scripts": {
8+
"prepublish": "make build"
9+
},
810
"keywords": [
911
"react",
1012
"avatar",

src/hair/beanie.js

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

src/hair/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import Thick from "./thick";
55
import Mohawk from "./mohawk";
66
import WomanLong from "./womanLong";
77
import WomanShort from "./womanShort";
8-
import Turban from './turban';
9-
import Beanie from "./beanie";
108

119
export default function (props) {
1210
const { style, color, colorRandom } = props;
@@ -15,9 +13,7 @@ export default function (props) {
1513
case "mohawk": return <Mohawk color={color} colorRandom={colorRandom} />;
1614
case "womanLong": return <WomanLong color={color} />;
1715
case "womanShort": return <WomanShort color={color} />;
18-
case 'beanie': return <Beanie color={color} />;
19-
case "turban" : return <Turban color={color}/>;
20-
case "normal":
16+
case "normal":
2117
default:
2218
return <Normal color={color} />;
2319
}

src/hair/turban.js

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

0 commit comments

Comments
 (0)