diff --git a/desktop/app/src/ui/components/CodeBlock.tsx b/desktop/app/src/ui/components/CodeBlock.tsx index 9c459bae9..0e0b2da70 100644 --- a/desktop/app/src/ui/components/CodeBlock.tsx +++ b/desktop/app/src/ui/components/CodeBlock.tsx @@ -10,7 +10,7 @@ import styled from '@emotion/styled'; /** - * @deprecated, use
.... instead.
+ * @deprecated, use CodeBlock from flipper-plugin instead
  */
 const CodeBlock = styled.div({
   fontFamily: 'monospace',
diff --git a/desktop/flipper-plugin/src/__tests__/api.node.tsx b/desktop/flipper-plugin/src/__tests__/api.node.tsx
index 711cd70a5..c2c663370 100644
--- a/desktop/flipper-plugin/src/__tests__/api.node.tsx
+++ b/desktop/flipper-plugin/src/__tests__/api.node.tsx
@@ -28,6 +28,7 @@ test('Correct top level API exposed', () => {
   // Note, all `exposedAPIs` should be documented in `flipper-plugin.mdx`
   expect(exposedAPIs.sort()).toMatchInlineSnapshot(`
     Array [
+      "CodeBlock",
       "DataDescription",
       "DataFormatter",
       "DataInspector",
diff --git a/desktop/flipper-plugin/src/index.ts b/desktop/flipper-plugin/src/index.ts
index ca139d791..fde7a6e4c 100644
--- a/desktop/flipper-plugin/src/index.ts
+++ b/desktop/flipper-plugin/src/index.ts
@@ -59,6 +59,7 @@ export {Sidebar as _Sidebar} from './ui/Sidebar';
 export {DetailSidebar} from './ui/DetailSidebar';
 export {Toolbar} from './ui/Toolbar';
 export {MasterDetail} from './ui/MasterDetail';
+export {CodeBlock} from './ui/CodeBlock';
 
 export {renderReactRoot} from './utils/renderReactRoot';
 export {
diff --git a/desktop/flipper-plugin/src/ui/CodeBlock.tsx b/desktop/flipper-plugin/src/ui/CodeBlock.tsx
new file mode 100644
index 000000000..c94ae04c1
--- /dev/null
+++ b/desktop/flipper-plugin/src/ui/CodeBlock.tsx
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @format
+ */
+
+import React from 'react';
+import {Typography} from 'antd';
+import styled from '@emotion/styled';
+import {ParagraphProps} from 'antd/lib/typography/Paragraph';
+
+export function CodeBlock({children, ...props}: ParagraphProps) {
+  return (
+    
+      
{children}
+
+ ); +} + +const StyledParagrah = styled(Typography.Paragraph)({ + padding: 0, + fontSize: '9pt', + '&.ant-typography': { + margin: 0, + }, + '& pre': { + margin: 0, + }, +}); diff --git a/desktop/flipper-plugin/src/ui/Panel.tsx b/desktop/flipper-plugin/src/ui/Panel.tsx index 1ad40a4af..8e94885d4 100644 --- a/desktop/flipper-plugin/src/ui/Panel.tsx +++ b/desktop/flipper-plugin/src/ui/Panel.tsx @@ -78,7 +78,7 @@ const StyledCollapse = styled(Collapse)({ padding: `5px 0px`, left: 8, fontSize: '10px', - fontWeight: 'bold', + fontWeight: theme.bold, }, }, '& > .ant-collapse-item': { diff --git a/desktop/flipper-plugin/src/ui/Sidebar.tsx b/desktop/flipper-plugin/src/ui/Sidebar.tsx index 4bbab3d1a..414ba66e3 100644 --- a/desktop/flipper-plugin/src/ui/Sidebar.tsx +++ b/desktop/flipper-plugin/src/ui/Sidebar.tsx @@ -190,13 +190,7 @@ export class Sidebar extends Component { minHeight={minHeight} maxHeight={maxHeight} height={ - !horizontal - ? onResize - ? height - : this.state.height - : gutter - ? undefined - : '100%' + !horizontal ? (onResize ? height : this.state.height) : undefined } resizable={resizable} onResize={this.onResize} diff --git a/desktop/flipper-plugin/src/ui/theme.tsx b/desktop/flipper-plugin/src/ui/theme.tsx index 96d6b0dcd..ef2f76cb9 100644 --- a/desktop/flipper-plugin/src/ui/theme.tsx +++ b/desktop/flipper-plugin/src/ui/theme.tsx @@ -45,9 +45,14 @@ export const theme = { fontFamily: 'SF Mono,Monaco,Andale Mono,monospace', fontSize: '12px', } as const, + bold: 600, } as const; -export type Spacing = keyof typeof theme['space'] | number | undefined | true; +export type Spacing = + | keyof typeof theme['space'] + | number + | undefined + | boolean; export type PaddingProps = { padv?: Spacing; @@ -72,7 +77,7 @@ export function normalizePadding({ export function normalizeSpace(spacing: Spacing, defaultSpace: number): number { return spacing === true ? defaultSpace - : spacing === undefined + : spacing === undefined || spacing === false ? 0 : typeof spacing === 'string' ? theme.space[spacing] diff --git a/docs/extending/flipper-plugin.mdx b/docs/extending/flipper-plugin.mdx index 5637cfe92..12e16757f 100644 --- a/docs/extending/flipper-plugin.mdx +++ b/docs/extending/flipper-plugin.mdx @@ -873,6 +873,10 @@ The following additional properties are supported: A horizontal panel to organize buttons and alike. Basically a `Layout.Horizontal` with a border, padding, gap and wrapping enabled. +### CodeBlock + +A preformatted paragraph that supports wrapping, preserves whitespace and uses monospace. + ### DataList The DataList can be used to display a set of items efficiently, and where a single item can be selected.