@dicebear/initials 5.0.0-alpha.11 → 5.0.0-alpha.15
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/core.js +9 -8
- package/lib/schema.js +31 -7
- package/lib/types.d.ts +2 -1
- package/package.json +3 -3
package/lib/core.js
CHANGED
|
@@ -33,20 +33,21 @@ export const style = {
|
|
|
33
33
|
},
|
|
34
34
|
schema: schema,
|
|
35
35
|
create: ({ prng, options }) => {
|
|
36
|
-
var _a, _b, _c;
|
|
36
|
+
var _a, _b, _c, _d, _e, _f;
|
|
37
37
|
options.backgroundColor = (_a = options.backgroundColor) === null || _a === void 0 ? void 0 : _a.map((val) => { var _a; return (_a = colors[val]) !== null && _a !== void 0 ? _a : val; });
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const fontFamily = (_c = (_b = options.fontFamily) === null || _b === void 0 ? void 0 : _b.join(', ')) !== null && _c !== void 0 ? _c : 'Arial, sans-serif';
|
|
39
|
+
const fontSize = (_d = options.fontSize) !== null && _d !== void 0 ? _d : 50;
|
|
40
|
+
const fontWeight = (_e = options.fontWeight) !== null && _e !== void 0 ? _e : 400;
|
|
41
|
+
const seedInitials = initials(prng.seed.trim())
|
|
41
42
|
.toLocaleUpperCase()
|
|
42
|
-
.slice(0, (
|
|
43
|
+
.slice(0, (_f = options.chars) !== null && _f !== void 0 ? _f : 2);
|
|
43
44
|
// prettier-ignore
|
|
44
|
-
|
|
45
|
-
`<text x="50%" y="50%"
|
|
45
|
+
const svg = [
|
|
46
|
+
`<text x="50%" y="50%" font-family="${fontFamily}" font-size="${fontSize}" fontWeight="${fontWeight}" fill="#FFF" text-anchor="middle" dy="${(fontSize * .356).toFixed(3)}">${seedInitials}</text>`,
|
|
46
47
|
].join('');
|
|
47
48
|
return {
|
|
48
49
|
attributes: {
|
|
49
|
-
viewBox: '0 0
|
|
50
|
+
viewBox: '0 0 100 100',
|
|
50
51
|
},
|
|
51
52
|
body: svg,
|
|
52
53
|
};
|
package/lib/schema.js
CHANGED
|
@@ -3,9 +3,7 @@ export const schema = {
|
|
|
3
3
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
4
4
|
properties: {
|
|
5
5
|
backgroundColor: {
|
|
6
|
-
title: 'Background Color',
|
|
7
6
|
type: 'array',
|
|
8
|
-
uniqueItems: true,
|
|
9
7
|
items: {
|
|
10
8
|
type: 'string',
|
|
11
9
|
pattern: '^([0-9a-zA-Z]+|#[a-fA-F0-9]{3}|#[a-fA-F0-9]{4}|#[a-fA-F0-9]{6}|#[a-fA-F0-9]{8})$',
|
|
@@ -53,23 +51,49 @@ export const schema = {
|
|
|
53
51
|
['yellow'],
|
|
54
52
|
],
|
|
55
53
|
},
|
|
54
|
+
fontFamily: {
|
|
55
|
+
type: 'array',
|
|
56
|
+
uniqueItems: true,
|
|
57
|
+
minItems: 1,
|
|
58
|
+
items: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
pattern: '^[a-zA-Z0-9\\-\\s]+$',
|
|
61
|
+
},
|
|
62
|
+
default: ['Arial', 'sans-serif'],
|
|
63
|
+
examples: [
|
|
64
|
+
['Arial'],
|
|
65
|
+
['Verdana'],
|
|
66
|
+
['Helvetica'],
|
|
67
|
+
['Tahoma'],
|
|
68
|
+
['Trebuchet MS'],
|
|
69
|
+
['Times New Roman'],
|
|
70
|
+
['Georgia'],
|
|
71
|
+
['Garamond'],
|
|
72
|
+
['Courier New'],
|
|
73
|
+
['Brush Script MT'],
|
|
74
|
+
['sans-serif'],
|
|
75
|
+
['serif'],
|
|
76
|
+
],
|
|
77
|
+
},
|
|
56
78
|
fontSize: {
|
|
57
|
-
title: 'Font Size',
|
|
58
79
|
type: 'integer',
|
|
59
80
|
minimum: 1,
|
|
60
81
|
maximum: 100,
|
|
61
82
|
default: 50,
|
|
83
|
+
examples: [25, 50, 75, 100],
|
|
62
84
|
},
|
|
63
85
|
chars: {
|
|
64
|
-
title: 'Chars',
|
|
65
86
|
type: 'number',
|
|
66
87
|
minimum: 0,
|
|
67
88
|
maximum: 2,
|
|
68
89
|
default: 2,
|
|
90
|
+
examples: [1, 2],
|
|
69
91
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
92
|
+
fontWeight: {
|
|
93
|
+
type: 'number',
|
|
94
|
+
default: 400,
|
|
95
|
+
enum: [100, 200, 300, 400, 500, 600, 700, 800, 900],
|
|
96
|
+
examples: [100, 200, 300, 400, 500, 600, 700, 800, 900],
|
|
73
97
|
},
|
|
74
98
|
},
|
|
75
99
|
additionalProperties: false,
|
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/initials",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.15",
|
|
4
4
|
"description": "Initials avatar style for DiceBear",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dicebear"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"initials": "^3.0.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@dicebear/core": "^5.0.0-alpha.
|
|
34
|
+
"@dicebear/core": "^5.0.0-alpha.15",
|
|
35
35
|
"@tsconfig/recommended": "^1.0.0",
|
|
36
36
|
"@types/jest": "^26.0.22",
|
|
37
37
|
"del-cli": "^4.0.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "9905588d7bb8da0c3e7953f80845e732b9f43847"
|
|
51
51
|
}
|