@infonomic/uikit 6.9.0 → 6.9.1
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.
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export interface AvatarProps {
|
|
3
|
+
/** Shown when there is no `src`, or while the image loads or if it fails. */
|
|
3
4
|
initials: string;
|
|
4
|
-
|
|
5
|
+
/** Image URL. When omitted, no request is made and the initials show at once. */
|
|
6
|
+
src?: string;
|
|
7
|
+
/** Text alternative for the image. Defaults to `initials`. */
|
|
8
|
+
alt?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const Avatar: ({ initials, src, alt }: AvatarProps) => React.JSX.Element;
|
|
5
11
|
//# sourceMappingURL=avatar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../../src/components/avatar/avatar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"avatar.d.ts","sourceRoot":"","sources":["../../../src/components/avatar/avatar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAA;IAChB,iFAAiF;IACjF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,MAAM,2BAAuC,WAAW,KAAG,KAAK,CAAC,GAAG,CAAC,OAkBjF,CAAA"}
|
|
@@ -3,18 +3,17 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { Avatar } from "@base-ui/react/avatar";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import avatar_module from "./avatar.module.js";
|
|
6
|
-
const
|
|
7
|
-
const avatar_Avatar = ({ initials })=>/*#__PURE__*/ jsxs(Avatar.Root, {
|
|
6
|
+
const avatar_Avatar = ({ initials, src, alt = initials })=>/*#__PURE__*/ jsxs(Avatar.Root, {
|
|
8
7
|
className: clsx('infonomic-avatar-root', avatar_module["avatar-root"]),
|
|
9
8
|
children: [
|
|
10
|
-
/*#__PURE__*/ jsx(Avatar.Image, {
|
|
11
|
-
src:
|
|
12
|
-
alt:
|
|
9
|
+
src ? /*#__PURE__*/ jsx(Avatar.Image, {
|
|
10
|
+
src: src,
|
|
11
|
+
alt: alt,
|
|
13
12
|
className: clsx('infonomic-avatar-image', avatar_module["avatar-image"])
|
|
14
|
-
}),
|
|
13
|
+
}) : null,
|
|
15
14
|
/*#__PURE__*/ jsx(Avatar.Fallback, {
|
|
16
15
|
className: clsx('infonomic-avatar-fallback', avatar_module["avatar-fallback"]),
|
|
17
|
-
delay: 600,
|
|
16
|
+
delay: src ? 600 : 0,
|
|
18
17
|
children: /*#__PURE__*/ jsx("span", {
|
|
19
18
|
className: clsx('infonomic-avatar-text', avatar_module["avatar-text"]),
|
|
20
19
|
children: initials
|
package/package.json
CHANGED
|
@@ -4,6 +4,11 @@ import type { Meta } from '@storybook/react-vite'
|
|
|
4
4
|
|
|
5
5
|
import { Avatar as AvatarComponent } from './avatar.js'
|
|
6
6
|
|
|
7
|
+
// A local image, so the story makes no network request.
|
|
8
|
+
const photo = `data:image/svg+xml,${encodeURIComponent(
|
|
9
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#7c9cbf"/><stop offset="1" stop-color="#2f4a6b"/></linearGradient></defs><rect width="40" height="40" fill="url(#g)"/><circle cx="20" cy="16" r="7" fill="#e8eef5"/><path d="M6 40c2-9 8-13 14-13s12 4 14 13z" fill="#e8eef5"/></svg>'
|
|
10
|
+
)}`
|
|
11
|
+
|
|
7
12
|
const meta: Meta = {
|
|
8
13
|
/* 👇 The title prop is optional.
|
|
9
14
|
* See https://storybook.js.org/docs/react/configure/overview#configure-story-loading
|
|
@@ -35,5 +40,8 @@ export const Avatar = (): React.JSX.Element => (
|
|
|
35
40
|
<div style={{ height: '40px', width: '40px' }}>
|
|
36
41
|
<AvatarComponent initials="AB" />
|
|
37
42
|
</div>
|
|
43
|
+
<div style={{ height: '40px', width: '40px' }}>
|
|
44
|
+
<AvatarComponent initials="AB" src={photo} alt="Example user" />
|
|
45
|
+
</div>
|
|
38
46
|
</div>
|
|
39
47
|
)
|
|
@@ -7,19 +7,28 @@ import cx from 'clsx'
|
|
|
7
7
|
|
|
8
8
|
import styles from './avatar.module.css'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export interface AvatarProps {
|
|
11
|
+
/** Shown when there is no `src`, or while the image loads or if it fails. */
|
|
12
|
+
initials: string
|
|
13
|
+
/** Image URL. When omitted, no request is made and the initials show at once. */
|
|
14
|
+
src?: string
|
|
15
|
+
/** Text alternative for the image. Defaults to `initials`. */
|
|
16
|
+
alt?: string
|
|
17
|
+
}
|
|
11
18
|
|
|
12
|
-
export const Avatar = ({ initials
|
|
19
|
+
export const Avatar = ({ initials, src, alt = initials }: AvatarProps): React.JSX.Element => {
|
|
13
20
|
return (
|
|
14
21
|
<AvatarPrimitive.Root className={cx('infonomic-avatar-root', styles['avatar-root'])}>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
{src ? (
|
|
23
|
+
<AvatarPrimitive.Image
|
|
24
|
+
src={src}
|
|
25
|
+
alt={alt}
|
|
26
|
+
className={cx('infonomic-avatar-image', styles['avatar-image'])}
|
|
27
|
+
/>
|
|
28
|
+
) : null}
|
|
20
29
|
<AvatarPrimitive.Fallback
|
|
21
30
|
className={cx('infonomic-avatar-fallback', styles['avatar-fallback'])}
|
|
22
|
-
delay={600}
|
|
31
|
+
delay={src ? 600 : 0}
|
|
23
32
|
>
|
|
24
33
|
<span className={cx('infonomic-avatar-text', styles['avatar-text'])}>{initials}</span>
|
|
25
34
|
</AvatarPrimitive.Fallback>
|