Skip to content

Commit

Permalink
Update HOPagebuilderComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
Cody Nguyen committed Nov 17, 2021
1 parent 02a54a0 commit d5aabda
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
33 changes: 33 additions & 0 deletions src/components/PageBuilderComponent/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useEffect } from 'react';
import { PageBuilderComponent } from 'simi-pagebuilder-react';

const smRemoveMaxWidthOnMain = () => {
try {
if (document.getElementsByTagName('header')[0])
document.getElementsByTagName(
'header'
)[0].nextSibling.style.maxWidth = 'unset';
} catch (err) {
console.warn(err);
}
};

const HOPageBuilderComponent = props => {
useEffect(() => {
smRemoveMaxWidthOnMain();
return () => {
try {
//var(--venia-global-maxWidth);
if (document.getElementsByTagName('header')[0])
document.getElementsByTagName(
'header'
)[0].nextSibling.style.maxWidth = '1440px';
} catch (err) {
console.warn(err);
}
};
}, []);
return <PageBuilderComponent {...props} />;
};

export default HOPageBuilderComponent;
2 changes: 1 addition & 1 deletion src/components/ProductDetails/ProductFullDetail.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo } from 'react';
import { PageBuilderComponent } from 'simi-pagebuilder-react';
import PageBuilderComponent from '../PageBuilderComponent';
import { FormattedMessage, useIntl } from 'react-intl';
import { Form } from 'informed';
import Price from '@magento/venia-ui/lib/components/Price';
Expand Down
3 changes: 3 additions & 0 deletions src/components/ProductDetails/productFullDetail.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.smProductBuilderRoot > form {
padding: 0;
}
.smProductBuilderRoot h3 {
font-size: 1rem !important;
font-weight: 600 !important;
Expand Down
29 changes: 4 additions & 25 deletions src/override/magentoRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import ErrorView from '@magento/venia-ui/lib/components/ErrorView';

import { fullPageLoadingIndicator } from '@magento/venia-ui/lib/components/LoadingIndicator';
import { useLocation, Link, useHistory } from 'react-router-dom';
import { usePbFinder, PageBuilderComponent } from 'simi-pagebuilder-react';
import { usePbFinder } from 'simi-pagebuilder-react';
import PageBuilderComponent from '../components/PageBuilderComponent';
import ProductDetails from '../components/ProductDetails';
import ProductList from '../components/Products/list';
import ProductGrid from '../components/Products/grid';
Expand Down Expand Up @@ -87,7 +88,6 @@ const MagentoRoute = () => {
pageMaskedId !== 'notfound' &&
(isNotFound || hasError || location.pathname === '/')
) {
smRemoveMaxWidthOnMain();
return (
<PageBuilderComponent
{...pbcProps}
Expand All @@ -99,15 +99,7 @@ const MagentoRoute = () => {
} else if (pbLoading) {
return fullPageLoadingIndicator;
}
try {
if (document.getElementsByTagName('header')[0])
document.getElementsByTagName(
'header'
)[0].nextSibling.style.maxWidth = '1440px';
} catch (err) {
console.warn(err);
}


if (isLoading || isRedirect) {
return fullPageLoadingIndicator;
} else if (RootComponent) {
Expand All @@ -120,7 +112,6 @@ const MagentoRoute = () => {
return fullPageLoadingIndicator;
}
if (type === 'PRODUCT') {
smRemoveMaxWidthOnMain();
return (
<ProductDetails
{...componentData}
Expand Down Expand Up @@ -155,16 +146,4 @@ const MagentoRoute = () => {
);
};

export default MagentoRoute;


const smRemoveMaxWidthOnMain = () => {
try {
if (document.getElementsByTagName('header')[0])
document.getElementsByTagName(
'header'
)[0].nextSibling.style.maxWidth = 'unset';
} catch (err) {
console.warn(err);
}
}
export default MagentoRoute;

0 comments on commit d5aabda

Please sign in to comment.