Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions components/Callout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Wrapper around Nextra Callout to add "example" type for user documentation
import { Callout as NextraCallout } from 'nextra/components'

type CalloutProps = React.ComponentProps<typeof NextraCallout> & {
type?: 'default' | 'info' | 'warning' | 'error' | 'success' | 'example'
}

export function Callout({ type, children, ...props }: CalloutProps) {
if (type === 'example') {
return (
<NextraCallout type="info" {...props}>
<strong>Example:</strong> {children}
</NextraCallout>
)
}
return <NextraCallout type={type as any} {...props}>{children}</NextraCallout>
}
25 changes: 25 additions & 0 deletions components/Terminal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Module to help create terminal-like code blocks in user documentation.
import React from "react";

// It'd be cool if we colored lines beginning with $ differently, but I wasn't
// able to figure that out.
export function Terminal({ children }) {
return (
<pre
style={{
background: "#222",
color: "#eee",
padding: "1em",
borderRadius: "6px",
fontSize: "1em",
overflowX: "auto",
margin: "1em 0",
// Not sure how to altogether avoid rendering links (example links in Terminal blocks are probably never
// real links), but this makes them non-clickable
pointerEvents: "none",
}}
>
<code style={{ whiteSpace: "pre-wrap" }}>{children}</code>
</pre>
);
}