diff --git a/pwa/.gitignore b/pwa/.gitignore index 5ce44fc59..98837c85e 100644 --- a/pwa/.gitignore +++ b/pwa/.gitignore @@ -48,4 +48,10 @@ app/playground/utils/php-web.mjs app/playground/utils/php-web.wasm public/php-web.data public/php-web.wasm + +.phive/ core.temp/ +core/ +docs.temp/ +php-wasm/ +tools/pdg diff --git a/pwa/app/playground/components/PhpEditor.tsx b/pwa/app/playground/components/PhpEditor.tsx index 8a4507a5f..4bb8951e1 100644 --- a/pwa/app/playground/components/PhpEditor.tsx +++ b/pwa/app/playground/components/PhpEditor.tsx @@ -25,6 +25,11 @@ export default function PhpEditor({ options={{ wordWrap: "on", automaticLayout: true, + minimap: { enabled: false }, + fontSize: 14, + lineHeight: 1.6, + padding: { top: 10, bottom: 10 }, + scrollBeyondLastLine: false, }} /> ); diff --git a/pwa/app/playground/components/Playground.tsx b/pwa/app/playground/components/Playground.tsx index c043764b9..afa5a257b 100644 --- a/pwa/app/playground/components/Playground.tsx +++ b/pwa/app/playground/components/Playground.tsx @@ -1,12 +1,15 @@ "use client"; -import React, { ChangeEvent, useCallback, useEffect, useState } from "react"; +import React, { useCallback, useEffect, useMemo, useState } from "react"; import usePHP from "../utils/usePHP"; import PhpEditor from "./PhpEditor"; import Response from "./Response"; import SwaggerUI from "./SwaggerUI"; +import classNames from "classnames"; +import NavLink from "../../../components/layout/NavLink"; import { bufferTime } from "rxjs"; import { getGuides, GuideMetadata } from "../utils/getGuides"; import { useParams } from "next/navigation"; +import Logo from "components/common/Logo"; const STR = "string"; @@ -20,10 +23,6 @@ export default function Playground() { const [code, setCode] = useState(""); const [guides, setGuides] = useState([] as GuideMetadata[]); const [activeTab, setActiveTab] = useState("response"); - const notActiveTabClassname = - "py-4 px-1 inline-flex items-center gap-2 border-b-[3px] border-transparent text-sm whitespace-nowrap text-gray-500 hover:text-blue-600 active"; - const activeTabClassname = - "font-semibold border-blue-600 text-blue-60 " + notActiveTabClassname; const routeParams = useParams(); @@ -31,6 +30,19 @@ export default function Playground() { setGuide(routeParams.guide); }, [routeParams.guide]); + const guideName = useMemo(() => { + if (guides && guide) { + const currentGuideIndex = guides.findIndex((g) => guide === g.slug); + if (currentGuideIndex !== -1) { + const currentGuide = guides[currentGuideIndex]; + return `${currentGuideIndex + 1} - ${currentGuide.name}`; + } else { + return ""; // Guide non trouvé, renvoie une chaîne vide + } + } + return ""; + }, [guide, guides]); + // handles stdout and stderr, note that stdout is our HTTP body response useEffect(() => { const out = stdout.pipe(bufferTime(256)).subscribe((out) => { @@ -118,12 +130,19 @@ export default function Playground() { [guide, FS, ccall] ); - const onGuideChange = useCallback((event: ChangeEvent) => { + /*const onGuideChange = useCallback((event: ChangeEvent) => { const newGuide = (event.target as HTMLSelectElement).value; const url = new URL(window.location.href); url.pathname = "/playground/" + newGuide; window.history.pushState({}, "", url); setGuide(newGuide); + }, []);*/ + + const onGuideChange = useCallback((newGuide: string) => { + const url = new URL(window.location.href); + url.pathname = "/playground/" + newGuide; + window.history.pushState({}, "", url); + setGuide(newGuide); }, []); if (loading || !guide) { @@ -132,62 +151,108 @@ export default function Playground() { return ( <> -
-
-
API Platform {versions.apiPlatform}
-
PHP {versions.php}
-
- +
+
+
+ +
+ +
+

PLAYGROUND

+
+ +
+
+ API Platform {versions.apiPlatform} +
+
+ PHP {versions.php} +
+
-
-
- -
-
-
-
+
+
+ +
+
+
+
+
- {activeTab === "response" ? ( - - ) : ( - - )} +
+ {activeTab === "response" ? ( + + ) : ( + + )} +
diff --git a/pwa/app/playground/components/Response.tsx b/pwa/app/playground/components/Response.tsx index 28a87c529..dcd29edc3 100644 --- a/pwa/app/playground/components/Response.tsx +++ b/pwa/app/playground/components/Response.tsx @@ -10,7 +10,7 @@ export default function Response({ }) { if (isJson) { return ( - + {({ className, style, tokens, getLineProps, getTokenProps }) => (
             {tokens.map((line, i) => (
diff --git a/pwa/app/playground/layout.tsx b/pwa/app/playground/layout.tsx
index de4153f89..0098410df 100644
--- a/pwa/app/playground/layout.tsx
+++ b/pwa/app/playground/layout.tsx
@@ -1,4 +1,13 @@
 import "styles/common.css";
+import { Poppins } from "next/font/google";
+
+const poppins = Poppins({
+  variable: "--font-poppins",
+  display: "swap",
+  weight: ["300", "400", "500", "600", "700", "800"],
+  subsets: ["latin", "latin-ext"],
+});
+
 export const metadata = {
   title: "API Platform - Playground",
   description: "Try API Platform live in your browser!",
@@ -10,7 +19,7 @@ export default function RootLayout({
   children: React.ReactNode;
 }) {
   return (
-    
+    
       {children}
     
   );