Skip to content

Commit

Permalink
feat: update avatar fallback url
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyu2er committed Jan 6, 2025
1 parent ceb3053 commit 1dd5c1f
Show file tree
Hide file tree
Showing 6 changed files with 385 additions and 6 deletions.
2 changes: 2 additions & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"db:drop:staging": "wrangler d1 drop hexa-xyz --remote --env staging"
},
"dependencies": {
"@dicebear/collection": "catalog:",
"@dicebear/core": "catalog:",
"@dnd-kit/core": "catalog:",
"@dnd-kit/sortable": "catalog:",
"@dnd-kit/utilities": "catalog:",
Expand Down
7 changes: 6 additions & 1 deletion apps/app/src/lib/org.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { icons } from '@dicebear/collection';
import { createAvatar } from '@dicebear/core';
import type { SelectOrgType } from '@hexa/server/schema/org';

export const getOrgAvatarFallbackUrl = (org: SelectOrgType) => {
return `https://api.dicebear.com/9.x/icons/svg?seed=${org.name}`;
const avatar = createAvatar(icons, {
seed: org.id,
});
return avatar.toDataUri();
};
7 changes: 6 additions & 1 deletion apps/app/src/lib/project.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { icons } from '@dicebear/collection';
import { createAvatar } from '@dicebear/core';
import type { SelectProjectType } from '@hexa/server/schema/project';

export const getProjectAvatarFallbackUrl = (project: SelectProjectType) => {
return `https://api.dicebear.com/9.x/icons/svg?seed=${project?.id}`;
const avatar = createAvatar(icons, {
seed: project.id,
});
return avatar.toDataUri();
};

export const getProjectSlug = (project: {
Expand Down
7 changes: 6 additions & 1 deletion apps/app/src/lib/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { initials } from '@dicebear/collection';
import { createAvatar } from '@dicebear/core';
import type { BasicUserType } from '@hexa/server/schema/user';

export const getAvatarFallbackUrl = (user: BasicUserType) => {
return `https://api.dicebear.com/9.x/initials/svg?seed=${user.name ?? user.email}`;
const avatar = createAvatar(initials, {
seed: user.name ?? user.email ?? '',
});
return avatar.toDataUri();
};

export const getAvatarUrl = (user: BasicUserType) => {
Expand Down
Loading

0 comments on commit 1dd5c1f

Please sign in to comment.