Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Fix RDMD callout titles... (AGAIN 🎩) (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafegoldberg authored Apr 30, 2020
1 parent 0238060 commit 296ebeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Components Callout 1`] = `"<blockquote class=\\"callout callout_error\\" theme=\\"❗️\\"><h3 class=\\"callout-heading false\\"><span class=\\"callout-icon\\">❗️</span>Error Callout</h3><p>Lorem ipsum dolor.</p></blockquote>"`;
exports[`Components Callout 1`] = `"<blockquote class=\\"callout callout_error\\" theme=\\"❗️\\"><h3 class=\\"callout-heading false\\"><span class=\\"callout-icon\\">❗️</span><p>Error Callout</p></h3><p>Lorem ipsum dolor.</p></blockquote>"`;
exports[`Components Callout 2`] = `"<blockquote class=\\"callout callout_default\\" theme=\\"🎟\\"><h3 class=\\"callout-heading empty\\"><span class=\\"callout-icon\\">🎟</span></h3><p>Callout with no title or theme.</p></blockquote>"`;
Expand Down
8 changes: 5 additions & 3 deletions packages/markdown/components/Callout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ const React = require('react');
const PropTypes = require('prop-types');

const Callout = props => {
const { attributes, children, theme, title, icon } = props;
const content = children.splice(1);
let { children } = props;
const { attributes, theme, title, icon } = props;
const content = title ? children.splice(1) : children;
children = title ? children : '';
return (
// eslint-disable-next-line react/jsx-props-no-spreading
<blockquote {...attributes} className={`callout callout_${theme}`} theme={icon}>
<h3 className={`callout-heading ${!title && 'empty'}`}>
<span className="callout-icon">{icon}</span>
{children.length >= 2 ? children : title}
{children}
</h3>
{(content.length && content) || (!title ? children : '')}
</blockquote>
Expand Down

0 comments on commit 296ebeb

Please sign in to comment.