Skip to content

Commit

Permalink
change(columns): implement narrow, container and wide width classes
Browse files Browse the repository at this point in the history
- we can apply any of the defined widths this way starting from the
  layout view until we have extra classes
  • Loading branch information
ichim-david committed Oct 27, 2022
1 parent 9846159 commit 9696b54
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/theme/Views/NarrowView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { hasBlocksData } from '@plone/volto/helpers';
const NarrowView = ({ content }) => {
return hasBlocksData(content) ? (
<>
<BodyClass className="narrow_view" />
<BodyClass className="narrow-view" />
<DefaultView content={content} className={'page-area'} />
</>
) : null;
Expand Down
60 changes: 60 additions & 0 deletions src/components/theme/Views/WideView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Document view component.
* @module components/theme/View/WideView
*/

import React from 'react';
import PropTypes from 'prop-types';

import { DefaultView } from '@plone/volto/components/';

import { BodyClass } from '@plone/volto/helpers';

import { hasBlocksData } from '@plone/volto/helpers';

/**
* Component to display the default view.
* @function WideView
* @param {Object} content Content object.
* @returns {string} Markup of the component.
*/
const WideView = ({ content }) => {
return hasBlocksData(content) ? (
<>
<BodyClass className="wide-view" />
<DefaultView content={content} />
</>
) : null;
};

/**
* Property types.
* @property {Object} propTypes Property types.
* @static
*/
WideView.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 WideView;
15 changes: 13 additions & 2 deletions theme/themes/eea/globals/site.overrides
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,23 @@ h2, h3, h4, h5, h6 {
color: @contentAreaColor;
}

.narrow_view [id="page-document"] > * {
[class*="narrow-view"] [id="page-document"] > *,
.content-area .narrow_width
{
max-width: @narrowWidth;
margin: 0 auto;
}

.wide_view [id="page-document"] > * {
[class="view-defaultview"] [id="page-document"] > *,
.content-area .container-width
{
max-width: @containerWidth;
margin: 0 auto;
}

[class="wide-view"] [id="page-document"] > *,
.content-area .wide-width
{
max-width: @wideWidth;
margin: 0 auto;
}
Expand Down
1 change: 1 addition & 0 deletions theme/themes/eea/globals/site.variables
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@
--------------------*/
@textWidth: 800px;
@narrowWidth: var(--narrow-text-width, 900px);
@containerWidth: var(--content-text-width, 1120px);
@wideWidth: var(--wide-text-width, 1200px);


Expand Down

0 comments on commit 9696b54

Please sign in to comment.