Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

feat(playground): add className prop for embeddable layouts (#1095)

Sarina Li4a95fe898d61
diff --git a/docs/scripts/check-links.ts b/docs/scripts/check-links.ts
index ba339b7985..93f2759532 100644
--- a/docs/scripts/check-links.ts
+++ b/docs/scripts/check-links.ts
@@ -12,12 +12,12 @@
* pnpm docs:check-links:external # Also check external links
*/
-import { readFiles, validateFiles, printErrors, type ScanResult } from "next-validate-link";
-import * as path from "path";
-import fg from "fast-glob";
+import { readFiles, validateFiles, printErrors, type ScanResult } from 'next-validate-link';
+import * as path from 'path';
+import fg from 'fast-glob';
-const DOCS_DIR = path.resolve(__dirname, "..");
-const CONTENT_DIR = path.join(DOCS_DIR, "content/docs");
+const DOCS_DIR = path.resolve(__dirname, '..');
+const CONTENT_DIR = path.join(DOCS_DIR, 'content/docs');
/**
* Build the ScanResult (valid URL map) directly from content files.
@@ -25,37 +25,35 @@ const CONTENT_DIR = path.join(DOCS_DIR, "content/docs");
*/
function buildScannedUrls(): ScanResult {
const urls = new Map<string, {}>();
- const mdxFiles = fg.sync("**/*.mdx", { cwd: CONTENT_DIR });
+ const mdxFiles = fg.sync('**/*.mdx', { cwd: CONTENT_DIR });
for (const file of mdxFiles) {
- const slug = file
- .replace(/\.mdx$/, "")
- .replace(/\/index$/, "");
+ const slug = file.replace(/\.mdx$/, '').replace(/\/index$/, '');
urls.set(`/${slug}`, {});
}
// Also add the root
- urls.set("/", {});
+ urls.set('/', {});
return { urls, fallbackUrls: [] };
}
function pathToUrl(filePath: string): string | undefined {
const slug = filePath
- .replace(/^content\/docs\//, "")
- .replace(/\.mdx$/, "")
- .replace(/\/index$/, "");
+ .replace(/^content\/docs\//, '')
+ .replace(/\.mdx$/, '')
+ .replace(/\/index$/, '');
return `/${slug}`;
}
async function main() {
const args = process.argv.slice(2);
- const checkExternal = args.includes("--external");
+ const checkExternal = args.includes('--external');
const scanned = buildScannedUrls();
// Read all MDX content files
- const files = await readFiles("content/docs/**/*.mdx", { pathToUrl });
+ const files = await readFiles('content/docs/**/*.mdx', { pathToUrl });
// Validate all links in the MDX files
const results = await validateFiles(files, {
@@ -69,9 +67,23 @@ async function main() {
const pathname = url.split(/[#?]/)[0];
const ext = path.extname(pathname).toLowerCase();
const staticExts = new Set([
- ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico",
- ".webp", ".avif", ".mp4", ".webm", ".pdf",
- ".css", ".js", ".woff", ".woff2", ".ttf", ".eot",
+ '.png',
+ '.jpg',
+ '.jpeg',
+ '.gif',
+ '.svg',
+ '.ico',
+ '.webp',
+ '.avif',
+ '.mp4',
+ '.webm',
+ '.pdf',
+ '.css',
+ '.js',
+ '.woff',
+ '.woff2',
+ '.ttf',
+ '.eot',
]);
return staticExts.has(ext);
},
@@ -81,6 +93,6 @@ async function main() {
}
main().catch((err) => {
- console.error("Fatal error:", err);
+ console.error('Fatal error:', err);
process.exit(1);
});
diff --git a/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx b/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx
index 5a4dccb190..6d027724c5 100644
--- a/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx
+++ b/libs/typescript/playground/src/components/composed/PlaygroundContent.tsx
@@ -82,6 +82,8 @@ interface PlaygroundContentProps {
onExamplePromptSelected?: (promptId: string, promptTitle: string) => void;
/** Optional toast callback */
onToast?: (message: string, type?: 'success' | 'error' | 'info') => void;
+ /** Optional class name for the root layout container (can override default h-screen w-screen) */
+ className?: string;
}
/**
@@ -109,6 +111,7 @@ export function PlaygroundContent({
onPlaygroundViewed,
onExamplePromptSelected,
onToast,
+ className,
}: PlaygroundContentProps) {
const { state, dispatch, adapters } = usePlayground();
const activeChat = useActiveChat();
@@ -303,6 +306,7 @@ export function PlaygroundContent({
return (
<>
<PlaygroundLayout
+ className={className}
isDarkMode={isDarkMode}
onToggleTheme={onToggleTheme}
renderThemeToggle={renderThemeToggle}
diff --git a/libs/typescript/playground/src/components/composed/PlaygroundLayout.tsx b/libs/typescript/playground/src/components/composed/PlaygroundLayout.tsx
index 64649f7a57..cf64446a08 100644
--- a/libs/typescript/playground/src/components/composed/PlaygroundLayout.tsx
+++ b/libs/typescript/playground/src/components/composed/PlaygroundLayout.tsx
@@ -16,6 +16,7 @@ import { motion } from 'motion/react';
import { type ReactNode, useEffect, useState } from 'react';
import { ChatList } from './ChatList';
import { useActiveChat, usePlayground } from '../../hooks/usePlayground';
+import { cn } from '../../utils/cn';
import type { Chat } from '../../types';
interface PlaygroundLayoutProps {
@@ -51,6 +52,8 @@ interface PlaygroundLayoutProps {
onChatSelect?: () => void;
/** Toast callback for user notifications */
onToast?: (message: string, type?: 'success' | 'error' | 'info') => void;
+ /** Optional class name for the root container (can override default h-screen w-screen) */
+ className?: string;
}
export function PlaygroundLayout({
@@ -70,6 +73,7 @@ export function PlaygroundLayout({
chatsLoading = false,
onChatSelect,
onToast,
+ className,
}: PlaygroundLayoutProps) {
const { state, dispatch } = usePlayground();
const { isSidebarCollapsed } = state;
@@ -115,7 +119,12 @@ export function PlaygroundLayout({
const LinkComponent = renderLink || defaultRenderLink;
return (
- <div className="relative flex h-screen w-screen flex-col overflow-hidden bg-white dark:bg-[#0C0C0C]">
+ <div
+ className={cn(
+ 'relative flex h-screen w-screen flex-col overflow-hidden bg-white dark:bg-[#0C0C0C]',
+ className
+ )}
+ >
{loadingBar}
{/* Top header bar */}