From a6adfaaf27049be679cfd5491494bee411e1ac8d Mon Sep 17 00:00:00 2001 From: Brett Jephson Date: Fri, 20 Sep 2024 11:27:27 +0100 Subject: [PATCH] Add icons for editing url --- .../components/DocumentView/OpenAPI/OpenAPI.tsx | 2 ++ .../components/DocumentView/OpenAPI/style.css | 17 ++++++++++++++--- packages/react-openapi/src/OpenAPIOperation.tsx | 2 +- .../react-openapi/src/OpenAPIServerURLForm.tsx | 5 +++-- packages/react-openapi/src/ServerSelector.tsx | 4 ++-- packages/react-openapi/src/types.ts | 2 ++ 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPI.tsx b/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPI.tsx index 05c094467..1c907c928 100644 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPI.tsx +++ b/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPI.tsx @@ -54,6 +54,8 @@ async function OpenAPIBody(props: BlockProps) { icons: { chevronDown: , chevronRight: , + edit: , + clear: }, CodeBlock: PlainCodeBlock, defaultInteractiveOpened: context.mode === 'print', diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css b/packages/gitbook/src/components/DocumentView/OpenAPI/style.css index 6bd0206ad..cd2c8b5ca 100644 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css +++ b/packages/gitbook/src/components/DocumentView/OpenAPI/style.css @@ -57,7 +57,7 @@ /** URL */ .openapi-url { - @apply font-mono text-sm text-dark/8 dark:text-light/8; + @apply flex items-center font-mono text-sm text-dark/8 dark:text-light/8; } .openapi-url-var { @@ -365,6 +365,17 @@ @apply mb-0; } -.openapi-server-button { - @apply disabled:opacity-5; +.openapi-select-button, +.openapi-edit-button { + @apply p-0.5 inline-flex text-dark/6 dark:text-light/6 hover:opacity-8; +} + +.openapi-edit-button { @apply p-0.5 ml-4 size-4; } + +.openapi-edit-button > * { + @apply size-full; +} + +.openapi-select-button { + @apply leading-[1cap] disabled:opacity-5; } diff --git a/packages/react-openapi/src/OpenAPIOperation.tsx b/packages/react-openapi/src/OpenAPIOperation.tsx index b0a2b0325..e4a643303 100644 --- a/packages/react-openapi/src/OpenAPIOperation.tsx +++ b/packages/react-openapi/src/OpenAPIOperation.tsx @@ -37,7 +37,7 @@ export async function OpenAPIOperation(props: { {operation.description ? ( ) : null} -
+
1 || server.variables; return (
{ e.preventDefault(); updateServerVariables(new FormData(e.currentTarget)); }} className="contents">
@@ -61,11 +62,11 @@ export function ServerURLForm(props: { onChange={switchServer} /> ) : null} - + }} title={ctx?.state?.edit ? undefined : "Try different server options"} aria-label={ctx?.state?.edit ? "Clear" : "Edit"}>{ctx?.state?.edit ? context.icons.clear : context.icons.edit} : null}
); diff --git a/packages/react-openapi/src/ServerSelector.tsx b/packages/react-openapi/src/ServerSelector.tsx index 53051e3b8..bd2997619 100644 --- a/packages/react-openapi/src/ServerSelector.tsx +++ b/packages/react-openapi/src/ServerSelector.tsx @@ -18,7 +18,7 @@ export function ServerSelector(props: {