@loopbacktools/inbox 0.0.0-stage → 0.4.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.
package/src/update.tsx ADDED
@@ -0,0 +1,39 @@
1
+ import { Banner } from "@cloudflare/kumo";
2
+ import { ArrowClockwise } from "@phosphor-icons/react";
3
+ import { useEffect } from "react";
4
+ import { useUpdate } from "./context.tsx";
5
+ import { reloadPage } from "./page.ts";
6
+
7
+ /**
8
+ * Says when Loopback has been updated under the page. A later deploy of the same revision of the
9
+ * contract is offered as a reload. A later revision is one this page can't fully read, so it reloads
10
+ * at the first moment that disturbs no one: as soon as the page is hidden, or at once if it already
11
+ * is. What the person has written and not sent is kept in this browser, so the reload loses none of it.
12
+ */
13
+ export function UpdateBanner() {
14
+ const update = useUpdate();
15
+ useEffect(() => {
16
+ if (update !== "required") return undefined;
17
+ const whenHidden = () => {
18
+ if (document.visibilityState === "hidden") reloadPage();
19
+ };
20
+ whenHidden();
21
+ document.addEventListener("visibilitychange", whenHidden);
22
+ return () => document.removeEventListener("visibilitychange", whenHidden);
23
+ }, [update]);
24
+ if (update === "none") return null;
25
+ return (
26
+ <Banner
27
+ size="sm"
28
+ className="m-2"
29
+ icon={<ArrowClockwise />}
30
+ title="Loopback has been updated"
31
+ description={
32
+ update === "required"
33
+ ? "This page reloads onto the new version when you next leave it. Anything you haven't sent is kept."
34
+ : "Reload to use the new version."
35
+ }
36
+ action={<Banner.Action onClick={reloadPage}>Reload</Banner.Action>}
37
+ />
38
+ );
39
+ }
package/styles.css ADDED
@@ -0,0 +1,72 @@
1
+ /*
2
+ * The inbox's styles. Import this after Tailwind and Kumo's theme: it has Tailwind generate the
3
+ * utilities the components use, and styles the Markdown agents write.
4
+ */
5
+ @source "./src";
6
+
7
+ /* Markdown an agent wrote: quiet, readable prose. */
8
+ .loopback-markdown {
9
+ line-height: 1.6;
10
+ overflow-wrap: anywhere;
11
+ }
12
+ .loopback-markdown > * + * {
13
+ margin-top: 0.75em;
14
+ }
15
+ .loopback-markdown h1,
16
+ .loopback-markdown h2,
17
+ .loopback-markdown h3 {
18
+ font-weight: 600;
19
+ line-height: 1.3;
20
+ color: var(--text-color-kumo-strong);
21
+ }
22
+ .loopback-markdown h1 {
23
+ font-size: 1.25rem;
24
+ }
25
+ .loopback-markdown h2 {
26
+ font-size: 1.125rem;
27
+ }
28
+ .loopback-markdown h3 {
29
+ font-size: 1rem;
30
+ }
31
+ .loopback-markdown ul {
32
+ list-style: disc;
33
+ padding-left: 1.25rem;
34
+ }
35
+ .loopback-markdown ol {
36
+ list-style: decimal;
37
+ padding-left: 1.25rem;
38
+ }
39
+ .loopback-markdown li + li {
40
+ margin-top: 0.25em;
41
+ }
42
+ .loopback-markdown a {
43
+ color: var(--text-color-kumo-link);
44
+ text-decoration: underline;
45
+ text-underline-offset: 2px;
46
+ }
47
+ .loopback-markdown blockquote {
48
+ border-left: 3px solid var(--color-kumo-line);
49
+ padding-left: 0.75rem;
50
+ color: var(--text-color-kumo-subtle);
51
+ }
52
+ .loopback-markdown :not(pre) > code {
53
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
54
+ font-size: 0.875em;
55
+ padding: 0.1em 0.35em;
56
+ border-radius: 4px;
57
+ background: var(--color-kumo-recessed);
58
+ }
59
+ .loopback-markdown table {
60
+ border-collapse: collapse;
61
+ font-size: 0.875rem;
62
+ }
63
+ .loopback-markdown th,
64
+ .loopback-markdown td {
65
+ border: 1px solid var(--color-kumo-line);
66
+ padding: 0.35rem 0.6rem;
67
+ text-align: left;
68
+ }
69
+ .loopback-markdown hr {
70
+ border: 0;
71
+ border-top: 1px solid var(--color-kumo-line);
72
+ }