mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-26 13:52:38 +00:00
Get basic function worked out
Adds `setBookMode()` which toggles a className on `.pages`. The `.book-mode` class sets display to grid, and the first child/page to start at the second slot of the book arrangement.
This commit is contained in:
@@ -8,6 +8,14 @@
|
||||
:where(.pages) {
|
||||
margin : 30px 0px;
|
||||
|
||||
&.book-mode {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, auto);
|
||||
grid-template-rows: repeat(3, auto);
|
||||
gap: 10px 10px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
& > :where(.page) {
|
||||
width : 215.9mm;
|
||||
height : 279.4mm;
|
||||
|
||||
@@ -12,6 +12,7 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
|
||||
|
||||
const [zoomLevel, setZoomLevel] = useState(100);
|
||||
const [pageInput, setPageInput] = useState(currentPage);
|
||||
const [arrangement, setArrangement] = useState('single');
|
||||
|
||||
useEffect(()=>{
|
||||
onZoomChange(zoomLevel);
|
||||
@@ -86,6 +87,13 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
|
||||
return deltaZoom;
|
||||
};
|
||||
|
||||
const setBookMode = ()=>{
|
||||
const iframe = document.getElementById('BrewRenderer');
|
||||
const pagesContainer = iframe.contentWindow.document.getElementsByClassName('pages')[0];
|
||||
pagesContainer.classList.toggle('book-mode');
|
||||
pagesContainer.firstChild.style.gridColumnStart = '2' ;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='toolBar'>
|
||||
<div className='group'>
|
||||
@@ -137,6 +145,16 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className='group'>
|
||||
<button
|
||||
id='book-mode'
|
||||
className='tool'
|
||||
onClick={()=>setBookMode()}
|
||||
>
|
||||
{arrangement}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className='group'>
|
||||
<button
|
||||
id='previous-page'
|
||||
|
||||
Reference in New Issue
Block a user