Uncustomizable Markup
Visage typically requires specific class names to be added on to components in order to style them properly, but sometimes you need to render content that was generated by a third-party tool, and you don't have a good way of adding Visage class names onto the generated content.
For instance, Contentful's rich-text utility allows content authors to create bulleted lists, but we don't have any way of telling Contentful to add specific Visage class names onto its generated bullet lists — so we need another way to make sure that the content is styled properly.
That's what the Uncustomizable Markup component is for! It is a wrapper element that applies a Visage standard look-and-feel to some HTML tags inside that wrapper.
<UncustomizableMarkup>// uncustomizable content goes here</UncustomizableMarkup>
<!-- doesn't have to a be a div tag; use on any tag --><div class="uncustomizable-markup"><!-- uncustomizable content goes here --></div>
Examples
With <ul>
Before (HTML default):
item 1
item 1
item 1
item 1
After (using Uncustomizable Markup):
- item 1
- item 1
- item 1
- item 1
With <ol>
Before (HTML default):
item 1
item 1
item 1
item 1
After (using Uncustomizable Markup):
- item 1
- item 1
- item 1
- item 1
With <table>
Before (HTML default):
Table header | Table header | Table header |
---|---|---|
This table has thead and tbody tags. | Table data | Table data |
Table data | Table data | Table data |
After (using Uncustomizable Markup):
Table header | Table header | Table header |
---|---|---|
This table has thead and tbody tags. | Table data | Table data |
Table data | Table data | Table data |
React Usage
You can use React's dangerouslySetInnerHTML
functionality if your uncustomizable content is a string
.
const ThirdPartyContent = () => {// content is a stringconst someThirdPartyContent = `<ul><li>item 1</li><li>item 2</li><li>item 2</li></ul>`return (<UncustomizableMarkupdangerouslySetInnerHTML={{ __html: someThirdPartyContent }}/>)}
Or you can simply pass children if your uncustomizable content is already transformed into a React Node.
const ThirdPartyContent = () => {// content is a React Nodeconst someThirdPartyContent = (<ul><li>item 1</li><li>item 2</li><li>item 2</li></ul>)return <UncustomizableMarkup>{someThirdPartyContent}</UncustomizableMarkup>}
Components
UncustomizableMarkup
UncustomizableMarkup
has no props of its own
All props are forwarded to the element specified in thecomponent
prop(default: <div/>
)
Guidelines
Developer Guidelines
This component should be placed around any output from the rich text editor of a CMS, if that CMS doesn't allow us to add CSS classes to the editor's content such as bullet lists. This applies to Sitecore, Contentful, WordPress, and others.