From d568a7516820c436f77faf5778e7ed80cf2016d6 Mon Sep 17 00:00:00 2001 From: Andy Clifford Date: Mon, 9 Oct 2023 15:08:17 +1300 Subject: [PATCH] Endpoint component This change allows us to document api endpoints using the same layout as seen in the [Figma Design](https://www.figma.com/file/IgRlQWJTyGoZhlF4fVKD6B/Centrapay-Docs-(Tailwind)?type=design&node-id=1654-8412&mode=design&t=qTBa6bhBVBAMyHqN-0). There are issues with the styling such as the h2 header but we are just focussed on getting the layout correct then will followup with styling later once we have aligned with the designers. --- package.json | 4 +- .../links.integration.test.js.snap | 4 + src/components/Code.astro | 3 + src/components/Column.astro | 8 ++ src/components/Endpoint.astro | 18 +++++ src/components/Eyebrow.astro | 24 ++++++ src/components/ProseCode.vue | 2 +- src/components/Row.astro | 3 + src/content/api/media-uploads.mdx | 79 +++++++++++++++++++ 9 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 src/components/Code.astro create mode 100644 src/components/Column.astro create mode 100644 src/components/Endpoint.astro create mode 100644 src/components/Eyebrow.astro create mode 100644 src/components/Row.astro diff --git a/package.json b/package.json index 9f1ad841c..444872eba 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "flexsearch": "^0.7.31", "glob": "^8.1.0", "gray-matter": "^4.0.3", + "jsdom": "^22.1.0", "linkinator": "^5.0.2", "mdast-util-to-string": "^3.1.1", "mermaid": "^9.3.0", @@ -42,7 +43,6 @@ "unist-util-find-after": "^4.0.1", "unist-util-visit": "^4.1.2", "vitest": "^0.28.3", - "vue": "^3.2.47", - "jsdom": "^22.1.0" + "vue": "^3.2.47" } } diff --git a/src/__tests__/__snapshots__/links.integration.test.js.snap b/src/__tests__/__snapshots__/links.integration.test.js.snap index b07dd6855..6cd6fe44d 100644 --- a/src/__tests__/__snapshots__/links.integration.test.js.snap +++ b/src/__tests__/__snapshots__/links.integration.test.js.snap @@ -304,8 +304,12 @@ exports[`the build should not break any links 1`] = ` "/api/managed-integrations#paypal-referral", "/api/managed-integrations#top", "/api/media-uploads", + "/api/media-uploads#attributes", + "/api/media-uploads#attributes-1", "/api/media-uploads#contents", + "/api/media-uploads#create-a-presigned-url-for-media-upload", "/api/media-uploads#create-a-presigned-url-for-media-upload-experimental", + "/api/media-uploads#get-media-upload-location", "/api/media-uploads#get-media-upload-location-experimental", "/api/media-uploads#media-upload", "/api/media-uploads#media-uploads", diff --git a/src/components/Code.astro b/src/components/Code.astro new file mode 100644 index 000000000..d16fb0883 --- /dev/null +++ b/src/components/Code.astro @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/components/Column.astro b/src/components/Column.astro new file mode 100644 index 000000000..7eb86336b --- /dev/null +++ b/src/components/Column.astro @@ -0,0 +1,8 @@ + +--- +const { sticky = false } = Astro.props; +--- + +
:first-child]:mt-0 [&>:last-child]:mb-0 xl:sticky xl:top-24' : '[&>:first-child]:mt-0 [&>:last-child]:mb-0'}`> + +
diff --git a/src/components/Endpoint.astro b/src/components/Endpoint.astro new file mode 100644 index 000000000..427af8251 --- /dev/null +++ b/src/components/Endpoint.astro @@ -0,0 +1,18 @@ +--- +import Eyebrow from './Eyebrow.astro'; +import Row from './Row.astro'; +import Column from './Column.astro'; + +const { method, path, experimental = false } = Astro.props; +--- + + + + + + + + + + + diff --git a/src/components/Eyebrow.astro b/src/components/Eyebrow.astro new file mode 100644 index 000000000..34fca3d95 --- /dev/null +++ b/src/components/Eyebrow.astro @@ -0,0 +1,24 @@ +--- +const { method, path } = Astro.props; +const valueColorMap = { + GET: 'emerald', + POST: 'sky', + PUT: 'amber', + DELETE: 'rose', +}; +const color = valueColorMap[method] || 'emerald'; +const colorStyles = { + emerald: 'ring-emerald-300 dark:ring-emerald-400/30 bg-emerald-400/10 text-emerald-500 dark:text-emerald-400', + sky: 'ring-sky-300 bg-sky-400/10 text-sky-500 dark:ring-sky-400/30 dark:bg-sky-400/10 dark:text-sky-400', + amber: 'ring-amber-300 bg-amber-400/10 text-amber-500 dark:ring-amber-400/30 dark:bg-amber-400/10 dark:text-amber-400', + rose: 'ring-rose-200 bg-rose-50 text-red-500 dark:ring-rose-500/20 dark:bg-rose-400/10 dark:text-rose-400', +} +--- + +
+
+ { method } + + { path } +
+
diff --git a/src/components/ProseCode.vue b/src/components/ProseCode.vue index 72c0a27ff..225f6bcbb 100644 --- a/src/components/ProseCode.vue +++ b/src/components/ProseCode.vue @@ -1,6 +1,6 @@