From 32867856cc61a6e0a1210249d2f59ef5ac006cfb 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 | 1 + src/components/Code.astro | 7 ++ src/components/Column.astro | 8 ++ src/components/Eyebrow.astro | 24 ++++++ src/components/ProseCode.vue | 2 +- src/components/Row.astro | 3 + src/content/api/media-uploads.mdx | 75 +++++++++++++++++++ 8 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 src/components/Code.astro create mode 100644 src/components/Column.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..e2a57f969 100644 --- a/src/__tests__/__snapshots__/links.integration.test.js.snap +++ b/src/__tests__/__snapshots__/links.integration.test.js.snap @@ -304,6 +304,7 @@ 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#contents", "/api/media-uploads#create-a-presigned-url-for-media-upload-experimental", "/api/media-uploads#get-media-upload-location-experimental", diff --git a/src/components/Code.astro b/src/components/Code.astro new file mode 100644 index 000000000..9b3a660fb --- /dev/null +++ b/src/components/Code.astro @@ -0,0 +1,7 @@ +--- +import ProseCode from "./ProseCode.vue"; +--- + + + + 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/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 @@