Skip to content

Commit

Permalink
feat: added container prop to StickyBlocks component and fix view
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Mar 28, 2024
1 parent 882ee6c commit 9fe1e4c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/StickyBlocks/StickyBlocks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@ import { useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom';
import { RenderBlocks } from '@plone/volto/components';

const StickyBlocks = () => {
const DefaultContainer = ({ children, className }) => (
<div className={className}>{children}</div>
);

const StickyBlocks = ({ container = DefaultContainer }) => {
const location = useLocation();
const blocks = useSelector(
(state) => state.content?.['@components']?.['sticky-blocks'],
(state) => state.content?.data?.['@components']?.['sticky-blocks'],
);

return blocks ? <RenderBlocks content={blocks} location={location} /> : <></>;
const ContainerComponent = container;
return blocks ? (
<ContainerComponent className="sticky-blocks">
<RenderBlocks content={blocks} location={location} />
</ContainerComponent>
) : (
<></>
);
};
export default StickyBlocks;

0 comments on commit 9fe1e4c

Please sign in to comment.