Skip to content

Commit

Permalink
add PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
goranalkovic-infinum committed Oct 9, 2024
1 parent a325f7b commit a1bab18
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
8 changes: 7 additions & 1 deletion lib/components/responsive/mini-responsive.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export const MiniResponsive = (props) => {
innerContentAlign = 'start',
} = props;

if (typeof rawBreakpoints === 'undefined' || !Array.isArray(rawBreakpoints)) {
console.warn(__("MiniResponsive: Missing or invalid 'breakpoints' prop.", 'eightshift-ui-components'));

return null;
}

const breakpoints = rawBreakpoints.slice(1);
const desktopFirstBreakpoints = (rawDesktopFirstBreakpoints ?? rawBreakpoints.slice(0, -1)).map((breakpoint) =>
breakpoint.startsWith('max-') ? breakpoint : `max-${breakpoint}`,
Expand Down Expand Up @@ -132,7 +138,7 @@ export const MiniResponsive = (props) => {

{firstMobileFirstOverride &&
!isDesktopFirst &&
sprintf(__('Applies when the browser width is %dpx or narrower.', 'eightshift-ui-components'), breakpointData[firstMobileFirstOverride] - 1)}
sprintf(__('Applies when the browser width is %dpx or less.', 'eightshift-ui-components'), breakpointData[firstMobileFirstOverride] - 1)}

{lastDesktopFirstOverride &&
isDesktopFirst &&
Expand Down
9 changes: 7 additions & 2 deletions lib/components/responsive/responsive.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useState } from 'react';
import { DecorativeTooltip } from '../tooltip/tooltip';
import { clsx } from 'clsx/lite';

import { __, sprintf } from '@wordpress/i18n';
import { BreakpointPreview } from '../breakpoint-preview/breakpoint-preview';
import { upperFirst } from '../../utilities';
Expand Down Expand Up @@ -101,6 +100,12 @@ export const Responsive = (props) => {
innerContentAlign = 'start',
} = props;

if (typeof rawBreakpoints === 'undefined' || !Array.isArray(rawBreakpoints)) {
console.warn(__("Responsive: Missing or invalid 'breakpoints' prop.", 'eightshift-ui-components'));

return null;
}

const breakpoints = rawBreakpoints.slice(1);
const desktopFirstBreakpoints = (rawDesktopFirstBreakpoints ?? rawBreakpoints.slice(0, -1)).map((breakpoint) =>
breakpoint.startsWith('max-') ? breakpoint : `max-${breakpoint}`,
Expand Down Expand Up @@ -138,7 +143,7 @@ export const Responsive = (props) => {

{firstMobileFirstOverride &&
!isDesktopFirst &&
sprintf(__('Applies when the browser width is %dpx or narrower.', 'eightshift-ui-components'), breakpointData[firstMobileFirstOverride] - 1)}
sprintf(__('Applies when the browser width is %dpx or less.', 'eightshift-ui-components'), breakpointData[firstMobileFirstOverride] - 1)}

{lastDesktopFirstOverride &&
isDesktopFirst &&
Expand Down
6 changes: 0 additions & 6 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,6 @@ function App() {
},
];

// const [repeaterItems, setRepeaterItems] = useState();
// const [repeaterItems2, setRepeaterItems2] = useState();
// const [draggableListItems, setDraggableListItems] = useState();
// const [draggableListItems2, setDraggableListItems2] = useState();
// const [draggableItems, setDraggableItems] = useState();

const [repeaterItems, setRepeaterItems] = useState(repeaterDefaultItems);
const [repeaterItems2, setRepeaterItems2] = useState(repeaterDefaultItems2);
const [draggableListItems, setDraggableListItems] = useState(draggableListDefaultItems);
Expand Down

0 comments on commit a1bab18

Please sign in to comment.