@ddd-qc/profiles-dvm 0.19.18 → 0.19.19

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.
@@ -0,0 +1,8 @@
1
+ import { AgentPubKeyB64 } from "@holochain/client";
2
+ import { ProfilesPerspective } from "./profiles.zvm";
3
+ import { ProfileMat } from "./profiles.proxy";
4
+ import { TemplateResult } from "lit";
5
+ /** */
6
+ export declare function getInitials(nickname: string): string;
7
+ /** */
8
+ export declare function agent2avatar(key: AgentPubKeyB64, profilesPerspective: ProfilesPerspective): [ProfileMat, TemplateResult<1>];
package/dist/utils.js ADDED
@@ -0,0 +1,35 @@
1
+ import { html } from "lit";
2
+ /** */
3
+ export function getInitials(nickname) {
4
+ const names = nickname.split(' ');
5
+ let initials = names[0].substring(0, 1).toUpperCase();
6
+ if (names.length > 1) {
7
+ initials += names[names.length - 1].substring(0, 1).toUpperCase();
8
+ }
9
+ else {
10
+ initials += names[0].substring(1, 2);
11
+ }
12
+ return initials;
13
+ }
14
+ /** */
15
+ export function agent2avatar(key, profilesPerspective) {
16
+ let profile = { nickname: "unknown", fields: {} };
17
+ const maybeProfile = profilesPerspective.profiles[key];
18
+ if (maybeProfile) {
19
+ profile = maybeProfile;
20
+ }
21
+ else {
22
+ console.log("Profile not found for agent", key, profilesPerspective.profiles);
23
+ }
24
+ const initials = getInitials(profile.nickname);
25
+ const avatarUrl = profile.fields['avatar'];
26
+ const avatar = avatarUrl ? html `
27
+ <sl-avatar class="activityAvatar" style="box-shadow: 1px 1px 1px 1px rgba(130, 122, 122, 0.88)">
28
+ <img src=${avatarUrl}>
29
+ </sl-avatar>
30
+ ` : html `
31
+ <sl-avatar class="activityAvatar" shape="circle" initials=${initials} color-scheme="Accent2"></sl-avatar>
32
+ `;
33
+ return [profile, avatar];
34
+ }
35
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names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,IAAI,CAAA;oEACgD,QAAQ;iBAC3D,CAAC;IACd,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import {AgentPubKeyB64} from \"@holochain/client\";\r\nimport {ProfilesPerspective} from \"./profiles.zvm\";\r\nimport {ProfileMat} from \"./profiles.proxy\";\r\nimport {html, TemplateResult} from \"lit\";\r\n\r\n/** */\r\nexport function getInitials(nickname: string): string {\r\n const names = nickname.split(' ');\r\n let initials = names[0].substring(0, 1).toUpperCase();\r\n if (names.length > 1) {\r\n initials += names[names.length - 1].substring(0, 1).toUpperCase();\r\n } else {\r\n initials += names[0].substring(1, 2);\r\n }\r\n return initials;\r\n}\r\n\r\n\r\n\r\n/** */\r\nexport function agent2avatar(key: AgentPubKeyB64, profilesPerspective: ProfilesPerspective): [ProfileMat, TemplateResult<1>] {\r\n let profile = {nickname: \"unknown\", fields: {}} as ProfileMat;\r\n const maybeProfile = profilesPerspective.profiles[key];\r\n if (maybeProfile) {\r\n profile = maybeProfile;\r\n } else {\r\n console.log(\"Profile not found for agent\", key, profilesPerspective.profiles)\r\n }\r\n const initials = getInitials(profile.nickname);\r\n const avatarUrl = profile.fields['avatar'];\r\n const avatar =\r\n avatarUrl? html`\r\n <sl-avatar class=\"activityAvatar\" style=\"box-shadow: 1px 1px 1px 1px rgba(130, 122, 122, 0.88)\">\r\n <img src=${avatarUrl}>\r\n </sl-avatar> \r\n ` : html`\r\n <sl-avatar class=\"activityAvatar\" shape=\"circle\" initials=${initials} color-scheme=\"Accent2\"></sl-avatar>\r\n `;\r\n return [profile, avatar];\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-qc/profiles-dvm",
3
- "version": "0.19.18",
3
+ "version": "0.19.19",
4
4
  "description": "DnaViewModel implementation for the Profiles zome.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -31,7 +31,8 @@
31
31
  "dependencies": {
32
32
  "@ddd-qc/lit-happ": "file:../lit-happ",
33
33
  "@holochain/client": "=0.16.2",
34
- "@msgpack/msgpack": "^2.7.2"
34
+ "@msgpack/msgpack": "^2.7.2",
35
+ "lit": "^2.6.0"
35
36
  },
36
37
  "engines": {
37
38
  "node": "^14.13.1 || >=16.0.0 || >=18.0.0"