docs: improvements and fixes to components in API reference (#9410)

- Change layout of parameters for clearer display
- Fix schema code blocks being longer than container
- switch between showing required to showing optional indicator
- Fixed code tabs not having copy / report buttons

Closes DOCS-936

Preview: https://api-reference-v2-git-docs-api-ref-comp-improv-medusajs.vercel.app/v2/api/store
This commit is contained in:
Shahed Nasser
2024-10-09 17:51:27 +00:00
committed by GitHub
parent 8d3e7b3336
commit 7f1f075222
14 changed files with 239 additions and 187 deletions
@@ -51,6 +51,7 @@ export type CodeBlockProps = {
collapsed?: boolean
blockStyle?: CodeBlockStyle
children?: React.ReactNode
style?: React.HTMLAttributes<HTMLDivElement>["style"]
} & CodeBlockMetaFields &
Omit<HighlightProps, "code" | "language" | "children">
@@ -71,6 +72,7 @@ export const CodeBlock = ({
collapsibleLines,
expandButtonLabel,
isTerminal,
style,
...rest
}: CodeBlockProps) => {
if (!source && typeof children === "string") {
@@ -92,10 +94,14 @@ export const CodeBlock = ({
: isTerminal
}, [isTerminal, lang])
const codeTitle = useMemo(() => {
if (title || hasTabs) {
if (title) {
return title
}
if (hasTabs) {
return ""
}
if (isTerminalCode) {
return "Terminal"
}
@@ -329,6 +335,7 @@ export const CodeBlock = ({
!hasInnerCodeBlock && "rounded-docs_DEFAULT",
className
)}
style={style}
>
<Highlight
theme={codeTheme}
@@ -370,9 +377,6 @@ export const CodeBlock = ({
!hasInnerCodeBlock &&
tokens.length <= 1 &&
"px-docs_1 py-[6px]",
!codeTitle.length &&
(!noCopy || !noReport) &&
"xs:max-w-[83%]",
(noLineNumbers ||
(tokens.length <= 1 && !isTerminalCode)) &&
"pl-docs_1",