Skip to content

Commit

Permalink
Adicionada ImageLegacy (temp)
Browse files Browse the repository at this point in the history
  • Loading branch information
bombassaro committed Aug 24, 2020
1 parent 363629d commit c4a622b
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 7 deletions.
5 changes: 4 additions & 1 deletion components/Article/TextBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React from 'react';
import AdBlock from '../AdBlock';
import Block from '../Block';
import Image from '../Image';
import ImageLegacy from '../Image/Legacy';
import Paragraph from './Paragraph';
import {parseBody} from './Utils';

Expand Down Expand Up @@ -44,7 +45,9 @@ const TextBody = ({adsblocks, content, domain, embeds}) => {
case 'Facebook':
return embeds && embeds.Facebook && <embeds.Facebook key={key} value={value} />;
case 'Image':
return <Block custom="article-image-embed" mb="3"><Image domain={domain} key={key} value={value} /></Block>;
return <Block key={key} custom="article-image-embed" mb="3"><Image domain={domain} value={value} /></Block>;
case 'ImageLegacy':
return <Block key={key} custom="article-image-embed" mb="3"><ImageLegacy domain={domain} value={value} /></Block>;
case 'Instagram':
return embeds && embeds.Instagram && <embeds.Instagram key={key} value={value} />;
case 'Tweet':
Expand Down
4 changes: 3 additions & 1 deletion components/Article/Utils/parseBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const parseBody = (content) => {
}

// render image
if(tag === 'img' && attr.src && attr.src.startsWith('/legacy/image'))
bodyItems.push({type: 'ImageLegacy', value: {'image-legacy': attr.src}})

if(tag === 'a' && attr.class && attr.class === 'p-smartembed') {
const childImage = find(child, {tag: 'img'});
if(childImage) {
Expand All @@ -75,7 +78,6 @@ const parseBody = (content) => {
bodyItems.push({type: 'Image', value: propsImage});
}
}

// render embed
if(tag === 'a' && attr.href && !attr.class && attr.href !== '') {

Expand Down
24 changes: 24 additions & 0 deletions components/Image/Legacy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import PropTypes from 'prop-types'
import React from 'react'

import Block from '../Block'

const Image = ({domain, value}) => {

if(!value || !value['image-legacy'])
return false

const imagePath = `${value['image-legacy']}`
return (
<Block custom="article-image-box" w="100p">
<img className='image-article' src={imagePath} alt={`Imagem importada do sistema legado`} />
</Block>
)
}

Image.propTypes = {
value: PropTypes.object.isRequired
}
Image.defaultProps = {value: {}}

export default Image
49 changes: 44 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,28 @@ AdBlock.propTypes = {
content: PropTypes.object
};

var Image$1 = function Image(_ref) {
var domain = _ref.domain,
value = _ref.value;
if (!value || !value['image-legacy']) return false;
var imagePath = "".concat(value['image-legacy']);
return /*#__PURE__*/React__default.createElement(Block, {
custom: "article-image-box",
w: "100p"
}, /*#__PURE__*/React__default.createElement("img", {
className: "image-article",
src: imagePath,
alt: "Imagem importada do sistema legado"
}));
};

Image$1.propTypes = {
value: PropTypes.object.isRequired
};
Image$1.defaultProps = {
value: {}
};

var Paragraph = function Paragraph(_ref) {
var value = _ref.value;
return /*#__PURE__*/React__default.createElement(Typography, {
Expand Down Expand Up @@ -583,6 +605,13 @@ var parseBody = function parseBody(content) {
} // render image


if (tag === 'img' && attr.src && attr.src.startsWith('/legacy/image')) bodyItems.push({
type: 'ImageLegacy',
value: {
'image-legacy': attr.src
}
});

if (tag === 'a' && attr["class"] && attr["class"] === 'p-smartembed') {
var childImage = lodash.find(child, {
tag: 'img'
Expand Down Expand Up @@ -694,11 +723,21 @@ var TextBody = function TextBody(_ref) {

case 'Image':
return /*#__PURE__*/React__default.createElement(Block, {
key: key,
custom: "article-image-embed",
mb: "3"
}, /*#__PURE__*/React__default.createElement(Image, {
domain: domain,
value: value
}));

case 'ImageLegacy':
return /*#__PURE__*/React__default.createElement(Block, {
key: key,
custom: "article-image-embed",
mb: "3"
}, /*#__PURE__*/React__default.createElement(Image$1, {
domain: domain,
value: value
}));

Expand Down Expand Up @@ -865,7 +904,7 @@ Button.defaultProps = {
style: 'primary'
};

var Image$1 = function Image(_ref) {
var Image$2 = function Image(_ref) {
var children = _ref.children,
custom = _ref.custom,
domain = _ref.domain,
Expand All @@ -890,13 +929,13 @@ var Image$1 = function Image(_ref) {
}, children && children));
};

Image$1.propTypes = {
Image$2.propTypes = {
children: PropTypes.node,
custom: PropTypes.string,
domain: PropTypes.string,
value: PropTypes.object.isRequired
};
Image$1.defaultProps = {
Image$2.defaultProps = {
value: {}
};

Expand All @@ -918,7 +957,7 @@ var ColumnHeader = function ColumnHeader(_ref) {
className: "teaser-aria",
href: path,
"aria-label": "Imagem do colunista ".concat(column_name)
}, /*#__PURE__*/React__default.createElement(Image$1, {
}, /*#__PURE__*/React__default.createElement(Image$2, {
domain: domain,
value: image
}))), /*#__PURE__*/React__default.createElement(Block, {
Expand Down Expand Up @@ -4605,7 +4644,7 @@ exports.ColumnHeader = ColumnHeader;
exports.Form = index;
exports.Grid = Grid;
exports.Image = Image;
exports.ImageBackground = Image$1;
exports.ImageBackground = Image$2;
exports.ImageGallery = ImageGallery;
exports.SearchForm = SearchForm;
exports.SearchMenu = SearchMenu;
Expand Down

0 comments on commit c4a622b

Please sign in to comment.