@dicebear/initials 5.0.0-beta.6 → 5.0.0-beta.7
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/index.d.ts +6 -3
- package/lib/index.js +30 -4
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
|
|
5
5
|
* Copyright (c) 2022 Florian Körner
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
7
|
+
import type { StyleCreate, StyleMeta } from '@dicebear/core';
|
|
8
|
+
import type { Options } from './types.js';
|
|
9
|
+
export declare const meta: StyleMeta;
|
|
10
|
+
export declare const create: StyleCreate<Options>;
|
|
11
|
+
export { schema } from './schema.js';
|
|
12
|
+
export type { Options } from './types.js';
|
package/lib/index.js
CHANGED
|
@@ -4,7 +4,33 @@
|
|
|
4
4
|
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
|
|
5
5
|
* Copyright (c) 2022 Florian Körner
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import initials from 'initials';
|
|
8
|
+
export const meta = {
|
|
9
|
+
title: 'Initials',
|
|
10
|
+
creator: 'Florian Körner',
|
|
11
|
+
source: 'https://github.com/dicebear/dicebear',
|
|
12
|
+
license: {
|
|
13
|
+
name: 'CC0 1.0',
|
|
14
|
+
url: 'https://creativecommons.org/publicdomain/zero/1.0/',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export const create = ({ prng, options }) => {
|
|
18
|
+
var _a, _b, _c, _d, _e;
|
|
19
|
+
const fontFamily = (_b = (_a = options.fontFamily) === null || _a === void 0 ? void 0 : _a.join(', ')) !== null && _b !== void 0 ? _b : 'Arial, sans-serif';
|
|
20
|
+
const fontSize = (_c = options.fontSize) !== null && _c !== void 0 ? _c : 50;
|
|
21
|
+
const fontWeight = (_d = options.fontWeight) !== null && _d !== void 0 ? _d : 400;
|
|
22
|
+
const seedInitials = initials(prng.seed.trim())
|
|
23
|
+
.toLocaleUpperCase()
|
|
24
|
+
.slice(0, (_e = options.chars) !== null && _e !== void 0 ? _e : 2);
|
|
25
|
+
// prettier-ignore
|
|
26
|
+
const svg = [
|
|
27
|
+
`<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>`,
|
|
28
|
+
].join('');
|
|
29
|
+
return {
|
|
30
|
+
attributes: {
|
|
31
|
+
viewBox: '0 0 100 100',
|
|
32
|
+
},
|
|
33
|
+
body: svg,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export { schema } from './schema.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/initials",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.7",
|
|
4
4
|
"description": "Initials avatar style for DiceBear",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dicebear"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"initials": "^3.1.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@dicebear/core": "^5.0.0-beta.
|
|
35
|
+
"@dicebear/core": "^5.0.0-beta.7",
|
|
36
36
|
"@tsconfig/recommended": "^1.0.1",
|
|
37
37
|
"del-cli": "^4.0.1",
|
|
38
38
|
"typescript": "^4.6.3",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "6864a0fec66652d8740f6feb2d99dc7a118ebd79"
|
|
51
51
|
}
|