Skip to content

Commit

Permalink
Refs #267520 - Custom view for News Items, add styles.
Browse files Browse the repository at this point in the history
  • Loading branch information
GhitaB committed Mar 22, 2024
1 parent 977f82d commit 5a62787
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/components/theme/Views/NewsItemView.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
// import { When } from '@plone/volto/components/theme/View/EventDatesInfo';
import React from 'react';
import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
import { Label } from 'semantic-ui-react';
import { BannerTitle } from '@eeacms/volto-insitu-policy/components';

// const Date = (props) => {
// const date = props.content?.effective;
// return date ? (
// <>
// <When start={date} end={date} whole_day={true} open_end={false} />
// </>
// ) : null;
// };
import { HTMLField, isOldFormat } from '@eeacms/volto-insitu-policy/helpers';
import './styles.less';

const SubjectTags = (props) => {
const tags = props.content?.subjects;
Expand All @@ -32,8 +24,23 @@ function NewsItemView(props) {
<div className="insitu-newsitem-view">
<BannerTitle content={content} />
<div className="ui container">
{isOldFormat(content) && (
<>
<p className="documentDescription eea callout">
{content.description}
</p>
<div className="lead-img">
<img
className="main-img"
src={content.image.download}
alt={content.title}
/>
<p className="main-img-caption">{content.image_caption}</p>
</div>
<HTMLField value={content.text} />
</>
)}
<RenderBlocks {...props} />
{/* <Date {...props} /> */}
<SubjectTags {...props} />
</div>
</div>
Expand Down
19 changes: 19 additions & 0 deletions src/components/theme/Views/styles.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
div.insitu-newsitem-view {
p.documentDescription.callout {
background: #eee;
}

div.lead-img {
margin: 1em;
text-align: center;

img.main-img {
width: auto;
max-height: 700px;
}

p.main-img-caption {
background: #ccc;
}
}
}
16 changes: 16 additions & 0 deletions src/helpers/Utils.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const HTMLField = ({ value, className }) => {
if (value === null) {
return <></>;
}

return (
<div
className={className}
dangerouslySetInnerHTML={{ __html: value?.data }}
></div>
);
};

export const isOldFormat = ({ content }) => {
return true;
};
1 change: 1 addition & 0 deletions src/helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { HTMLField, isOldFormat } from './Utils';

0 comments on commit 5a62787

Please sign in to comment.