diff --git a/src/cloud/CloudConnect.tsx b/src/cloud/CloudConnect.tsx new file mode 100644 index 0000000..f3cb2d7 --- /dev/null +++ b/src/cloud/CloudConnect.tsx @@ -0,0 +1,5 @@ +export const CloudConnect = ({ accentColor }: { accentColor: string }) => { + return null; +}; + +export const CLOUD_ENABLED = false; diff --git a/src/cloud/README.md b/src/cloud/README.md new file mode 100644 index 0000000..c169d34 --- /dev/null +++ b/src/cloud/README.md @@ -0,0 +1 @@ +Files in this `cloud/` directory can be ignored. They are mocks which we override in our private, hosted version of the agents-playground that supports LiveKit Cloud authentication. \ No newline at end of file diff --git a/src/cloud/useCloud.tsx b/src/cloud/useCloud.tsx new file mode 100644 index 0000000..4353372 --- /dev/null +++ b/src/cloud/useCloud.tsx @@ -0,0 +1,3 @@ +export function CloudProvider({ children }: { children: React.ReactNode }) { + return <>{children}; +} \ No newline at end of file diff --git a/src/components/PlaygroundConnect.tsx b/src/components/PlaygroundConnect.tsx index 8468e02..63e8567 100644 --- a/src/components/PlaygroundConnect.tsx +++ b/src/components/PlaygroundConnect.tsx @@ -1,4 +1,5 @@ import { useConfig } from "@/hooks/useConfig"; +import { CLOUD_ENABLED, CloudConnect } from "../cloud/CloudConnect"; import { Button } from "./button/Button"; import { useState } from "react"; @@ -7,25 +8,34 @@ type PlaygroundConnectProps = { onConnectClicked: () => void; }; -export const PlaygroundConnect = ({ +const ConnectTab = ({ active, onClick, children }: any) => { + let className = "px-2 py-1 text-sm"; + + if (active) { + className += " border-b border-cyan-500 text-cyan-500"; + } else { + className += " text-gray-500 border-b border-transparent"; + } + + return ( + + ); +}; + +const TokenConnect = ({ accentColor, onConnectClicked, }: PlaygroundConnectProps) => { const { setUserSettings, config } = useConfig(); - const [url, setUrl] = useState(config.settings.ws_url) - const [token, setToken] = useState(config.settings.token) + const [url, setUrl] = useState(config.settings.ws_url); + const [token, setToken] = useState(config.settings.token); return (
-

Connect to playground

-

- Connect LiveKit Agent Playground with a custom server using LiveKit - Cloud or LiveKit Server. -

-
-
setUrl(e.target.value)} @@ -43,7 +53,7 @@ export const PlaygroundConnect = ({ accentColor={accentColor} className="w-full" onClick={() => { - const newSettings = {...config.settings}; + const newSettings = { ...config.settings }; newSettings.ws_url = url; newSettings.token = token; setUserSettings(newSettings); @@ -63,3 +73,60 @@ export const PlaygroundConnect = ({
); }; + +export const PlaygroundConnect = ({ + accentColor, + onConnectClicked, +}: PlaygroundConnectProps) => { + const [showCloud, setShowCloud] = useState(true); + const copy = CLOUD_ENABLED + ? "Connect to playground with LiveKit Cloud or manually with a URL and token" + : "Connect to playground with a URL and token"; + return ( +
+
+
+
+
+

Connect to playground

+

+ {copy} +

+
+ {CLOUD_ENABLED && ( +
+ { + setShowCloud(true); + }} + > + LiveKit Cloud + + { + setShowCloud(false); + }} + > + Manual + +
+ )} +
+
+ {showCloud && CLOUD_ENABLED ? ( + + ) : ( + + )} +
+
+
+
+ ); +}; + diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index a7a790f..7c501ee 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,6 +1,10 @@ +import { CloudProvider } from "@/cloud/useCloud"; import "@/styles/globals.css"; import type { AppProps } from "next/app"; export default function App({ Component, pageProps }: AppProps) { - return ; -} + return ( + + + + );}