@passui/react 0.1.34 → 0.1.35
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/types/src/components/content-unavailable-view/content-unavailable-view.d.ts +4 -1
- package/dist/types/src/components/profile-image/profile-image.d.ts +6 -1
- package/package.json +1 -1
- package/src/components/content-unavailable-view/content-unavailable-view.tsx +28 -3
- package/src/components/profile-image/profile-image.tsx +28 -6
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ReactNode, ComponentProps } from "react";
|
|
2
|
+
export type ContentUnavailableViewSize = "sm" | "md" | "lg";
|
|
2
3
|
export interface ContentUnavailableViewProps extends Omit<ComponentProps<"div">, "title"> {
|
|
3
4
|
title: string;
|
|
4
5
|
description?: string;
|
|
5
6
|
icon?: ReactNode;
|
|
6
7
|
actions?: ReactNode;
|
|
8
|
+
/** Title, description and vertical rhythm. @default "md" */
|
|
9
|
+
size?: ContentUnavailableViewSize;
|
|
7
10
|
}
|
|
8
11
|
/** A focused empty or unavailable state with an optional next action. */
|
|
9
|
-
export declare function ContentUnavailableView({ title, description, icon, actions, className, ...props }: ContentUnavailableViewProps): import("react").JSX.Element;
|
|
12
|
+
export declare function ContentUnavailableView({ title, description, icon, actions, size, className, ...props }: ContentUnavailableViewProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { type ComponentProps } from "react";
|
|
2
|
-
export
|
|
2
|
+
export type ProfileImageSize = "sm" | "md" | "lg";
|
|
3
|
+
export interface ProfileImageProps extends ComponentProps<"span"> {
|
|
4
|
+
/** Avatar diameter; fallback initials scale with it. @default "md" */
|
|
5
|
+
size?: ProfileImageSize;
|
|
6
|
+
}
|
|
7
|
+
export declare function ProfileImage({ size, className, ...props }: ProfileImageProps): import("react").JSX.Element;
|
|
3
8
|
export declare function ProfileImageContent({ src, className, onLoad, onError, ...props }: ComponentProps<"img">): import("react").JSX.Element | null;
|
|
4
9
|
export declare function ProfileImageFallback({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element | null;
|
package/package.json
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import type { ReactNode, ComponentProps } from "react"
|
|
2
2
|
import { cn } from "../../lib/class-names"
|
|
3
3
|
|
|
4
|
+
export type ContentUnavailableViewSize = "sm" | "md" | "lg"
|
|
5
|
+
|
|
6
|
+
const titleSizes: Record<ContentUnavailableViewSize, string> = {
|
|
7
|
+
sm: "text-subheadline",
|
|
8
|
+
md: "text-headline",
|
|
9
|
+
lg: "text-title3",
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const descriptionSizes: Record<ContentUnavailableViewSize, string> = {
|
|
13
|
+
sm: "text-caption",
|
|
14
|
+
md: "text-footnote",
|
|
15
|
+
lg: "text-subheadline",
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const spacings: Record<ContentUnavailableViewSize, string> = {
|
|
19
|
+
sm: "gap-2 px-6 py-6",
|
|
20
|
+
md: "gap-3 px-6 py-10",
|
|
21
|
+
lg: "gap-4 px-6 py-14",
|
|
22
|
+
}
|
|
23
|
+
|
|
4
24
|
export interface ContentUnavailableViewProps extends Omit<ComponentProps<"div">, "title"> {
|
|
5
25
|
title: string
|
|
6
26
|
description?: string
|
|
7
27
|
icon?: ReactNode
|
|
8
28
|
actions?: ReactNode
|
|
29
|
+
/** Title, description and vertical rhythm. @default "md" */
|
|
30
|
+
size?: ContentUnavailableViewSize
|
|
9
31
|
}
|
|
10
32
|
|
|
11
33
|
/** A focused empty or unavailable state with an optional next action. */
|
|
@@ -14,22 +36,25 @@ export function ContentUnavailableView({
|
|
|
14
36
|
description,
|
|
15
37
|
icon,
|
|
16
38
|
actions,
|
|
39
|
+
size = "md",
|
|
17
40
|
className,
|
|
18
41
|
...props
|
|
19
42
|
}: ContentUnavailableViewProps) {
|
|
20
43
|
return (
|
|
21
44
|
<div
|
|
22
45
|
{...props}
|
|
23
|
-
className={cn("flex flex-col items-center
|
|
46
|
+
className={cn("flex flex-col items-center text-center", spacings[size], className)}
|
|
24
47
|
>
|
|
25
48
|
{icon && (
|
|
26
49
|
<span aria-hidden="true" className="text-label-tertiary">
|
|
27
50
|
{icon}
|
|
28
51
|
</span>
|
|
29
52
|
)}
|
|
30
|
-
<p className="
|
|
53
|
+
<p className={cn(titleSizes[size], "font-semibold text-label")}>{title}</p>
|
|
31
54
|
{description && (
|
|
32
|
-
<p className="max-w-sm text-
|
|
55
|
+
<p className={cn(descriptionSizes[size], "max-w-sm text-label-secondary")}>
|
|
56
|
+
{description}
|
|
57
|
+
</p>
|
|
33
58
|
)}
|
|
34
59
|
{actions && <div className="mt-1 flex flex-wrap justify-center gap-2">{actions}</div>}
|
|
35
60
|
</div>
|
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
import { createContext, useContext, useEffect, useState, type ComponentProps } from "react"
|
|
2
2
|
import { cn } from "../../lib/class-names"
|
|
3
3
|
|
|
4
|
+
export type ProfileImageSize = "sm" | "md" | "lg"
|
|
5
|
+
|
|
6
|
+
const diameters: Record<ProfileImageSize, string> = {
|
|
7
|
+
sm: "size-7",
|
|
8
|
+
md: "size-9",
|
|
9
|
+
lg: "size-12",
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const fallbackTextSizes: Record<ProfileImageSize, string> = {
|
|
13
|
+
sm: "text-caption",
|
|
14
|
+
md: "text-footnote",
|
|
15
|
+
lg: "text-subheadline",
|
|
16
|
+
}
|
|
17
|
+
|
|
4
18
|
const ImageContext = createContext<{
|
|
5
19
|
loaded: boolean
|
|
6
20
|
setLoaded: (loaded: boolean) => void
|
|
7
|
-
|
|
8
|
-
|
|
21
|
+
size: ProfileImageSize
|
|
22
|
+
}>({ loaded: false, setLoaded: () => {}, size: "md" })
|
|
23
|
+
|
|
24
|
+
export interface ProfileImageProps extends ComponentProps<"span"> {
|
|
25
|
+
/** Avatar diameter; fallback initials scale with it. @default "md" */
|
|
26
|
+
size?: ProfileImageSize
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function ProfileImage({ size = "md", className, ...props }: ProfileImageProps) {
|
|
9
30
|
const [loaded, setLoaded] = useState(false)
|
|
10
31
|
return (
|
|
11
|
-
<ImageContext value={{ loaded, setLoaded }}>
|
|
32
|
+
<ImageContext value={{ loaded, setLoaded, size }}>
|
|
12
33
|
<span
|
|
13
34
|
{...props}
|
|
14
35
|
className={cn(
|
|
15
|
-
"relative inline-flex
|
|
36
|
+
"relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-fill text-label-secondary",
|
|
37
|
+
diameters[size],
|
|
16
38
|
className
|
|
17
39
|
)}
|
|
18
40
|
/>
|
|
@@ -51,8 +73,8 @@ export function ProfileImageContent({
|
|
|
51
73
|
)
|
|
52
74
|
}
|
|
53
75
|
export function ProfileImageFallback({ className, ...props }: ComponentProps<"span">) {
|
|
54
|
-
const { loaded } = useContext(ImageContext)
|
|
76
|
+
const { loaded, size } = useContext(ImageContext)
|
|
55
77
|
return loaded ? null : (
|
|
56
|
-
<span {...props} className={cn("
|
|
78
|
+
<span {...props} className={cn(fallbackTextSizes[size], "font-medium", className)} />
|
|
57
79
|
)
|
|
58
80
|
}
|