mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-26 03:02:40 +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);
|
||||
|
||||
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]);
|
||||
|
||||
const handleZoomButton = (zoom)=>{
|
||||
@@ -72,11 +74,6 @@ const ToolBar = ({ displayOptions, onDisplayOptionsChange, visiblePages, totalPa
|
||||
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 (
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user