Skip to content

Commit

Permalink
Added lead image
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Mar 13, 2020
1 parent 0802ed6 commit bfdba53
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/customizations/volto/components/theme/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class App extends Component {
actualPathName={this.props.pathname}
pathname={path}
/>
<Breadcrumbs pathname={path} />

<Segment basic className="content-area">
<main>
<OutdatedBrowser />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,20 @@ class Breadcrumbs extends Component {
*/
render() {
return (
<Segment
role="navigation"
aria-label={this.props.intl.formatMessage(messages.breadcrumbs)}
className="breadcrumbs"
secondary
vertical
>
<Container>
<Container>
<Segment
role="navigation"
aria-label={this.props.intl.formatMessage(messages.breadcrumbs)}
className="breadcrumbs"
secondary
vertical
>
<Breadcrumb>
<Link
to="/"
className="section"
title={this.props.intl.formatMessage(messages.home)}
>
>
<Icon name={homeSVG} size="18px" />
</Link>
{this.props.items.map((item, index, items) => [
Expand All @@ -112,8 +112,8 @@ class Breadcrumbs extends Component {
),
])}
</Breadcrumb>
</Container>
</Segment>
</Segment>
</Container>
);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/customizations/volto/components/theme/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
Logo,
Navigation,
SearchWidget,
Breadcrumbs,
} from '@plone/volto/components';

import HomepageSlider from '~/components/theme/Header/HomepageSlider';
Expand Down Expand Up @@ -107,7 +108,10 @@ class Header extends Component {
{this.state.isHomepage ? (
<HomepageSlider />
) : (
<div className="header-leadimage"></div>
<div style={{ position: 'relative' }}>
<Breadcrumbs pathname={this.props.pathname} />
<div id="header-leadimage"></div>
</div>
)}
</div>
</div>
Expand Down
151 changes: 151 additions & 0 deletions src/customizations/volto/components/theme/View/DefaultView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/**
* Document view component.
* @module components/theme/View/DefaultView
*/

import React from 'react';
import PropTypes from 'prop-types';
import { Helmet } from '@plone/volto/helpers';
import { defineMessages, injectIntl } from 'react-intl';
import { Portal } from 'react-portal';

import { Container, Image } from 'semantic-ui-react';
import { map } from 'lodash';

import { settings, blocks } from '~/config';

import {
getBlocksFieldname,
getBlocksLayoutFieldname,
hasBlocksData,
getBaseUrl,
} from '@plone/volto/helpers';

const messages = defineMessages({
unknownBlock: {
id: 'Unknown Block',
defaultMessage: 'Unknown Block {block}',
},
});

/**
* Component to display the default view.
* @function DefaultView
* @param {Object} content Content object.
* @returns {string} Markup of the component.
*/
const DefaultView = ({ content, intl, location }) => {
const blocksFieldname = getBlocksFieldname(content);
const blocksLayoutFieldname = getBlocksLayoutFieldname(content);

return hasBlocksData(content) ? (
<div>
<Portal node={__CLIENT__ && document.querySelector('#header-leadimage')}>
{content.image && (
<div className="leadimage-header">
<div className="leadimage-container">
<div className="leadimage-wrapper">
<div className="leadimage document-image"
style={{ backgroundImage: `url(${content.image.download})` }}
>
</div>
<div className="image-layer"></div>
<div class="ui container image-content">
<h1 class="leadimage-title">{content.title}</h1>
<p>{content.description}</p>
</div>
</div>
</div>
</div>
)}
</Portal>
<div id="page-document" className="ui container">
<Helmet title={content.title} />
{map(content[blocksLayoutFieldname].items, block => {
const Block =
blocks.blocksConfig[content[blocksFieldname]?.[block]?.['@type']]?.[
'view'
] || null;
return Block !== null ? (
<Block
key={block}
id={block}
properties={content}
data={content[blocksFieldname][block]}
path={getBaseUrl(location.pathname)}
/>
) : (
<div key={block}>
{intl.formatMessage(messages.unknownBlock, {
block: content[blocksFieldname]?.[block]?.['@type'],
})}
</div>
);
})}
</div>
</div>
) : (
<Container id="page-document">
<Helmet title={content.title} />
<h1 className="documentFirstHeading">{content.title}</h1>
{content.description && (
<p className="documentDescription">{content.description}</p>
)}
{content.image && (
<Image
className="document-image"
src={content.image.scales.thumb.download}
floated="right"
/>
)}
{content.remoteUrl && (
<span>
The link address is:
<a href={content.remoteUrl}>{content.remoteUrl}</a>
</span>
)}
{content.text && (
<div
dangerouslySetInnerHTML={{
__html: content.text.data.replace(
/a href="([^"]*\.[^"]*)"/g,
`a href="${settings.apiPath}$1/download/file"`,
),
}}
/>
)}
</Container>
);
};

/**
* Property types.
* @property {Object} propTypes Property types.
* @static
*/
DefaultView.propTypes = {
/**
* Content of the object
*/
content: PropTypes.shape({
/**
* Title of the object
*/
title: PropTypes.string,
/**
* Description of the object
*/
description: PropTypes.string,
/**
* Text of the object
*/
text: PropTypes.shape({
/**
* Data of the text of the object
*/
data: PropTypes.string,
}),
}).isRequired,
};

export default injectIntl(DefaultView);
20 changes: 17 additions & 3 deletions theme/themes/bise/collections/breadcrumb.overrides
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,23 @@
.home.icon {
margin-right: 0;
}
}

.ui.vertical.segment.breadcrumbs {
position: absolute !important;
background: none;
padding: 0;
z-index: 1;
top: 0;
overflow: hidden;

.breadcrumb {
display: inline-flex;
background: #000;
padding: 5px 10px;
}

@media only screen and (min-width: @tabletBreakpoint) {
padding-right: 0;
padding-left: 0;
.ui.breadcrumb .section {
color: #fff;
}
}
61 changes: 40 additions & 21 deletions theme/themes/bise/globals/site.overrides
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ a:hover {
color: @darkGreenColor;
}

.documentFirstHeading {
margin-top: 0.5em !important;
}

/*-------------------
Header
--------------------*/
Expand Down Expand Up @@ -318,42 +322,57 @@ a:hover {
display: none;
}

.leadimage-header {
position: relative;
display: block;
}

/* .homepage-slide-wrapper {
height: 500px;
.leadimage-container {
overflow: hidden;
height: 400px;
}

.leadimage-wrapper {
height: 400px;
position: relative;
}

.homepage-slide-img {
.leadimage {
height: 100%;
background-size: cover;
background-repeat: no-repeat;
background-position: left center;
background-color: #000c;
background-color: rgba(0,0,0,0.8);
}

.slide-content {
.image-layer {
background-color:rgba(0,0,0,0.2);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.image-content {
position: absolute;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
top: 40%;
bottom: 25%;
z-index: 997;
text-align: left;
color: #fff;
z-index: 99;
}

.slide-title {
font-size: 60px;
font-weight: 700;
margin-bottom: 1rem;
line-height: 1.2;
font-family: @headerFont;
h1 {
margin-bottom: 1rem;
font-weight: 700;
font-size: 48px;
}
p {
font-size: 24px;
font-weight: 200;
max-width: 770px;
}
}

.slide-description {
font-size: 24px;
line-height: 1.2;
font-weight: 200;
max-width: 540px;
} */

0 comments on commit bfdba53

Please sign in to comment.