@indietabletop/appkit 3.2.0-12 → 3.2.0-14
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/lib/ModalDialog/index.tsx +28 -0
- package/lib/ModalDialog/style.css.ts +87 -0
- package/lib/failureMessages.ts +39 -28
- package/lib/index.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Dialog, type DialogProps } from "@ariakit/react";
|
|
2
|
+
import type { RecipeVariants } from "@vanilla-extract/recipes";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import { cx } from "../class-names.ts";
|
|
5
|
+
import * as css from "./style.css.ts";
|
|
6
|
+
|
|
7
|
+
type Size = NonNullable<NonNullable<RecipeVariants<typeof css.dialog>>["size"]>;
|
|
8
|
+
|
|
9
|
+
export type ModalDialogProps = Omit<DialogProps, "modal" | "backdrop"> & {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
size: Size;
|
|
12
|
+
backdropClassName?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function ModalDialog(props: ModalDialogProps) {
|
|
16
|
+
const { size, backdropClassName, className, ...dialogProps } = props;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Dialog
|
|
20
|
+
{...dialogProps}
|
|
21
|
+
{...cx(className, css.dialog({ size }))}
|
|
22
|
+
backdrop={<div {...cx(css.backdrop, backdropClassName)} />}
|
|
23
|
+
modal
|
|
24
|
+
>
|
|
25
|
+
{props.children}
|
|
26
|
+
</Dialog>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { style } from "@vanilla-extract/css";
|
|
2
|
+
import { recipe } from "@vanilla-extract/recipes";
|
|
3
|
+
import { MinWidth } from "../media.ts";
|
|
4
|
+
|
|
5
|
+
const scaleTransition = {
|
|
6
|
+
transition: "transform 200ms, opacity 200ms",
|
|
7
|
+
transform: "scale(1.1)",
|
|
8
|
+
|
|
9
|
+
selectors: {
|
|
10
|
+
"&[data-enter]": {
|
|
11
|
+
opacity: 1,
|
|
12
|
+
transform: "scale(1)",
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
"&[data-leave]": {
|
|
16
|
+
opacity: 0,
|
|
17
|
+
transform: "scale(0.9)",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const translateTransition = {
|
|
23
|
+
transition: "transform 200ms, opacity 200ms",
|
|
24
|
+
transform: "translateY(5rem)",
|
|
25
|
+
|
|
26
|
+
selectors: {
|
|
27
|
+
"&[data-enter]": {
|
|
28
|
+
opacity: 1,
|
|
29
|
+
transform: "translateY(0)",
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
"&[data-leave]": {
|
|
33
|
+
opacity: 0,
|
|
34
|
+
transform: "translateY(5rem)",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const dialog = recipe({
|
|
40
|
+
base: {
|
|
41
|
+
position: "fixed",
|
|
42
|
+
inset: 0,
|
|
43
|
+
zIndex: 100,
|
|
44
|
+
margin: "auto",
|
|
45
|
+
overflow: "auto",
|
|
46
|
+
opacity: 0,
|
|
47
|
+
backgroundColor: "white",
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
variants: {
|
|
51
|
+
size: {
|
|
52
|
+
large: {
|
|
53
|
+
...translateTransition,
|
|
54
|
+
inlineSize: "100%",
|
|
55
|
+
blockSize: "100%",
|
|
56
|
+
|
|
57
|
+
"@media": {
|
|
58
|
+
[MinWidth.MEDIUM]: {
|
|
59
|
+
...scaleTransition,
|
|
60
|
+
blockSize: "fit-content",
|
|
61
|
+
maxInlineSize: "40rem",
|
|
62
|
+
maxBlockSize: "90%",
|
|
63
|
+
borderRadius: "1rem",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
small: {
|
|
69
|
+
...scaleTransition,
|
|
70
|
+
inlineSize: "min(24rem, 90svw)",
|
|
71
|
+
blockSize: "fit-content",
|
|
72
|
+
borderRadius: "1rem",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const backdrop = style({
|
|
79
|
+
backgroundColor: "black",
|
|
80
|
+
opacity: 0,
|
|
81
|
+
transition: "opacity 200ms",
|
|
82
|
+
selectors: {
|
|
83
|
+
"&[data-enter]": {
|
|
84
|
+
opacity: 0.4,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
package/lib/failureMessages.ts
CHANGED
|
@@ -40,41 +40,52 @@ export type FetchFailureAction =
|
|
|
40
40
|
label: string;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export type
|
|
43
|
+
export type FetchFailureMessages = {
|
|
44
44
|
title: string;
|
|
45
45
|
description: string;
|
|
46
46
|
action: FetchFailureAction;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
export const getFetchFailureMessages =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
export const getFetchFailureMessages =
|
|
50
|
+
createFailureMessageGetter<FetchFailureMessages>(
|
|
51
|
+
{
|
|
52
|
+
401: {
|
|
53
|
+
title: "Not logged in",
|
|
54
|
+
description: "You must be logged in to view this page.",
|
|
55
|
+
action: { type: "LINK", href: "~/login", label: "Go to login" },
|
|
56
|
+
},
|
|
57
|
+
403: {
|
|
58
|
+
title: "Not authorized",
|
|
59
|
+
description: "You might be logged into the wrong account.",
|
|
60
|
+
action: { type: "LINK", href: "~/login", label: "Go to login" },
|
|
61
|
+
},
|
|
62
|
+
404: {
|
|
63
|
+
title: `Not found`,
|
|
64
|
+
description: `The link you have followed might be broken.`,
|
|
65
|
+
action: { type: "LINK", href: "~/", label: "Go back" },
|
|
66
|
+
},
|
|
67
|
+
500: {
|
|
68
|
+
title: `Ooops, something went wrong`,
|
|
69
|
+
description: `This is probably an issue with our servers. You can try refreshing.`,
|
|
70
|
+
action: { type: "RELOAD", label: "Reload app" },
|
|
71
|
+
},
|
|
72
|
+
connection: {
|
|
73
|
+
title: `No connection`,
|
|
74
|
+
description: `Check your interent connection and try again.`,
|
|
75
|
+
action: { type: "REFETCH", label: "Retry request" },
|
|
76
|
+
},
|
|
77
|
+
fallback: {
|
|
78
|
+
title: `Ooops, something went wrong`,
|
|
79
|
+
description: `This is probably an issue on our side. You can try refreshing.`,
|
|
80
|
+
action: { type: "RELOAD", label: "Reload app" },
|
|
81
|
+
},
|
|
65
82
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
{
|
|
84
|
+
onOverride(fallback, override) {
|
|
85
|
+
return { ...fallback, ...override };
|
|
86
|
+
},
|
|
70
87
|
},
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
onOverride(fallback, override) {
|
|
74
|
-
return { ...fallback, ...override };
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
);
|
|
88
|
+
);
|
|
78
89
|
|
|
79
90
|
export const getSubmitFailureMessage = createFailureMessageGetter(
|
|
80
91
|
{
|
package/lib/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./IndieTabletopClubSymbol.tsx";
|
|
|
7
7
|
export * from "./Letterhead/index.tsx";
|
|
8
8
|
export * from "./LetterheadForm/index.tsx";
|
|
9
9
|
export * from "./LoadingIndicator.tsx";
|
|
10
|
+
export * from "./ModalDialog/index.tsx";
|
|
10
11
|
export * from "./ServiceWorkerHandler.tsx";
|
|
11
12
|
|
|
12
13
|
// Hooks
|