Skip to content

Commit

Permalink
chore(PPDSC-2369): rename fns
Browse files Browse the repository at this point in the history
  • Loading branch information
Stoyan Delev committed Aug 23, 2022
1 parent 5b1373a commit b6a7d8b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions site/components/unpack-content/unpack-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import {childIsString} from '../../../src/utils/react-children-utilities';
import {getDisplayName} from '../../../src/utils/component';
import {OutputType, UnpackContentProps} from './types';

const allowedComponents = ['Link', 'InlineCode', 'Mono', 'ColoredTextElement'];
const allowedHTMLElements = ['br', 'b', 'em'];
const textComponents = ['Link', 'InlineCode', 'Mono', 'ColoredTextElement'];
const textHTMLElements = ['br', 'b', 'em'];

const defaultTextBlockProps = {
stylePreset: 'inkBase',
typographyPreset: 'editorialSubheadline020',
};

const childIsAllowedComponent = (child: React.ReactNode): boolean =>
allowedComponents.includes(getDisplayName(child));
const childIsTextComponent = (child: React.ReactNode): boolean =>
textComponents.includes(getDisplayName(child));

const childIsAllowedTag = (child: React.ReactNode): boolean =>
const childIsTextTag = (child: React.ReactNode): boolean =>
child !== null &&
typeof child === 'object' &&
'type' in child &&
allowedHTMLElements.includes(child.type as string);
textHTMLElements.includes(child.type as string);

const fragmentToOutput = (
fragment: React.ReactNode,
Expand All @@ -31,8 +31,8 @@ const fragmentToOutput = (
React.Children.forEach(fragment, child => {
if (
childIsString(child) ||
childIsAllowedComponent(child) ||
childIsAllowedTag(child)
childIsTextComponent(child) ||
childIsTextTag(child)
) {
const outputLastIndex = output.length - 1;
const prevChild = output[outputLastIndex];
Expand Down

0 comments on commit b6a7d8b

Please sign in to comment.