feat(custom-widgets): Full Mantine v9 + SubFetch support for custom JSX (#6304)
This commit is contained in:
1 parent
cd71404288
commit
83e3b22f9a
181 files changed
+19956
-6479
No files matched your search
@@ -0,0 +1,73 @@
|
||||
import { Alert, Paper, SimpleGrid, Stack, Text } from "@mantine/core";
|
||||
import { IconAlertTriangle, IconCheck } from "@tabler/icons-react";
|
||||
|
||||
import type { EditorDiagnostic } from "./analyzer";
|
||||
|
||||
interface PreviewDiagnosticsMessages {
|
||||
templateSize: string;
|
||||
characters: (count: number) => string;
|
||||
namedRequests: string;
|
||||
methods: string;
|
||||
networkScope: string;
|
||||
ready: string;
|
||||
diagnostic: (diagnostic: EditorDiagnostic) => string;
|
||||
}
|
||||
|
||||
interface PreviewDiagnosticsPanelProps {
|
||||
templateLength: number;
|
||||
namedRequestCount: number;
|
||||
methods: string;
|
||||
networkScope: string;
|
||||
diagnostics: EditorDiagnostic[];
|
||||
messages: PreviewDiagnosticsMessages;
|
||||
}
|
||||
|
||||
export function PreviewDiagnosticsPanel({
|
||||
templateLength,
|
||||
namedRequestCount,
|
||||
methods,
|
||||
networkScope,
|
||||
diagnostics,
|
||||
messages,
|
||||
}: PreviewDiagnosticsPanelProps) {
|
||||
return (
|
||||
<Stack gap="xs">
|
||||
<SimpleGrid cols={2} spacing="xs">
|
||||
<DiagnosticFact label={messages.templateSize} value={messages.characters(templateLength)} />
|
||||
<DiagnosticFact label={messages.namedRequests} value={String(namedRequestCount)} />
|
||||
<DiagnosticFact label={messages.methods} value={methods} />
|
||||
<DiagnosticFact label={messages.networkScope} value={networkScope} />
|
||||
</SimpleGrid>
|
||||
{diagnostics.length === 0 ? (
|
||||
<Alert color="green" variant="light" p="xs" icon={<IconCheck size={15} />}>
|
||||
<Text size="xs">{messages.ready}</Text>
|
||||
</Alert>
|
||||
) : (
|
||||
diagnostics.map((diagnostic, index) => (
|
||||
<Alert
|
||||
key={`${diagnostic.code}-${index}`}
|
||||
color={diagnostic.severity === "error" ? "red" : "yellow"}
|
||||
variant="light"
|
||||
p="xs"
|
||||
icon={<IconAlertTriangle size={15} />}
|
||||
>
|
||||
<Text size="xs">{messages.diagnostic(diagnostic)}</Text>
|
||||
</Alert>
|
||||
))
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
function DiagnosticFact({ label, value }: { label: string; value: string }) {
|
||||
return (
|
||||
<Paper withBorder p="xs">
|
||||
<Text size="xs" c="dimmed">
|
||||
{label}
|
||||
</Text>
|
||||
<Text size="xs" fw={600} lineClamp={2}>
|
||||
{value || "—"}
|
||||
</Text>
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user