diff --git a/src/assets/styles/30-components/__manifest.scss b/src/assets/styles/30-components/__manifest.scss index 2a370493..946a5a32 100644 --- a/src/assets/styles/30-components/__manifest.scss +++ b/src/assets/styles/30-components/__manifest.scss @@ -7,7 +7,6 @@ // Base level components used by other components @import './src/components/Icon/icon'; -@import './src/components/RichText/rich-text'; // component styles @import './src/components/Button/button'; diff --git a/src/components/RichText/RichText.md b/src/components/RichText/RichText.md deleted file mode 100644 index f257f54e..00000000 --- a/src/components/RichText/RichText.md +++ /dev/null @@ -1,11 +0,0 @@ -# RichText - -Component for parsing, embellishing and rendering rich text content areas. - -## Embellishments - -* Adds 'new window' icon to any link which is set to open in a new window - -## When to use - -RichText can be used multiple times within a page/layout. diff --git a/src/components/RichText/RichText.test.tsx b/src/components/RichText/RichText.test.tsx deleted file mode 100644 index 8a64f7f5..00000000 --- a/src/components/RichText/RichText.test.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import { mount } from 'enzyme'; - -import RichText from 'RichText'; - -describe('', () => { - const content = ( - {''} - ); - const outputMount = mount(content); - - it('contains an H3 element with aria-hidden attribute', () => { - expect(outputMount.html()).toEqual( - '
' - ); - }); -}); diff --git a/src/components/RichText/RichText.tsx b/src/components/RichText/RichText.tsx deleted file mode 100644 index f7d62b84..00000000 --- a/src/components/RichText/RichText.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import React from 'react'; -import cx from 'classnames'; - -import { sanitizeHtml } from 'utils/sanitize-html'; - -type RichTextProps = { - children: string; - className?: string; - itemProp?: string; - variant?: 'text' | 'text-snippet'; -}; - -const regexTableElements = /(.|\n)(.*?)(.|\n)*<\/table>/g; - -/** - * Perform some desirable transforms to a string of HTML so that we - * can affect the markup however we desire. - * - * @param {string} children - * @returns {string} - */ -const formatHTMLString = (children: string) => { - try { - return ( - children - /** - * Add markup to wrap elements with a
to prevent overflow-x - * on the rich-text element, constraining the overflow-x to only the - *
element itself. - */ - .replaceAll(regexTableElements, match => { - return `
${match}
`; - }) - ); - } catch { - return children; - } -}; - -export const RichText = ({ - children, - className, - itemProp, - variant = 'text' -}: RichTextProps) => { - // pass text through sanitizeHtml to sanitize it prior to applying transformations - const htmlString = formatHTMLString(sanitizeHtml(children)); - const classNames = cx(`cc-rich-${variant}`, { - [className]: className - }); - - return ( -
- ); -}; - -export default RichText; diff --git a/src/components/RichText/_rich-text.scss b/src/components/RichText/_rich-text.scss deleted file mode 100644 index 33378290..00000000 --- a/src/components/RichText/_rich-text.scss +++ /dev/null @@ -1,159 +0,0 @@ -// ---------------------------------- -// UI Components -// Rich text -// ---------------------------------- -// Design System 1.0 Alpha -// 2019-11-11 -// ---------------------------------- - -.cc-rich-text { - // ensure extra long words are wrapped to prevent overlap or horizontal scroll - overflow-wrap: break-word; - word-wrap: break-word; - - h2 { - @extend %heading-base; - @extend %heading-display; - @include heading-fancy; - } - - h3 { - @extend %heading-base; - @extend %heading-large; - } - - h4 { - @extend %heading-base; - @extend %heading-regular; - } - - h5, - h6 { - @extend %heading-base; - @extend %heading-small; - } - - p { - @extend %body-large; - } - - ol, - ul { - @extend %list-base; - } - - li p { - margin-bottom: calc(2 * var(--space-unit)); - } - - table { - border-collapse: collapse; - caption-side: top; - line-height: var(--body-line-height); - margin-bottom: calc(4 * var(--space-unit)); - width: 100%; - } - - caption { - border-left: 1px solid var(--color-grey-70); - font-family: var(--font-tertiary); - font-size: var(--body-xxs); - font-weight: bold; - margin-bottom: calc(2 * var(--space-unit)); - padding: calc(0.25 * var(--space-unit)) 0 calc(0.25 * var(--space-unit)) calc(2 * var(--space-unit)); - text-align: left; - } - - tr { - border: solid var(--color-grey-10); - border-width: 1px 0; - } - - thead tr { - border-bottom-width: 2px; - } - - tbody tr:nth-child(odd) { - background-color: var(--color-cyan-05); - } - - th, - td { - padding: var(--space-md) var(--space-lg); - text-align: left; - vertical-align: top; - } - - th { - font-size: var(--body-xxxs); - font-weight: var(--heading-font-weight); - text-transform: uppercase; - } - - thead th { - padding: calc(2.5 * var(--space-unit)) var(--space-lg); - } - - td { - font-size: var(--body-sm); - } -} - -.cc-rich-text-snippet { - @extend %body-large; - line-height: var(--body-line-height); - - p { - @extend %body-regular; - } - - ol, - ul { - @extend %list-base; - margin-bottom: calc(2 * var(--space-unit)); - } -} - -.cc-text-snippet__title { - @extend %heading-base; - font-size: var(--font-size-body-lg); - font-weight: var(--font-weight-heading); - letter-spacing: var(--letter-spacing-heading-minor); - margin-bottom: var(--space-unit); - - @include mq(sm) { - margin-bottom: calc(2 * var(--space-unit)); - } -} - -.cc-rich-text-snippet h2, -.cc-rich-text-snippet h3, -.cc-rich-text-snippet h4, -.cc-rich-text-snippet h5, -.cc-rich-text-snippet h6 { - @extend %heading-base; - font-size: var(--body-md); - font-weight: bold; - letter-spacing: normal; - margin-bottom: var(--space-unit); -} - -.cc-rich-text__table-wrap { - overflow-x: auto; - width: 100%; -} - -// remove any bottom margins -.cc-text-snippet > :last-child, -.cc-rich-text > :last-child, -.cc-rich-text-snippet > :last-child { - margin-bottom: 0; -} - -/* stylelint-disable selector-no-qualifying-type */ -.cc-rich-text a[href], -.cc-rich-text-snippet a[href] { - @include animated-link; - font-weight: 500; -} -/* stylelint-enable selector-no-qualifying-type */ diff --git a/src/components/RichText/index.ts b/src/components/RichText/index.ts deleted file mode 100644 index bd8294c1..00000000 --- a/src/components/RichText/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './RichText'; diff --git a/src/index.ts b/src/index.ts index fbce6e33..cfb023f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,7 +22,6 @@ export { Logo } from 'Logo/Logo'; export { default as NumberInput } from 'NumberInput'; export { default as Pagination } from 'Pagination'; export { default as RadioInput } from 'RadioInput'; -export { default as RichText } from 'RichText'; export { RouterLinkWrapper } from 'RouterLinkWrapper/RouterLinkWrapper'; export { SearchForm } from 'SearchForm/SearchForm'; export { Section } from 'Section/Section';