@dicebear/initials 5.0.0-alpha.31 → 5.0.0-alpha.32
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 +5 -27
- package/lib/schema.js +17 -41
- package/package.json +3 -3
package/lib/core.js
CHANGED
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { schema } from './schema.js';
|
|
2
2
|
import initials from 'initials';
|
|
3
|
-
const colors = {
|
|
4
|
-
amber: 'rgba(255, 179, 0, 1)',
|
|
5
|
-
blue: 'rgba(30, 136, 229, 1)',
|
|
6
|
-
blueGrey: 'rgba(84, 110, 122, 1)',
|
|
7
|
-
brown: 'rgba(109, 76, 65, 1)',
|
|
8
|
-
cyan: 'rgba(0, 172, 193, 1)',
|
|
9
|
-
deepOrange: 'rgba(244, 81, 30, 1)',
|
|
10
|
-
deepPurple: 'rgba(94, 53, 177, 1)',
|
|
11
|
-
green: 'rgba(67, 160, 71, 1)',
|
|
12
|
-
grey: 'rgba(117, 117, 117, 1)',
|
|
13
|
-
indigo: 'rgba(57, 73, 171, 1)',
|
|
14
|
-
lightBlue: 'rgba(3, 155, 229, 1)',
|
|
15
|
-
lightGreen: 'rgba(124, 179, 66, 1)',
|
|
16
|
-
lime: 'rgba(192, 202, 51, 1)',
|
|
17
|
-
orange: 'rgba(251, 140, 0, 1)',
|
|
18
|
-
pink: 'rgba(216, 27, 96, 1)',
|
|
19
|
-
purple: 'rgba(142, 36, 170, 1)',
|
|
20
|
-
red: 'rgba(229, 57, 53, 1)',
|
|
21
|
-
teal: 'rgba(0, 137, 123, 1)',
|
|
22
|
-
yellow: 'rgba(253, 216, 53, 1)',
|
|
23
|
-
};
|
|
24
3
|
export const style = {
|
|
25
4
|
meta: {
|
|
26
5
|
title: 'Initials',
|
|
@@ -33,14 +12,13 @@ export const style = {
|
|
|
33
12
|
},
|
|
34
13
|
schema: schema,
|
|
35
14
|
create: ({ prng, options }) => {
|
|
36
|
-
var _a, _b, _c, _d, _e
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const fontWeight = (_e = options.fontWeight) !== null && _e !== void 0 ? _e : 400;
|
|
15
|
+
var _a, _b, _c, _d, _e;
|
|
16
|
+
const fontFamily = (_b = (_a = options.fontFamily) === null || _a === void 0 ? void 0 : _a.join(', ')) !== null && _b !== void 0 ? _b : 'Arial, sans-serif';
|
|
17
|
+
const fontSize = (_c = options.fontSize) !== null && _c !== void 0 ? _c : 50;
|
|
18
|
+
const fontWeight = (_d = options.fontWeight) !== null && _d !== void 0 ? _d : 400;
|
|
41
19
|
const seedInitials = initials(prng.seed.trim())
|
|
42
20
|
.toLocaleUpperCase()
|
|
43
|
-
.slice(0, (
|
|
21
|
+
.slice(0, (_e = options.chars) !== null && _e !== void 0 ? _e : 2);
|
|
44
22
|
// prettier-ignore
|
|
45
23
|
const svg = [
|
|
46
24
|
`<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>`,
|
package/lib/schema.js
CHANGED
|
@@ -6,49 +6,25 @@ export const schema = {
|
|
|
6
6
|
type: 'array',
|
|
7
7
|
items: {
|
|
8
8
|
type: 'string',
|
|
9
|
-
pattern: '
|
|
9
|
+
pattern: '^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$',
|
|
10
10
|
},
|
|
11
11
|
default: [
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'red',
|
|
29
|
-
'teal',
|
|
30
|
-
'yellow',
|
|
31
|
-
],
|
|
32
|
-
examples: [
|
|
33
|
-
['amber'],
|
|
34
|
-
['blue'],
|
|
35
|
-
['blueGrey'],
|
|
36
|
-
['brown'],
|
|
37
|
-
['cyan'],
|
|
38
|
-
['deepOrange'],
|
|
39
|
-
['deepPurple'],
|
|
40
|
-
['green'],
|
|
41
|
-
['grey'],
|
|
42
|
-
['indigo'],
|
|
43
|
-
['lightBlue'],
|
|
44
|
-
['lightGreen'],
|
|
45
|
-
['lime'],
|
|
46
|
-
['orange'],
|
|
47
|
-
['pink'],
|
|
48
|
-
['purple'],
|
|
49
|
-
['red'],
|
|
50
|
-
['teal'],
|
|
51
|
-
['yellow'],
|
|
12
|
+
'e53935',
|
|
13
|
+
'd81b60',
|
|
14
|
+
'8e24aa',
|
|
15
|
+
'5e35b1',
|
|
16
|
+
'3949ab',
|
|
17
|
+
'1e88e5',
|
|
18
|
+
'039be5',
|
|
19
|
+
'00acc1',
|
|
20
|
+
'00897b',
|
|
21
|
+
'43a047',
|
|
22
|
+
'7cb342',
|
|
23
|
+
'c0ca33',
|
|
24
|
+
'fdd835',
|
|
25
|
+
'ffb300',
|
|
26
|
+
'fb8c00',
|
|
27
|
+
'f4511e',
|
|
52
28
|
],
|
|
53
29
|
},
|
|
54
30
|
fontFamily: {
|
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.32",
|
|
4
4
|
"description": "Initials avatar style for DiceBear",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dicebear"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"initials": "^3.1.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@dicebear/core": "^5.0.0-alpha.
|
|
34
|
+
"@dicebear/core": "^5.0.0-alpha.32",
|
|
35
35
|
"@tsconfig/recommended": "^1.0.1",
|
|
36
36
|
"del-cli": "^4.0.1",
|
|
37
37
|
"typescript": "^4.6.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "5a4a06cbb8aca42a5d19da8e704b3a7b3a45d755"
|
|
50
50
|
}
|