Skip to content

Commit 4dae538

Browse files
committed
Modularization of Modal Component:
- The Modal class has been replaced with more specialized components using Pydantic models for better state management (AlertDialogRef, ConfirmDialogRef) - Functions like use_alert_dialog, use_confirm_dialog, alert_dialog, and confirm_dialog manage modal states and rendering. Component Enhancements: - Added button_with_confirm_dialog to handle button interactions related to confirm dialogs. - The modal_scaffold function creates a standardized structure for modals, supporting large modals with appropriate bootstrap CSS classes. - Add Modal Animations Renderer Context Management: - Introduced current_root_ctx for handling the context of the current rendering tree. Utilizes thread-local storage for managing the root context, ensuring consistent state across renders. Error Handling: - Handle undefined loaderHeaders - Ignore network errors in sentry - Reduce UI layout change on lazy load Version Bump: - Updated the version from 0.1.1 to 0.2.0, indicating significant changes.
1 parent 5829529 commit 4dae538

File tree

14 files changed

+254
-129
lines changed

14 files changed

+254
-129
lines changed

app/base.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ import { lazyImport } from "./lazyImports";
2222
const { DataTable, DataTableRaw } = lazyImport(() => import("~/dataTable"));
2323

2424
const { GooeyFileInput } = lazyImport(() => import("~/gooeyFileInput"), {
25-
fallback: (
26-
<div
27-
className="gui-input d-flex align-items-center justify-content-center"
28-
style={{ height: "250px" }}
29-
>
30-
Loading...
25+
fallback: ({ label }) => (
26+
<div className="gui-input">
27+
{label && <RenderedMarkdown body={label} />}
28+
<div
29+
className="d-flex align-items-center justify-content-center bg-light"
30+
style={{ height: "250px" }}
31+
>
32+
Loading...
33+
</div>
3134
</div>
3235
),
3336
});

app/components/GooeySelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default function GooeySelect({
6161
<ClientOnlySuspense
6262
fallback={
6363
<div
64-
className="d-flex align-items-center justify-content-center"
64+
className="d-flex align-items-center justify-content-center border rounded"
6565
style={{ height: "38px" }}
6666
>
6767
Loading...

app/entry.client.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1-
import { useLocation, useMatches, RemixBrowser } from "@remix-run/react";
2-
import { hydrate } from "react-dom";
1+
import { RemixBrowser, useLocation, useMatches } from "@remix-run/react";
32
import * as Sentry from "@sentry/remix";
43
import { useEffect } from "react";
5-
import { HttpClient, Offline } from "@sentry/integrations";
4+
import { hydrate } from "react-dom";
65

76
Sentry.init({
87
dsn: window.ENV.SENTRY_DSN,
8+
release: window.ENV.SENTRY_RELEASE,
9+
environment: "client",
910
integrations: [
10-
new Sentry.BrowserTracing({
11-
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
12-
// tracePropagationTargets: ["localhost", /^https:\/\/gooey\.ai\/.*/],
13-
routingInstrumentation: Sentry.remixRouterInstrumentation(
14-
useEffect,
15-
useLocation,
16-
useMatches
17-
),
11+
Sentry.browserTracingIntegration({
12+
useEffect,
13+
useLocation,
14+
useMatches,
1815
}),
19-
new Sentry.Replay(),
20-
new HttpClient(),
16+
Sentry.replayIntegration(),
17+
Sentry.httpClientIntegration(),
2118
],
22-
release: window.ENV.SENTRY_RELEASE,
2319
// Performance Monitoring
2420
tracesSampleRate: 0.005, // Capture X% of the transactions, reduce in production!
2521
// Session Replay
2622
replaysSessionSampleRate: 0, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
2723
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
2824
// This option is required for capturing headers and cookies.
2925
sendDefaultPii: true,
26+
// To enable offline events caching, use makeBrowserOfflineTransport to wrap existing transports and queue events using the browsers' IndexedDB storage.
27+
// Once your application comes back online, all events will be sent together.
3028
transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
29+
// You can use the ignoreErrors option to filter out errors that match a certain pattern.
30+
ignoreErrors: [
31+
/TypeError: Failed to fetch/i,
32+
/TypeError: Load failed/i,
33+
/(network)(\s+)(error)/i,
34+
/AbortError/i,
35+
],
3136
});
3237

3338
hydrate(<RemixBrowser />, document);

app/entry.server.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import settings from "./settings";
88
if (settings.SENTRY_DSN) {
99
Sentry.init({
1010
dsn: settings.SENTRY_DSN,
11+
environment: "server",
1112
// Integrations:
1213
// e.g. new Sentry.Integrations.Prisma({ client: prisma })
1314
// Performance Monitoring:
@@ -42,8 +43,10 @@ export default function handleDocumentRequestFunction(
4243
<RemixServer context={remixContext} url={request.url} />
4344
);
4445

45-
for (let [key, value] of loaderHeaders.entries()) {
46-
responseHeaders.set(key, value);
46+
if (loaderHeaders) {
47+
for (let [key, value] of loaderHeaders.entries()) {
48+
responseHeaders.set(key, value);
49+
}
4750
}
4851
responseHeaders.delete("Content-Length");
4952
responseHeaders.set("Content-Type", "text/html");

app/global-progres-bar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const useGlobalProgress = () => {
1515
const fetchers = useFetchers();
1616

1717
useEffect(() => {
18+
if (!document.querySelector(parent)) return;
1819
NProgress.configure({ parent, trickleSpeed: 100 });
1920
}, []);
2021

app/lazyImports.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import LoadingFallback from "./loadingfallback";
44

55
export function lazyImport<T>(
66
loader: () => Promise<T>,
7-
{ fallback }: { fallback?: React.ReactNode } = {}
7+
{
8+
fallback,
9+
}: { fallback?: (props: Record<string, any>) => React.ReactNode } = {}
810
): T {
911
return new Proxy(
1012
{},
@@ -22,7 +24,7 @@ export function lazyImport<T>(
2224

2325
return (props: any) => {
2426
return (
25-
<ClientOnlySuspense fallback={fallback}>
27+
<ClientOnlySuspense fallback={fallback && fallback(props)}>
2628
{() => <Component {...props} />}
2729
</ClientOnlySuspense>
2830
);

app/renderedHTML.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export function RenderedHTML({
2222
return <RenderLocalDt body={body} {...attrs} />;
2323
}
2424

25-
const parsedElements = parse(body, reactParserOptions);
25+
if (typeof body !== "string") {
26+
body = JSON.stringify(body);
27+
}
28+
const parsedElements = parse(body || "", reactParserOptions);
2629
return (
2730
<LineClamp lines={lineClamp} key={body}>
2831
<span className="gui-html-container" {...attrs}>

app/root.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export default function App() {
7777
const reloadOnErrors = [
7878
"TypeError: Failed to fetch",
7979
"TypeError: Load failed",
80-
"A network error",
80+
"Network Error",
81+
"NetworkError",
8182
];
8283

8384
const ignoreErrors = ["AbortError"];

app/styles/custom.css

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,4 +753,30 @@ a.text-primary:hover {
753753
}
754754
.cm-lineNumbers .cm-gutterElement {
755755
min-width: 36px !important;
756-
}
756+
}
757+
758+
/* Modal animations */
759+
@keyframes popOut {
760+
0% {
761+
transform: scale(0.5);
762+
opacity: 0;
763+
}
764+
100% {
765+
transform: scale(1);
766+
opacity: 1;
767+
}
768+
}
769+
.modal-dialog {
770+
animation: popOut 0.2s forwards;
771+
}
772+
@keyframes fadeInBackground {
773+
0% {
774+
background-color: rgba(0, 0, 0, 0);
775+
}
776+
100% {
777+
background-color: rgba(0, 0, 0, 0.5);
778+
}
779+
}
780+
.modal {
781+
animation: fadeInBackground 1s forwards;
782+
}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
from .common import *
2-
from .modal import Modal
2+
from .modal import (
3+
AlertDialogRef,
4+
ConfirmDialogRef,
5+
use_alert_dialog,
6+
modal_scaffold,
7+
alert_dialog,
8+
use_confirm_dialog,
9+
confirm_dialog,
10+
button_with_confirm_dialog,
11+
)
312
from .pills import pill
413
from .url_button import url_button

0 commit comments

Comments
 (0)