Browse Source

[Beta] Fixes to blocks

main
Dan Abramov 2 years ago
parent
commit
c998108462
  1. 11
      beta/src/components/MDX/ConsoleBlock.tsx
  2. 2
      beta/src/components/MDX/TerminalBlock.tsx

11
beta/src/components/MDX/ConsoleBlock.tsx

@ -7,7 +7,7 @@ import cn from 'classnames';
import {IconWarning} from '../Icon/IconWarning';
import {IconError} from '../Icon/IconError';
type LogLevel = 'info' | 'warning' | 'error';
type LogLevel = 'warning' | 'error' | 'info';
interface ConsoleBlockProps {
level?: LogLevel;
@ -29,14 +29,11 @@ const Box = ({
);
Box.displayName = 'Box';
function ConsoleBlock({level = 'info', children}: ConsoleBlockProps) {
let message: string | undefined;
function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
let message: React.ReactNode | null;
if (typeof children === 'string') {
message = children;
} else if (
React.isValidElement(children) &&
typeof children.props.children === 'string'
) {
} else if (React.isValidElement(children)) {
message = children.props.children;
}

2
beta/src/components/MDX/TerminalBlock.tsx

@ -33,6 +33,8 @@ function TerminalBlock({level = 'info', children}: TerminalBlockProps) {
typeof children.props.children === 'string'
) {
message = children.props.children;
} else {
throw Error('Expected TerminalBlock children to be a plain string.');
}
const [copied, setCopied] = React.useState(false);

Loading…
Cancel
Save