Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Guards for missing configs (fixes #195) #196

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions js/BoxMenuView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class BoxMenuView extends MenuView {

className() {
const backgroundImages = this.model.get('_boxMenu')?._backgroundImage;
const backgroundImage = backgroundImages[`_${device.screenSize}`] ?? backgroundImages._small;
const backgroundImage = backgroundImages?.[`_${device.screenSize}`] ?? backgroundImages?._small;
const textAlignment = this.model.get('_boxMenu')?._menuHeader?._textAlignment;

return [
`${super.className()} boxmenu`,
backgroundImage && 'has-bg-image',
textAlignment._title && `title-align-${textAlignment._title}`,
textAlignment._body && `body-align-${textAlignment._body}`,
textAlignment._instruction && `instruction-align-${textAlignment._instruction}`
textAlignment?._title && `title-align-${textAlignment._title}`,
textAlignment?._body && `body-align-${textAlignment._body}`,
textAlignment?._instruction && `instruction-align-${textAlignment._instruction}`
].join(' ');
}

Expand Down
18 changes: 9 additions & 9 deletions templates/boxMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ export default function BoxMenu (props) {

// set menu background image
const backgroundImages = _boxMenu?._backgroundImage;
const backgroundImage = backgroundImages[`_${device.screenSize}`] ?? backgroundImages._small;
const backgroundImage = backgroundImages?.[`_${device.screenSize}`] ?? backgroundImages?._small;
// set menu background styles
const styles = _boxMenu._backgroundStyles;
const styles = _boxMenu?._backgroundStyles || {};

// set header background image
const header = _boxMenu?._menuHeader;
const headerBackgroundImages = header._backgroundImage;
const headerBackgroundImage = headerBackgroundImages[`_${device.screenSize}`] ?? headerBackgroundImages._small;
const headerBackgroundImages = header?._backgroundImage;
const headerBackgroundImage = headerBackgroundImages?.[`_${device.screenSize}`] ?? headerBackgroundImages?._small;
// set header background styles
const headerBackgroundStyles = header._backgroundStyles;
const headerBackgroundStyles = header?._backgroundStyles || {};
// set header minimum height
const headerMinimumHeights = header._minimumHeights;
const headerMinimumHeight = headerMinimumHeights[`_${device.screenSize}`] ?? headerMinimumHeights._small;
const headerMinimumHeights = header?._minimumHeights;
const headerMinimumHeight = headerMinimumHeights?.[`_${device.screenSize}`] ?? headerMinimumHeights?._small;

return (
<>
Expand All @@ -40,7 +40,7 @@ export default function BoxMenu (props) {
className="background"
aria-hidden="true"
style={{
backgroundImage: 'url(' + backgroundImage + ')',
backgroundImage: backgroundImage && 'url(' + backgroundImage + ')',
backgroundRepeat: styles._backgroundRepeat,
backgroundSize: styles._backgroundSize,
backgroundPosition: styles._backgroundPosition
Expand All @@ -66,7 +66,7 @@ export default function BoxMenu (props) {
className="background"
aria-hidden="true"
style={{
backgroundImage: 'url(' + headerBackgroundImage + ')',
backgroundImage: headerBackgroundImage && 'url(' + headerBackgroundImage + ')',
backgroundRepeat: headerBackgroundStyles._backgroundRepeat,
backgroundSize: headerBackgroundStyles._backgroundSize,
backgroundPosition: headerBackgroundStyles._backgroundPosition
Expand Down