mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-09 06:34:53 +03:00
Use json-stringify-pretty-compact to give compact pretty JSON in purple code for x- extensions
This commit is contained in:
parent
500708b6c6
commit
3549819f80
|
@ -88,7 +88,14 @@ export const ExampleValue = styled(FieldLabel)`
|
|||
${extensionsHook('ExampleValue')};
|
||||
`;
|
||||
|
||||
export const ExtensionValue = styled(ExampleValue)``;
|
||||
|
||||
export const ExtensionValue = styled(ExampleValue)`
|
||||
white-space: pre;
|
||||
display: block;
|
||||
overflow: scroll;
|
||||
max-height: ${({ theme }) => theme.extension.maxHeight};
|
||||
${extensionsHook('ExtensionValue')};
|
||||
`;
|
||||
|
||||
export const ConstraintItem = styled(FieldLabel)`
|
||||
border-radius: 2px;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import * as prettyCompactJSON from 'json-stringify-pretty-compact';
|
||||
|
||||
import { ExtensionValue, FieldLabel } from '../../common-elements/fields';
|
||||
|
||||
import styled from '../../styled-components';
|
||||
|
@ -30,7 +32,7 @@ export class Extensions extends React.PureComponent<ExtensionsProps> {
|
|||
<Extension key={key}>
|
||||
<FieldLabel> {key.substring(2)}: </FieldLabel>{' '}
|
||||
<ExtensionValue>
|
||||
{typeof exts[key] === 'string' ? exts[key] : JSON.stringify(exts[key])}
|
||||
{typeof exts[key] === 'string' ? exts[key] : prettyCompactJSON(exts[key], {indent: 2})}
|
||||
</ExtensionValue>
|
||||
</Extension>
|
||||
))}
|
||||
|
|
|
@ -150,6 +150,9 @@ const defaultTheme: ThemeInterface = {
|
|||
codeSample: {
|
||||
backgroundColor: ({ rightPanel }) => darken(0.1, rightPanel.backgroundColor),
|
||||
},
|
||||
extension: {
|
||||
maxHeight: '16em'
|
||||
}
|
||||
};
|
||||
|
||||
export default defaultTheme;
|
||||
|
@ -320,7 +323,9 @@ export interface ResolvedThemeInterface {
|
|||
codeSample: {
|
||||
backgroundColor: string;
|
||||
};
|
||||
|
||||
extension: {
|
||||
maxHeight: string;
|
||||
}
|
||||
extensionsHook?: (name: string, props: any) => string;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user