@dicebear/micah 5.0.4 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/hooks/onPreCreate.js +3 -3
- package/lib/index.js +10 -0
- package/lib/utils/convertColor.js +1 -4
- package/lib/utils/getColors.js +11 -11
- package/package.json +3 -3
package/lib/hooks/onPreCreate.js
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* File: https://www.figma.com/file/YHb4ShTgmO8Lqhkz1plLfL
|
|
6
6
|
*/
|
|
7
7
|
export function onPreCreate({ prng, options }) {
|
|
8
|
-
var _a
|
|
8
|
+
var _a;
|
|
9
9
|
// Prevent baseColor from being used a second time if possible.
|
|
10
|
-
options.baseColor = options.baseColor && options.baseColor.length > 0 ? [
|
|
10
|
+
options.baseColor = options.baseColor && options.baseColor.length > 0 ? [prng.pick(options.baseColor, 'transparent')] : [];
|
|
11
11
|
for (const colorName of ['eyebrows', 'hair', 'eyes', 'nose', 'ears', 'shirt', 'earrings', 'glasses', 'facialHair']) {
|
|
12
12
|
// @ts-ignore
|
|
13
|
-
const colorOption = (
|
|
13
|
+
const colorOption = (_a = options[`${colorName}Color`]) !== null && _a !== void 0 ? _a : [];
|
|
14
14
|
const index = colorOption.indexOf(options.baseColor[0]);
|
|
15
15
|
if (colorOption.length > 1 && index > -1) {
|
|
16
16
|
colorOption.splice(index, 1);
|
package/lib/index.js
CHANGED
|
@@ -31,6 +31,16 @@ export const create = ({ prng, options }) => {
|
|
|
31
31
|
'shape-rendering': 'auto'
|
|
32
32
|
},
|
|
33
33
|
body: `<g transform="translate(80 23)">${(_b = (_a = components.base) === null || _a === void 0 ? void 0 : _a.value(components, colors)) !== null && _b !== void 0 ? _b : ''}</g><g transform="translate(170 183)">${(_d = (_c = components.mouth) === null || _c === void 0 ? void 0 : _c.value(components, colors)) !== null && _d !== void 0 ? _d : ''}</g><g transform="translate(110 102)">${(_f = (_e = components.eyebrows) === null || _e === void 0 ? void 0 : _e.value(components, colors)) !== null && _f !== void 0 ? _f : ''}</g><g transform="translate(49 11)">${(_h = (_g = components.hair) === null || _g === void 0 ? void 0 : _g.value(components, colors)) !== null && _h !== void 0 ? _h : ''}</g><g transform="translate(142 119)">${(_k = (_j = components.eyes) === null || _j === void 0 ? void 0 : _j.value(components, colors)) !== null && _k !== void 0 ? _k : ''}</g><g transform="rotate(-8 1149.44 -1186.92)">${(_m = (_l = components.nose) === null || _l === void 0 ? void 0 : _l.value(components, colors)) !== null && _m !== void 0 ? _m : ''}</g><g transform="translate(84 154)">${(_p = (_o = components.ears) === null || _o === void 0 ? void 0 : _o.value(components, colors)) !== null && _p !== void 0 ? _p : ''}</g><g transform="translate(53 272)">${(_r = (_q = components.shirt) === null || _q === void 0 ? void 0 : _q.value(components, colors)) !== null && _r !== void 0 ? _r : ''}</g>`,
|
|
34
|
+
extra: () => ({
|
|
35
|
+
...Object.entries(components).reduce((acc, [key, value]) => {
|
|
36
|
+
acc[key] = value === null || value === void 0 ? void 0 : value.name;
|
|
37
|
+
return acc;
|
|
38
|
+
}, {}),
|
|
39
|
+
...Object.entries(colors).reduce((acc, [key, value]) => {
|
|
40
|
+
acc[`${key}Color`] = value;
|
|
41
|
+
return acc;
|
|
42
|
+
}, {}),
|
|
43
|
+
}),
|
|
34
44
|
};
|
|
35
45
|
};
|
|
36
46
|
export { schema } from './schema.js';
|
package/lib/utils/getColors.js
CHANGED
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { convertColor } from './convertColor.js';
|
|
8
8
|
export function getColors({ prng, options }) {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
10
10
|
return {
|
|
11
|
-
'base': convertColor(
|
|
12
|
-
'earring': convertColor(
|
|
13
|
-
'eyeShadow': convertColor(
|
|
14
|
-
'eyebrows': convertColor(
|
|
15
|
-
'facialHair': convertColor(
|
|
16
|
-
'glasses': convertColor(
|
|
17
|
-
'hair': convertColor(
|
|
18
|
-
'mouth': convertColor(
|
|
19
|
-
'shirt': convertColor(
|
|
20
|
-
'eyes': convertColor(
|
|
11
|
+
'base': convertColor(prng.pick((_a = options.baseColor) !== null && _a !== void 0 ? _a : [], 'transparent')),
|
|
12
|
+
'earring': convertColor(prng.pick((_b = options.earringColor) !== null && _b !== void 0 ? _b : [], 'transparent')),
|
|
13
|
+
'eyeShadow': convertColor(prng.pick((_c = options.eyeShadowColor) !== null && _c !== void 0 ? _c : [], 'transparent')),
|
|
14
|
+
'eyebrows': convertColor(prng.pick((_d = options.eyebrowsColor) !== null && _d !== void 0 ? _d : [], 'transparent')),
|
|
15
|
+
'facialHair': convertColor(prng.pick((_e = options.facialHairColor) !== null && _e !== void 0 ? _e : [], 'transparent')),
|
|
16
|
+
'glasses': convertColor(prng.pick((_f = options.glassesColor) !== null && _f !== void 0 ? _f : [], 'transparent')),
|
|
17
|
+
'hair': convertColor(prng.pick((_g = options.hairColor) !== null && _g !== void 0 ? _g : [], 'transparent')),
|
|
18
|
+
'mouth': convertColor(prng.pick((_h = options.mouthColor) !== null && _h !== void 0 ? _h : [], 'transparent')),
|
|
19
|
+
'shirt': convertColor(prng.pick((_j = options.shirtColor) !== null && _j !== void 0 ? _j : [], 'transparent')),
|
|
20
|
+
'eyes': convertColor(prng.pick((_k = options.eyesColor) !== null && _k !== void 0 ? _k : [], 'transparent')),
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/micah",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "Avatar style for DiceBear",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dicebear"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test": "uvu tests"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@dicebear/core": "^5.
|
|
32
|
+
"@dicebear/core": "^5.1.1",
|
|
33
33
|
"@tsconfig/recommended": "^1.0.1",
|
|
34
34
|
"del-cli": "^4.0.1",
|
|
35
35
|
"typescript": "^4.6.3",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "0c544971431b02f8783598b4f821a6341b9fff0a"
|
|
48
48
|
}
|