From e27853e73948edadc430727e2ba56d0678163d08 Mon Sep 17 00:00:00 2001 From: Sean McQuay Date: Fri, 24 Nov 2023 11:56:25 -0600 Subject: [PATCH] Fixed display issue but build fails. --- src/components/CodeBlockComponent/index.js | 33 +++--- src/components/GridItemComponent/styles.scss | 2 +- src/components/ListComponent/index.js | 113 +++++++++---------- 3 files changed, 73 insertions(+), 75 deletions(-) diff --git a/src/components/CodeBlockComponent/index.js b/src/components/CodeBlockComponent/index.js index 01a0162..8d90bb4 100644 --- a/src/components/CodeBlockComponent/index.js +++ b/src/components/CodeBlockComponent/index.js @@ -1,8 +1,6 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { - Prism as SyntaxHighlighter -} from 'react-syntax-highlighter'; +import SyntaxHighlighter from 'react-syntax-highlighter'; import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism'; @@ -15,19 +13,21 @@ function CodeBlockComponent(props) { const { children, className, - inline: isInline, - language + language, + node } = props; - const fieldValue = children[0]; + const isInline = !node.properties?.className; const { displayName } = CodeBlockComponent; + const syntaxLanguage = language || className.replace('language-language', 'language'); + const componentClassNames = classNames( displayName, - className, + syntaxLanguage, { [`${displayName}--inline`]: isInline } @@ -35,16 +35,16 @@ function CodeBlockComponent(props) { return ( isInline ? ( - {fieldValue} + {children} ) : ( - {fieldValue} + {children} ) ); @@ -55,16 +55,19 @@ CodeBlockComponent.displayName = 'CodeBlockComponent'; CodeBlockComponent.propTypes = { children: PropTypes.arrayOf(PropTypes.string), className: PropTypes.string, - // eslint-disable-next-line react/boolean-prop-naming - inline: PropTypes.bool, - language: PropTypes.string + language: PropTypes.string, + node: PropTypes.shape({ + properties: PropTypes.shape({ + className: PropTypes.arrayOf(PropTypes.string) + }) + }) }; CodeBlockComponent.defaultProps = { children: [], className: '', - inline: false, - language: '' + language: '', + node: {} }; export default CodeBlockComponent; diff --git a/src/components/GridItemComponent/styles.scss b/src/components/GridItemComponent/styles.scss index dc0e9ad..f4a610e 100644 --- a/src/components/GridItemComponent/styles.scss +++ b/src/components/GridItemComponent/styles.scss @@ -8,7 +8,7 @@ $breakpoints: ( ); .GridItemComponent { - grid-column: 1 13; + grid-column: 1 / 13; & > * { width: 100%; diff --git a/src/components/ListComponent/index.js b/src/components/ListComponent/index.js index a3eba76..e38ff49 100644 --- a/src/components/ListComponent/index.js +++ b/src/components/ListComponent/index.js @@ -1,98 +1,93 @@ import PropTypes from 'prop-types'; import React from 'react'; +import Button from '../ButtonComponent'; + +import { + BUTTON_STYLE_TYPE_INLINE +} from '../ButtonComponent/config'; + import classNames from '../../utils/classNames'; import './styles.scss'; +export const SHORT_LIST_LIMIT = 20; + function ListComponent(props) { const { displayName } = ListComponent; - console.log(props); - const renderListItems = (childList) => childList.map((childDetails) => { const { - children: nestedChildren, - key, - tagName: elementType, + children, + isRootList = false, + properties, + tagName, + type, value } = childDetails; - if (value === '\n') { - return undefined; - } - - const isList = elementType === 'ul' || elementType === 'ol'; + const componentClassNames = isRootList ? classNames( + displayName, + { + [`${displayName}--ordered`]: tagName === 'ol', + [`${displayName}--short`]: (children.length / 2) <= SHORT_LIST_LIMIT, + [`${displayName}--unordered`]: tagName !== 'ol' + } + ) : ''; - // console.log({ - // childDetails - // }); + // These are empty entries or new lines + if (type === 'text' && value === '\n') { + return null; + } - if (isList) { - const isOrderedList = elementType === 'ol'; - const isShortList = nestedChildren.length <= 14; + if (tagName === 'ul') { + return (); + } - const componentClassNames = classNames( - displayName, - { - [`${displayName}--ordered`]: isOrderedList, - [`${displayName}--short`]: isShortList, - [`${displayName}--unordered`]: !isOrderedList - } - ); + if (tagName === 'ol') { + return (
    {renderListItems(children)}
); + } - return ( - isOrderedList ? ( -
    {renderListItems(nestedChildren)} -
- ) : ( - - ) - ); + if (tagName === 'li' || tagName === 'p') { + return (
  • {renderListItems(children)}
  • ); } - if (value) { - if (value === '.') { - console.log({ - childDetails - }); - } + if (tagName === 'a') { return ( -
  • {value}
  • +