Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions apps/docs/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,3 @@ NEXT_PUBLIC_FB_FEEDBACK_URL=
# PostHog
NEXT_PUBLIC_POSTHOG_KEY=your-posthog-key
NEXT_PUBLIC_POSTHOG_HOST=your-posthog-host

# Chat
IMPORT_API_KEY=your-import-api-key
CHAT_API_URL=
CHAT_URL=
100 changes: 0 additions & 100 deletions apps/docs/actions/open-in-chat.ts

This file was deleted.

92 changes: 2 additions & 90 deletions apps/docs/components/docs/components/code-demo/code-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@ import type {UseCodeDemoProps} from "./use-code-demo";
import type {WindowResizerProps} from "./window-resizer";
import type {GradientBoxProps} from "@/components/gradient-box";

import React, {useCallback, useMemo, useRef, useState} from "react";
import React, {useCallback, useMemo, useRef} from "react";
import dynamic from "next/dynamic";
import {addToast, Button, Skeleton, Spinner, Tab, Tabs} from "@heroui/react";
import {Skeleton, Tab, Tabs} from "@heroui/react";
import {useInView} from "framer-motion";
import {usePostHog} from "posthog-js/react";
import {usePathname} from "next/navigation";

import {useCodeDemo} from "./use-code-demo";
import WindowResizer from "./window-resizer";
import {parseDependencies} from "./parse-dependencies";

import {openInChat} from "@/actions/open-in-chat";

const DynamicReactLiveDemo = dynamic(
() => import("./react-live-demo").then((m) => m.ReactLiveDemo),
Expand Down Expand Up @@ -82,11 +77,6 @@ export const CodeDemo: React.FC<CodeDemoProps> = ({
margin: "600px",
});

const pathname = usePathname();
const posthog = usePostHog();

const [isLoading, setIsLoading] = useState(false);

const {noInline, code} = useCodeDemo({
files,
});
Expand Down Expand Up @@ -178,64 +168,6 @@ export const CodeDemo: React.FC<CodeDemoProps> = ({
return true;
}, [showTabs, showPreview, showEditor]);

const isComponentsPage = pathname.includes("/components/");

const handleOpenInChat = useCallback(async () => {
setIsLoading(true);

// assume doc demo files are all App.jsx
const content = files["/App.jsx"];

if (!content || typeof content !== "string") {
addToast({
title: "Error",
description: "Invalid demo content",
color: "danger",
});

return;
}

const component = pathname.split("/components/")[1];
const dependencies = parseDependencies(content);

posthog.capture("CodeDemo - Open in Chat", {
component,
demo: title,
});

const newTab = window.open(undefined, "_blank");

const {data, error} = await openInChat({
component,
title,
content,
dependencies,
useWrapper: !asIframe,
});

setIsLoading(false);

if (error || !data) {
if (newTab) newTab.close();
posthog.capture("CodeDemo - Open in Chat Error", {
component,
demo: title,
error: error ?? "Unknown error",
});

addToast({
title: "Error",
description: error ?? "Unknown error",
color: "danger",
});

return;
}

if (newTab) newTab.location.href = data;
}, [pathname, title, files, posthog]);

return (
<div ref={ref} className="flex flex-col gap-2 relative">
{shouldRenderTabs ? (
Expand All @@ -255,26 +187,6 @@ export const CodeDemo: React.FC<CodeDemoProps> = ({
{editorContent}
</Tab>
</Tabs>
{isComponentsPage && (
<Button
disableRipple
className="absolute rounded-[9px] right-1 top-1 border-1 border-default-200 dark:border-default-100 data-[hover=true]:bg-default-50/80"
isDisabled={isLoading}
size="sm"
variant="bordered"
onPress={handleOpenInChat}
>
Open in Chat{" "}
{isLoading ? (
<Spinner
classNames={{wrapper: "h-4 w-4"}}
color="current"
size="sm"
variant="simple"
/>
) : null}
</Button>
)}
</>
) : (
<>
Expand Down
92 changes: 0 additions & 92 deletions apps/docs/components/heroui-chat-banner.tsx

This file was deleted.

26 changes: 0 additions & 26 deletions apps/docs/components/random-banner.tsx

This file was deleted.

5 changes: 1 addition & 4 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"IS_PREVIEW",
"IS_VA_ENABLED",
"ENABLE_EXPERIMENTAL_COREPACK",
"PLAIN_USER_AUTHENTICATED",
"IMPORT_API_KEY",
"CHAT_URL",
"CHAT_API_URL"
"PLAIN_USER_AUTHENTICATED"
],
"tasks": {
"build": {
Expand Down