@indietabletop/appkit 3.2.0-11 → 3.2.0-12
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/DialogTrigger/index.tsx +36 -0
- package/lib/Letterhead/style.css.ts +10 -2
- package/lib/index.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DialogProvider,
|
|
3
|
+
useDialogContext,
|
|
4
|
+
useStoreState,
|
|
5
|
+
} from "@ariakit/react";
|
|
6
|
+
import type { ReactElement, ReactNode } from "react";
|
|
7
|
+
|
|
8
|
+
function DialogGuard(props: { children: ReactNode }) {
|
|
9
|
+
const dialog = useDialogContext();
|
|
10
|
+
const isMounted = useStoreState(dialog, (store) => store?.mounted);
|
|
11
|
+
if (!isMounted) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return props.children;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Wraps AriaKit's DialogProvider, but take a tuple of Dialog a DialogDisclosure
|
|
19
|
+
* elements as children, and makes sense that the Dialog component is not
|
|
20
|
+
* rendered when it is hidden.
|
|
21
|
+
*
|
|
22
|
+
* This is important in cases where the dialog contains a form that should only
|
|
23
|
+
* be initialized and re-initialized when the dialog opens, not when it is first
|
|
24
|
+
* rendered.
|
|
25
|
+
*/
|
|
26
|
+
export function DialogTrigger(props: {
|
|
27
|
+
children: [ReactElement, ReactElement];
|
|
28
|
+
}) {
|
|
29
|
+
const [dialog, button] = props.children;
|
|
30
|
+
return (
|
|
31
|
+
<DialogProvider>
|
|
32
|
+
<DialogGuard>{dialog}</DialogGuard>
|
|
33
|
+
{button}
|
|
34
|
+
</DialogProvider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -2,7 +2,7 @@ import { createTheme, style } from "@vanilla-extract/css";
|
|
|
2
2
|
import { recipe } from "@vanilla-extract/recipes";
|
|
3
3
|
import { textVariants } from "../atomic.css.ts";
|
|
4
4
|
import { manofa, minion } from "../common.css.ts";
|
|
5
|
-
import { Hover } from "../media.ts";
|
|
5
|
+
import { Hover, MinWidth } from "../media.ts";
|
|
6
6
|
|
|
7
7
|
const align = {
|
|
8
8
|
start: textVariants({ textAlign: "start" }),
|
|
@@ -11,7 +11,7 @@ const align = {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const [letterheadTheme, { padding, footerMargin }] = createTheme({
|
|
14
|
-
padding: "
|
|
14
|
+
padding: "1.25rem",
|
|
15
15
|
footerMargin: "3rem",
|
|
16
16
|
});
|
|
17
17
|
|
|
@@ -25,6 +25,14 @@ export const letterhead = recipe({
|
|
|
25
25
|
borderRadius: "1rem",
|
|
26
26
|
marginInline: "auto",
|
|
27
27
|
maxInlineSize: "36rem",
|
|
28
|
+
|
|
29
|
+
"@media": {
|
|
30
|
+
[MinWidth.SMALL]: {
|
|
31
|
+
vars: {
|
|
32
|
+
[padding]: `clamp(1.5rem, 8%, 4rem)`,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
28
36
|
},
|
|
29
37
|
],
|
|
30
38
|
|
package/lib/index.ts
CHANGED