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 (
{renderListItems(children)}
);
+ }
- const componentClassNames = classNames(
- displayName,
- {
- [`${displayName}--ordered`]: isOrderedList,
- [`${displayName}--short`]: isShortList,
- [`${displayName}--unordered`]: !isOrderedList
- }
- );
+ if (tagName === 'ol') {
+ return ({renderListItems(children)}
);
+ }
- return (
- isOrderedList ? (
- {renderListItems(nestedChildren)}
-
- ) : (
- {renderListItems(nestedChildren)}
-
- )
- );
+ if (tagName === 'li' || tagName === 'p') {
+ return ({renderListItems(children)});
}
- if (value) {
- if (value === '.') {
- console.log({
- childDetails
- });
- }
+ if (tagName === 'a') {
return (
- {value}
+
);
}
- return renderListItems(nestedChildren);
+ return value;
}).filter((listItem) => listItem);
return renderListItems([
- props.node
+ {
+ ...props.node,
+ isRootList: true
+ }
]);
}
ListComponent.displayName = 'ListComponent';
ListComponent.propTypes = {
- node: PropTypes.shape({
- children: PropTypes.arrayOf(PropTypes.shape({
- children: PropTypes.arrayOf(PropTypes.shape({
- type: PropTypes.string,
- value: PropTypes.string
- })),
- tagName: PropTypes.string
- })),
- key: PropTypes.string,
- tagName: PropTypes.string
- })
+ key: PropTypes.string,
+ node: PropTypes.arrayOf(PropTypes.shape({
+ children: PropTypes.shape({}),
+ isRootList: PropTypes.string,
+ properties: PropTypes.shape({}),
+ tagName: PropTypes.string,
+ type: PropTypes.string,
+ value: PropTypes.string
+ }))
};
ListComponent.defaultProps = {