diff --git a/src/components/Actions.tsx b/src/components/Actions.tsx index 15e1c740..144f5539 100644 --- a/src/components/Actions.tsx +++ b/src/components/Actions.tsx @@ -109,6 +109,7 @@ export const ShapesSwitcher = ({ }`; return ( []) => void; onAddToLibrary: (elements: NonDeleted[]) => void; }) => { + const isMobile = useIsMobile(); const numCells = library.length + (pendingElements.length > 0 ? 1 : 0); - const CELLS_PER_ROW = 3; + const CELLS_PER_ROW = isMobile ? 4 : 6; const numRows = Math.max(1, Math.ceil(numCells / CELLS_PER_ROW)); const rows = []; let addedPendingElements = false; @@ -112,7 +113,7 @@ const LibraryMenuItems = ({ for (let row = 0; row < numRows; row++) { const i = CELLS_PER_ROW * row; const children = []; - for (let j = 0; j < 3; j++) { + for (let j = 0; j < CELLS_PER_ROW; j++) { const shouldAddPendingElements: boolean = pendingElements.length > 0 && !addedPendingElements && @@ -365,19 +366,21 @@ const LayerUI = ({ }); }, [setAppState]); + const libraryMenu = appState.isLibraryOpen ? ( + + ) : null; + const renderFixedSideContainer = () => { const shouldRenderSelectedShapeActions = showSelectedShapeActions( appState, elements, ); - const libraryMenu = appState.isLibraryOpen ? ( - - ) : null; + return ( @@ -503,6 +506,7 @@ const LayerUI = ({ appState={appState} elements={elements} actionManager={actionManager} + libraryMenu={libraryMenu} exportButton={renderExportDialog()} setAppState={setAppState} onUsernameChange={onUsernameChange} diff --git a/src/components/LibraryUnit.scss b/src/components/LibraryUnit.scss index cf6aba0e..16843844 100644 --- a/src/components/LibraryUnit.scss +++ b/src/components/LibraryUnit.scss @@ -2,10 +2,10 @@ align-items: center; border: 1px solid #ccc; display: flex; - height: 126px; // match width justify-content: center; position: relative; - width: 126px; // exactly match the toolbar width when 3 are lined up + padding + width: 63px; + height: 63px; // match width } .library-unit__dragger { diff --git a/src/components/LibraryUnit.tsx b/src/components/LibraryUnit.tsx index 6724d9a9..bcf1959f 100644 --- a/src/components/LibraryUnit.tsx +++ b/src/components/LibraryUnit.tsx @@ -5,6 +5,7 @@ import { close } from "../components/icons"; import "./LibraryUnit.scss"; import { t } from "../i18n"; +import useIsMobile from "../is-mobile"; // fa-plus const PLUS_ICON = ( @@ -50,8 +51,9 @@ export const LibraryUnit = ({ }, [elements, pendingElements]); const [isHovered, setIsHovered] = useState(false); + const isMobile = useIsMobile(); - const adder = isHovered && pendingElements && ( + const adder = (isHovered || isMobile) && pendingElements && (
{PLUS_ICON}
); @@ -79,7 +81,7 @@ export const LibraryUnit = ({ }} /> {adder} - {elements && isHovered && ( + {elements && (isHovered || isMobile) && (