sprintify-ui 0.11.19 → 0.11.21
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/dist/sprintify-ui.es.js +3781 -3727
- package/dist/types/utils/avatar.d.ts +2 -0
- package/dist/types/utils/index.d.ts +2 -1
- package/package.json +5 -4
- package/src/components/BaseAvatar.stories.js +18 -0
- package/src/components/BaseAvatar.vue +30 -0
- package/src/components/BaseTooltip.vue +1 -1
- package/src/utils/avatar.ts +30 -0
- package/src/utils/index.ts +3 -0
|
@@ -4,4 +4,5 @@ import resizeImageFromURI from './resizeImageFromURI';
|
|
|
4
4
|
import { disableScroll, enableScroll } from './scrollPreventer';
|
|
5
5
|
import { blobToBase64, validateBase64, base64ToBlob } from './blob';
|
|
6
6
|
import { getColorConfig } from './colors';
|
|
7
|
-
|
|
7
|
+
import { getInitials, getAvatarColor } from './avatar';
|
|
8
|
+
export { toHumanList, fileSizeFormat, disableScroll, enableScroll, resizeImageFromURI, blobToBase64, validateBase64, base64ToBlob, getColorConfig, getInitials, getAvatarColor, };
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprintify-ui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"build
|
|
6
|
+
"generate-llm-txt": "node scripts/generate-llm-txt.js",
|
|
7
|
+
"build": "rimraf dist && vue-tsc && vite build && npm run generate-llm-txt",
|
|
8
|
+
"build-fast": "rimraf dist && vite build && npm run generate-llm-txt",
|
|
8
9
|
"storybook": "storybook dev -p 6006",
|
|
9
10
|
"eslint:fix": "eslint --ext .js,.vue,.ts src --fix",
|
|
10
|
-
"build-storybook": "storybook build",
|
|
11
|
+
"build-storybook": "npm run generate-llm-txt && storybook build",
|
|
11
12
|
"prepack": "npm run build",
|
|
12
13
|
"prepare": "husky install && relative-deps",
|
|
13
14
|
"release": "standard-version",
|
|
@@ -37,3 +37,21 @@ Demo.args = {
|
|
|
37
37
|
"https://images.unsplash.com/photo-1494790108377-be9c29b29330??auto=format&fit=crop&w=200&h=200&q=80&g=face",
|
|
38
38
|
},
|
|
39
39
|
};
|
|
40
|
+
|
|
41
|
+
export const Fallback = Template.bind({});
|
|
42
|
+
Fallback.args = {
|
|
43
|
+
showDetails: true,
|
|
44
|
+
user: {
|
|
45
|
+
email: "jane@witify.io",
|
|
46
|
+
full_name: "Jane Doe",
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const FallbackSingleName = Template.bind({});
|
|
51
|
+
FallbackSingleName.args = {
|
|
52
|
+
showDetails: true,
|
|
53
|
+
user: {
|
|
54
|
+
email: "admin@witify.io",
|
|
55
|
+
full_name: "Admin",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -11,10 +11,36 @@
|
|
|
11
11
|
class="flex items-center"
|
|
12
12
|
>
|
|
13
13
|
<img
|
|
14
|
+
v-if="user.avatar_url"
|
|
14
15
|
:src="user.avatar_url"
|
|
15
16
|
:class="[sizeClass, detailsPosition == 'left' ? 'order-2' : 'order-1']"
|
|
16
17
|
class="shrink-0 block overflow-hidden rounded-full object-cover object-center"
|
|
17
18
|
>
|
|
19
|
+
<svg
|
|
20
|
+
v-else
|
|
21
|
+
viewBox="0 0 100 100"
|
|
22
|
+
:class="[sizeClass, detailsPosition == 'left' ? 'order-2' : 'order-1']"
|
|
23
|
+
class="shrink-0 block overflow-hidden rounded-full"
|
|
24
|
+
>
|
|
25
|
+
<circle
|
|
26
|
+
cx="50"
|
|
27
|
+
cy="50"
|
|
28
|
+
r="50"
|
|
29
|
+
:fill="avatarColor"
|
|
30
|
+
></circle>
|
|
31
|
+
<text
|
|
32
|
+
x="50"
|
|
33
|
+
y="50"
|
|
34
|
+
text-anchor="middle"
|
|
35
|
+
dominant-baseline="central"
|
|
36
|
+
fill="white"
|
|
37
|
+
:font-size="initials.length === 1 ? '45' : '40'"
|
|
38
|
+
font-weight="600"
|
|
39
|
+
font-family="system-ui, -apple-system, sans-serif"
|
|
40
|
+
>
|
|
41
|
+
{{ initials }}
|
|
42
|
+
</text>
|
|
43
|
+
</svg>
|
|
18
44
|
<div
|
|
19
45
|
v-if="showDetails"
|
|
20
46
|
class="max-w-[120px] grow leading-tight"
|
|
@@ -44,6 +70,7 @@ import { User } from '@/types/User';
|
|
|
44
70
|
import { RouteLocationRaw } from 'vue-router';
|
|
45
71
|
import { twMerge } from 'tailwind-merge';
|
|
46
72
|
import BaseTooltip from './BaseTooltip.vue';
|
|
73
|
+
import { getInitials, getAvatarColor } from '@/utils/avatar';
|
|
47
74
|
|
|
48
75
|
defineOptions({
|
|
49
76
|
inheritAttrs: false,
|
|
@@ -80,6 +107,9 @@ const props = defineProps({
|
|
|
80
107
|
},
|
|
81
108
|
});
|
|
82
109
|
|
|
110
|
+
const initials = computed(() => getInitials(props.user?.full_name || ''));
|
|
111
|
+
const avatarColor = computed(() => getAvatarColor(props.user?.full_name || '', props.user?.email));
|
|
112
|
+
|
|
83
113
|
const classInternal = computed(() => {
|
|
84
114
|
return twMerge(
|
|
85
115
|
'inline-flex',
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { palette } from './colors';
|
|
2
|
+
|
|
3
|
+
const avatarColorKeys = [
|
|
4
|
+
'red', 'orange', 'yellow', 'green', 'teal',
|
|
5
|
+
'cyan', 'blue', 'indigo', 'purple', 'pink',
|
|
6
|
+
] as const;
|
|
7
|
+
|
|
8
|
+
export function getInitials(fullName: string): string {
|
|
9
|
+
const words = fullName.trim().split(/\s+/).filter(Boolean);
|
|
10
|
+
|
|
11
|
+
if (words.length === 0) {
|
|
12
|
+
return '?';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (words.length === 1) {
|
|
16
|
+
return words[0][0].toUpperCase();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (words[0][0] + words[words.length - 1][0]).toUpperCase();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getAvatarColor(name: string, email?: string): string {
|
|
23
|
+
const input = (name + (email || '')).trim();
|
|
24
|
+
let sum = 0;
|
|
25
|
+
for (let i = 0; i < input.length; i++) {
|
|
26
|
+
sum += input.charCodeAt(i);
|
|
27
|
+
}
|
|
28
|
+
const key = avatarColorKeys[sum % avatarColorKeys.length];
|
|
29
|
+
return palette[key].high.backgroundColor;
|
|
30
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import resizeImageFromURI from './resizeImageFromURI';
|
|
|
4
4
|
import { disableScroll, enableScroll } from './scrollPreventer';
|
|
5
5
|
import { blobToBase64, validateBase64, base64ToBlob } from './blob';
|
|
6
6
|
import { getColorConfig } from './colors';
|
|
7
|
+
import { getInitials, getAvatarColor } from './avatar';
|
|
7
8
|
|
|
8
9
|
export {
|
|
9
10
|
toHumanList,
|
|
@@ -15,4 +16,6 @@ export {
|
|
|
15
16
|
validateBase64,
|
|
16
17
|
base64ToBlob,
|
|
17
18
|
getColorConfig,
|
|
19
|
+
getInitials,
|
|
20
|
+
getAvatarColor,
|
|
18
21
|
};
|