Standardize CodeBlock component

Summary:
Code blocks are quite common in Flipper, and a bit verbose in Ant, so let's standardize!

Changelog: Standardize CodeBlock component

Reviewed By: passy

Differential Revision: D28117560

fbshipit-source-id: 5a5538a49b59ef40c814d22055fac56e7598cbbb
This commit is contained in:
Michel Weststrate
2021-05-04 13:49:11 -07:00
committed by Facebook GitHub Bot
parent dd7a9f5195
commit 5bf9541e05
8 changed files with 48 additions and 11 deletions

View File

@@ -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]