From 64fb0326220e484b08afdf5abedc8501dd0077c9 Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Thu, 22 Aug 2024 15:51:16 -0500 Subject: [PATCH 01/13] fix className --- client/homebrew/brewRenderer/toolBar/toolBar.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/brewRenderer/toolBar/toolBar.jsx b/client/homebrew/brewRenderer/toolBar/toolBar.jsx index 8569e5df8..f857d5773 100644 --- a/client/homebrew/brewRenderer/toolBar/toolBar.jsx +++ b/client/homebrew/brewRenderer/toolBar/toolBar.jsx @@ -91,7 +91,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
Date: Thu, 22 Aug 2024 15:52:52 -0500 Subject: [PATCH 02/13] add a toFit() method to determine zoom change Adds a toFit() method to determine the delta/change needed to the current zoomLevel to fit the page to the pane, so that the widest page fits just inside the pane. --- .../homebrew/brewRenderer/toolBar/toolBar.jsx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/client/homebrew/brewRenderer/toolBar/toolBar.jsx b/client/homebrew/brewRenderer/toolBar/toolBar.jsx index f857d5773..8276f366f 100644 --- a/client/homebrew/brewRenderer/toolBar/toolBar.jsx +++ b/client/homebrew/brewRenderer/toolBar/toolBar.jsx @@ -41,9 +41,36 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ } }; + + const toFit = ()=>{ + const iframe = document.getElementById('BrewRenderer'); + const iframeWidth = iframe.getBoundingClientRect().width; + const pages = iframe.contentWindow.document.getElementsByClassName('page'); + + // find widest page, in case pages are different widths, so that the zoom is adapted to not cut the widest page off screen. + let widestPage = 0; + [...pages].forEach((page)=>{ + const width = page.offsetWidth; + if(width > widestPage) + widestPage = width; + }); + + const margin = 5; // extra space so page isn't edge to edge (not truly "to fit") + const desiredZoom = (iframeWidth / widestPage) * 100; + const deltaZoom = (desiredZoom - zoomLevel) - margin; + return deltaZoom; + } + return (
+ + From 0dc9e9ecdbfbf0b8cfb3446b4304d4de579a1bf8 Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Thu, 22 Aug 2024 23:21:48 -0500 Subject: [PATCH 06/13] Add 2 custom zoom related icons New icons for Zoom to Fit, and Fit Width buttons. Used SVGR online tool to create react components and then combined them. If doing in future, be sure to set currentColor on `fill` property in the SVG itself. Make the SVGs as closed curves only (don't rely on stroke). set only a width property, not height. --- .../homebrew/brewRenderer/toolBar/toolBar.jsx | 6 ++- client/icons/icon-components/zoomIcons.jsx | 46 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 client/icons/icon-components/zoomIcons.jsx diff --git a/client/homebrew/brewRenderer/toolBar/toolBar.jsx b/client/homebrew/brewRenderer/toolBar/toolBar.jsx index 4ef5ab211..07d6cfb70 100644 --- a/client/homebrew/brewRenderer/toolBar/toolBar.jsx +++ b/client/homebrew/brewRenderer/toolBar/toolBar.jsx @@ -3,6 +3,8 @@ const React = require('react'); const { useState, useEffect } = React; const _ = require('lodash') +import * as ZoomIcons from '../../../icons/icon-components/zoomIcons.jsx'; + const MAX_ZOOM = 300; const MIN_ZOOM = 10; @@ -92,14 +94,14 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ className='tool' onClick={()=>handleZoomChange(calculateZoom('fill'))} > - toFill + From 6bb5d04f07acbeccfcc7a6bba86a96e397cbf121 Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Fri, 23 Aug 2024 23:02:04 -0500 Subject: [PATCH 09/13] round the calculated zoom level --- client/homebrew/brewRenderer/toolBar/toolBar.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/brewRenderer/toolBar/toolBar.jsx b/client/homebrew/brewRenderer/toolBar/toolBar.jsx index 544ff7ff0..ae5949b2d 100644 --- a/client/homebrew/brewRenderer/toolBar/toolBar.jsx +++ b/client/homebrew/brewRenderer/toolBar/toolBar.jsx @@ -22,7 +22,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ }, [currentPage]); const handleZoomButton = (delta)=>{ - const newZoomLevel = _.clamp(zoomLevel + delta, MIN_ZOOM, MAX_ZOOM); + const newZoomLevel = _.round(_.clamp(zoomLevel + delta, MIN_ZOOM, MAX_ZOOM)); setZoomLevel(newZoomLevel); }; From 7b767368dfdd856b44bb13661fe03604a7e1b7a8 Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Mon, 26 Aug 2024 15:51:35 -0500 Subject: [PATCH 10/13] Change icons to mask-image Removes icons as components, uses mask-image instead. Sets a size on the .fac icons to 1em so by default they are 1em and retain their aspect ratio. rename the icon files for consistency. --- .../homebrew/brewRenderer/toolBar/toolBar.jsx | 7 ++- .../brewRenderer/toolBar/toolBar.less | 5 ++ client/icons/customIcons.less | 50 ++++++++++++------- client/icons/fit-width.svg | 15 ++++++ client/icons/icon-components/zoomIcons.jsx | 46 ----------------- client/icons/zoom-to-fit.svg | 12 +++++ 6 files changed, 66 insertions(+), 69 deletions(-) create mode 100644 client/icons/fit-width.svg delete mode 100644 client/icons/icon-components/zoomIcons.jsx create mode 100644 client/icons/zoom-to-fit.svg diff --git a/client/homebrew/brewRenderer/toolBar/toolBar.jsx b/client/homebrew/brewRenderer/toolBar/toolBar.jsx index ad9b99f1f..7a111fbb8 100644 --- a/client/homebrew/brewRenderer/toolBar/toolBar.jsx +++ b/client/homebrew/brewRenderer/toolBar/toolBar.jsx @@ -3,7 +3,6 @@ const React = require('react'); const { useState, useEffect } = React; const _ = require('lodash'); -import * as ZoomIcons from '../../../icons/icon-components/zoomIcons.jsx'; const MAX_ZOOM = 300; const MIN_ZOOM = 10; @@ -87,18 +86,18 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{ {/*v=====----------------------< Zoom Controls >---------------------=====v*/}