mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 09:52:41 +00:00
Move formatVisiblePages
After simplifying, this has become a single-line function used in only one place. Can just be placed directly in the one place it is used.
This commit is contained in:
@@ -15,7 +15,9 @@ const ToolBar = ({ displayOptions, onDisplayOptionsChange, visiblePages, totalPa
|
|||||||
const [toolsVisible, setToolsVisible] = useState(true);
|
const [toolsVisible, setToolsVisible] = useState(true);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
setPageNum(formatVisiblePages(visiblePages));
|
// format multiple visible pages as a range (e.g. "150-153")
|
||||||
|
const pageRange = visiblePages.length === 1 ? `${visiblePages[0]}` : `${visiblePages[0]} - ${visiblePages.at(-1)}`;
|
||||||
|
setPageNum(pageRange);
|
||||||
}, [visiblePages]);
|
}, [visiblePages]);
|
||||||
|
|
||||||
const handleZoomButton = (zoom)=>{
|
const handleZoomButton = (zoom)=>{
|
||||||
@@ -72,11 +74,6 @@ const ToolBar = ({ displayOptions, onDisplayOptionsChange, visiblePages, totalPa
|
|||||||
return deltaZoom;
|
return deltaZoom;
|
||||||
};
|
};
|
||||||
|
|
||||||
// format the visible pages into a range (e.g. "150-153")
|
|
||||||
const formatVisiblePages = (pages)=>{
|
|
||||||
return pages.length === 1 ? `${pages[0]}` : `${pages[0]} - ${pages.at(-1)}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id='preview-toolbar' className={`toolBar ${toolsVisible ? 'visible' : 'hidden'}`} role='toolbar'>
|
<div id='preview-toolbar' className={`toolBar ${toolsVisible ? 'visible' : 'hidden'}`} role='toolbar'>
|
||||||
<button className='toggleButton' title={`${toolsVisible ? 'Hide' : 'Show'} Preview Toolbar`} onClick={()=>{setToolsVisible(!toolsVisible);}}><i className='fas fa-glasses' /></button>
|
<button className='toggleButton' title={`${toolsVisible ? 'Hide' : 'Show'} Preview Toolbar`} onClick={()=>{setToolsVisible(!toolsVisible);}}><i className='fas fa-glasses' /></button>
|
||||||
|
|||||||
Reference in New Issue
Block a user