@authdog/react-elements 0.0.39 → 0.0.42
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/.eslintrc.js +1 -1
- package/.storybook/main.ts +21 -0
- package/.storybook/preview.ts +17 -0
- package/.storybook/vitest.setup.ts +7 -0
- package/.turbo/turbo-build.log +45 -42
- package/CHANGELOG.md +18 -0
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/alert.mjs.map +1 -1
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/avatar.mjs.map +1 -1
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/badge.mjs.map +1 -1
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/dropdown-menu.mjs +1 -1
- package/dist/components/ui/dropdown-menu.mjs.map +1 -1
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/input.mjs.map +1 -1
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sheet.mjs.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +218 -8
- package/package.json +25 -14
- package/src/components/core/client-only.tsx +10 -15
- package/src/components/core/navbar.tsx +81 -50
- package/src/components/core/placeholder-alert.tsx +7 -9
- package/src/components/core/user-dropdown.tsx +117 -57
- package/src/components/core/user-profile.tsx +180 -86
- package/src/components/flow/login.tsx +42 -29
- package/src/components/flow/totp-validator.tsx +94 -73
- package/src/components/icons.tsx +15 -21
- package/src/components/ui/alert.tsx +11 -11
- package/src/components/ui/avatar.tsx +10 -10
- package/src/components/ui/badge.tsx +9 -9
- package/src/components/ui/card.tsx +13 -13
- package/src/components/ui/dropdown-menu.tsx +214 -211
- package/src/components/ui/input.tsx +5 -5
- package/src/components/ui/label.tsx +7 -7
- package/src/components/ui/separator.tsx +7 -7
- package/src/components/ui/sheet.tsx +21 -21
- package/src/index.ts +6 -6
- package/src/stories/core/Navbar.stories.tsx +45 -0
- package/src/stories/core/PlaceholderAlert.stories.tsx +23 -0
- package/src/stories/core/UserDropdown.stories.tsx +56 -0
- package/src/stories/core/UserProfile.stories.tsx +47 -0
- package/src/stories/flow/LoginForm.stories.tsx +20 -0
- package/src/stories/flow/TotpValidator.stories.tsx +23 -0
- package/src/stories/showcase/Landing.stories.tsx +376 -0
- package/src/stories/ui/Button.stories.tsx +45 -0
- package/tsup.config.ts +6 -9
- package/vitest.config.ts +39 -0
- package/vitest.shims.d.ts +1 -0
- package/wrangler.prod.toml +4 -0
- package/ladle.config.mjs +0 -21
- package/src/main.tsx +0 -11
- package/src/preview.tsx +0 -11
- package/src/stories/Button._stories.tsx +0 -24
- package/src/stories/LoginForm.stories.tsx +0 -29
- package/src/stories/Navbar._stories.tsx +0 -28
- package/src/stories/PlaceholderAlert._stories.tsx +0 -13
- package/src/stories/TotpValidator.stories.tsx +0 -14
- package/src/stories/UserDropdown.stories.tsx +0 -36
- package/src/stories/UserProfile.stories.tsx +0 -46
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use client"
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import * as SheetPrimitive from "@radix-ui/react-dialog"
|
|
5
|
-
import { X } from "lucide-react"
|
|
6
|
-
import type { ComponentType } from "react"
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as SheetPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
import { X } from "lucide-react";
|
|
6
|
+
import type { ComponentType } from "react";
|
|
7
7
|
|
|
8
|
-
import { cn } from "
|
|
8
|
+
import { cn } from "../../lib/utils";
|
|
9
9
|
|
|
10
|
-
const XIcon = X as ComponentType<React.SVGProps<SVGSVGElement
|
|
10
|
+
const XIcon = X as ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
11
11
|
|
|
12
12
|
function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
|
|
13
|
-
return <SheetPrimitive.Root data-slot="sheet" {...props}
|
|
13
|
+
return <SheetPrimitive.Root data-slot="sheet" {...props} />;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function SheetTrigger({
|
|
17
17
|
...props
|
|
18
18
|
}: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
|
|
19
|
-
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props}
|
|
19
|
+
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function SheetClose({
|
|
23
23
|
...props
|
|
24
24
|
}: React.ComponentProps<typeof SheetPrimitive.Close>) {
|
|
25
|
-
return <SheetPrimitive.Close data-slot="sheet-close" {...props}
|
|
25
|
+
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function SheetPortal({
|
|
29
29
|
...props
|
|
30
30
|
}: React.ComponentProps<typeof SheetPrimitive.Portal>) {
|
|
31
|
-
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props}
|
|
31
|
+
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function SheetOverlay({
|
|
@@ -40,11 +40,11 @@ function SheetOverlay({
|
|
|
40
40
|
data-slot="sheet-overlay"
|
|
41
41
|
className={cn(
|
|
42
42
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
43
|
-
className
|
|
43
|
+
className,
|
|
44
44
|
)}
|
|
45
45
|
{...props}
|
|
46
46
|
/>
|
|
47
|
-
)
|
|
47
|
+
);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function SheetContent({
|
|
@@ -53,7 +53,7 @@ function SheetContent({
|
|
|
53
53
|
side = "right",
|
|
54
54
|
...props
|
|
55
55
|
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
|
|
56
|
-
side?: "top" | "right" | "bottom" | "left"
|
|
56
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
57
57
|
}) {
|
|
58
58
|
return (
|
|
59
59
|
<SheetPortal>
|
|
@@ -70,7 +70,7 @@ function SheetContent({
|
|
|
70
70
|
"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
|
|
71
71
|
side === "bottom" &&
|
|
72
72
|
"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
|
|
73
|
-
className
|
|
73
|
+
className,
|
|
74
74
|
)}
|
|
75
75
|
{...props}
|
|
76
76
|
>
|
|
@@ -81,7 +81,7 @@ function SheetContent({
|
|
|
81
81
|
</SheetPrimitive.Close>
|
|
82
82
|
</SheetPrimitive.Content>
|
|
83
83
|
</SheetPortal>
|
|
84
|
-
)
|
|
84
|
+
);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -91,7 +91,7 @@ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
91
91
|
className={cn("flex flex-col gap-1.5 p-4", className)}
|
|
92
92
|
{...props}
|
|
93
93
|
/>
|
|
94
|
-
)
|
|
94
|
+
);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -101,7 +101,7 @@ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
101
101
|
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
|
|
102
102
|
{...props}
|
|
103
103
|
/>
|
|
104
|
-
)
|
|
104
|
+
);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
function SheetTitle({
|
|
@@ -114,7 +114,7 @@ function SheetTitle({
|
|
|
114
114
|
className={cn("text-foreground font-semibold", className)}
|
|
115
115
|
{...props}
|
|
116
116
|
/>
|
|
117
|
-
)
|
|
117
|
+
);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
function SheetDescription({
|
|
@@ -127,7 +127,7 @@ function SheetDescription({
|
|
|
127
127
|
className={cn("text-muted-foreground text-sm", className)}
|
|
128
128
|
{...props}
|
|
129
129
|
/>
|
|
130
|
-
)
|
|
130
|
+
);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
export {
|
|
@@ -139,4 +139,4 @@ export {
|
|
|
139
139
|
SheetFooter,
|
|
140
140
|
SheetTitle,
|
|
141
141
|
SheetDescription,
|
|
142
|
-
}
|
|
142
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {Button} from "./components/ui/button";
|
|
1
|
+
export { Button } from "./components/ui/button";
|
|
2
2
|
export { ClientOnly } from "./components/core/client-only";
|
|
3
|
-
export {Navbar} from "./components/core/navbar";
|
|
4
|
-
export {UserProfile} from "./components/core/user-profile";
|
|
5
|
-
export {UserDropdown} from "./components/core/user-dropdown";
|
|
6
|
-
export {PlaceholderAlert} from "./components/core/placeholder-alert";
|
|
7
|
-
export {TOTPValidator} from "./components/flow/totp-validator";
|
|
3
|
+
export { Navbar } from "./components/core/navbar";
|
|
4
|
+
export { UserProfile } from "./components/core/user-profile";
|
|
5
|
+
export { UserDropdown } from "./components/core/user-dropdown";
|
|
6
|
+
export { PlaceholderAlert } from "./components/core/placeholder-alert";
|
|
7
|
+
export { TOTPValidator } from "./components/flow/totp-validator";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { Navbar } from "../../components/core/navbar";
|
|
6
|
+
import React from "react";
|
|
7
|
+
|
|
8
|
+
const demoItems = [
|
|
9
|
+
{ title: "Home", href: "/" },
|
|
10
|
+
{ title: "Features", href: "/features" },
|
|
11
|
+
{ title: "Pricing", href: "/pricing" },
|
|
12
|
+
{ title: "Contact", href: "/contact" },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const demoUser = {
|
|
16
|
+
id: "user_123",
|
|
17
|
+
displayName: "Avery Stone",
|
|
18
|
+
emails: [{ value: "avery.stone@example.com" }],
|
|
19
|
+
photos: [{ value: "https://i.pravatar.cc/120?img=56" }],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const meta = {
|
|
23
|
+
title: "Core/Navbar",
|
|
24
|
+
component: Navbar,
|
|
25
|
+
tags: ["autodocs"],
|
|
26
|
+
parameters: {
|
|
27
|
+
layout: "fullscreen",
|
|
28
|
+
},
|
|
29
|
+
args: {
|
|
30
|
+
logoText: "Authdog",
|
|
31
|
+
items: demoItems,
|
|
32
|
+
},
|
|
33
|
+
} satisfies Meta<typeof Navbar>;
|
|
34
|
+
|
|
35
|
+
export default meta;
|
|
36
|
+
|
|
37
|
+
type Story = StoryObj<typeof Navbar>;
|
|
38
|
+
|
|
39
|
+
export const Guest: Story = {};
|
|
40
|
+
|
|
41
|
+
export const Authenticated: Story = {
|
|
42
|
+
args: {
|
|
43
|
+
user: demoUser,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { PlaceholderAlert } from "../../components/core/placeholder-alert";
|
|
6
|
+
import React from "react";
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "Core/Placeholder Alert",
|
|
10
|
+
component: PlaceholderAlert,
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
} satisfies Meta<typeof PlaceholderAlert>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof PlaceholderAlert>;
|
|
17
|
+
|
|
18
|
+
export const Basic: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
title: "Custom Alert Title",
|
|
21
|
+
description: "This is a custom description for the placeholder alert.",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { UserDropdown } from "../../components/core/user-dropdown";
|
|
6
|
+
import {
|
|
7
|
+
Avatar,
|
|
8
|
+
AvatarFallback,
|
|
9
|
+
AvatarImage,
|
|
10
|
+
} from "../../components/ui/avatar";
|
|
11
|
+
import React from "react";
|
|
12
|
+
|
|
13
|
+
const demoUser = {
|
|
14
|
+
displayName: "Jane Doe",
|
|
15
|
+
emails: [{ value: "jane.doe@example.com" }],
|
|
16
|
+
photos: [{ value: "https://i.pravatar.cc/100" }],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const trigger = (
|
|
20
|
+
<span className="inline-flex h-10 w-10 items-center justify-center rounded-full border bg-white shadow">
|
|
21
|
+
<Avatar className="h-8 w-8 rounded-full">
|
|
22
|
+
<AvatarImage src="https://i.pravatar.cc/100" />
|
|
23
|
+
<AvatarFallback>JD</AvatarFallback>
|
|
24
|
+
</Avatar>
|
|
25
|
+
</span>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const meta = {
|
|
29
|
+
title: "Core/User Dropdown",
|
|
30
|
+
component: UserDropdown,
|
|
31
|
+
tags: ["autodocs"],
|
|
32
|
+
parameters: {
|
|
33
|
+
layout: "centered",
|
|
34
|
+
},
|
|
35
|
+
render: (args) => (
|
|
36
|
+
<div className="p-10">
|
|
37
|
+
<UserDropdown {...args} />
|
|
38
|
+
</div>
|
|
39
|
+
),
|
|
40
|
+
} satisfies Meta<typeof UserDropdown>;
|
|
41
|
+
|
|
42
|
+
export default meta;
|
|
43
|
+
|
|
44
|
+
type Story = StoryObj<typeof UserDropdown>;
|
|
45
|
+
|
|
46
|
+
export const Default: Story = {
|
|
47
|
+
args: {
|
|
48
|
+
trigger,
|
|
49
|
+
user: demoUser,
|
|
50
|
+
links: [{ label: "My Organizations", href: "/organizations" }],
|
|
51
|
+
side: "bottom",
|
|
52
|
+
align: "start",
|
|
53
|
+
onManageAccount: () => console.log("Manage account"),
|
|
54
|
+
onSignout: () => console.log("Sign out"),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { UserProfile } from "../../components/core/user-profile";
|
|
6
|
+
import React from "react";
|
|
7
|
+
|
|
8
|
+
const baseUser = {
|
|
9
|
+
id: "user_123",
|
|
10
|
+
displayName: "Jane Doe",
|
|
11
|
+
provider: "google-oauth20",
|
|
12
|
+
emails: [{ id: "e1", value: "jane.primary@example.com" }],
|
|
13
|
+
verifications: [],
|
|
14
|
+
photos: [],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const meta = {
|
|
18
|
+
title: "Core/User Profile",
|
|
19
|
+
component: UserProfile,
|
|
20
|
+
tags: ["autodocs"],
|
|
21
|
+
parameters: {
|
|
22
|
+
layout: "fullscreen",
|
|
23
|
+
},
|
|
24
|
+
render: (args) => (
|
|
25
|
+
<div className="bg-background p-6 text-foreground">
|
|
26
|
+
<UserProfile {...args} />
|
|
27
|
+
</div>
|
|
28
|
+
),
|
|
29
|
+
} satisfies Meta<typeof UserProfile>;
|
|
30
|
+
|
|
31
|
+
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<typeof UserProfile>;
|
|
34
|
+
|
|
35
|
+
export const Loaded: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
loading: false,
|
|
38
|
+
user: baseUser,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const Loading: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
loading: true,
|
|
45
|
+
user: baseUser,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { LoginForm } from "../../components/flow/login";
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: "Flows/Login Form",
|
|
9
|
+
component: LoginForm,
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: "fullscreen",
|
|
13
|
+
},
|
|
14
|
+
} satisfies Meta<typeof LoginForm>;
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
|
|
18
|
+
type Story = StoryObj<typeof LoginForm>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { TOTPValidator } from "../../components/flow/totp-validator";
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: "Flows/TOTP Validator",
|
|
9
|
+
component: TOTPValidator,
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
} satisfies Meta<typeof TOTPValidator>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof TOTPValidator>;
|
|
16
|
+
|
|
17
|
+
export const Default: Story = {
|
|
18
|
+
args: {
|
|
19
|
+
onValidate: async (code: string) => {
|
|
20
|
+
console.log("TOTP submitted", code);
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|