mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-28 04:52:40 +00:00
Merge branch 'View-Modes-Radio-Options' into View-Modes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
require('./anchoredBox.less');
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import React, { useState, useRef, useEffect, forwardRef } from 'react';
|
||||
import './anchoredBox.less';
|
||||
|
||||
const AnchoredBox = ({ anchorPoint = 'center', className, children, ...props })=>{
|
||||
const [visible, setVisible] = useState(false);
|
||||
@@ -8,10 +8,12 @@ const AnchoredBox = ({ anchorPoint = 'center', className, children, ...props })=
|
||||
|
||||
useEffect(()=>{
|
||||
const handleClickOutside = (evt)=>{
|
||||
if(boxRef.current &&
|
||||
!boxRef.current.contains(evt.target) &&
|
||||
triggerRef.current &&
|
||||
!triggerRef.current.contains(evt.target)){
|
||||
if(
|
||||
boxRef.current &&
|
||||
!boxRef.current.contains(evt.target) &&
|
||||
triggerRef.current &&
|
||||
!triggerRef.current.contains(evt.target)
|
||||
) {
|
||||
setVisible(false);
|
||||
}
|
||||
};
|
||||
@@ -33,18 +35,32 @@ const AnchoredBox = ({ anchorPoint = 'center', className, children, ...props })=
|
||||
iframe.contentWindow.document.removeEventListener('click', handleClickOutside);
|
||||
}
|
||||
};
|
||||
}, []); // Empty dependency array to run effect on mount only
|
||||
}, []);
|
||||
|
||||
const handleClick = ()=>{
|
||||
setVisible(!visible);
|
||||
triggerRef.current?.focus();
|
||||
};
|
||||
|
||||
const handleKeyDown = (evt)=>{
|
||||
if(evt.key === 'Escape') {
|
||||
setVisible(false);
|
||||
triggerRef.current?.focus();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<button className={`${className} anchored-trigger${visible ? ' active' : ''}`} onClick={handleClick} ref={triggerRef}>
|
||||
<i className='fas fa-gear' />
|
||||
</button>
|
||||
<div className={`anchored-box${visible ? ' active' : ''}`} ref={boxRef}>
|
||||
<TriggerButton
|
||||
className={`${className} anchored-trigger${visible ? ' active' : ''}`}
|
||||
onClick={handleClick}
|
||||
ref={triggerRef}
|
||||
/>
|
||||
<div
|
||||
className={`anchored-box${visible ? ' active' : ''}`}
|
||||
ref={boxRef}
|
||||
onKeyDown={(evt)=>handleKeyDown(evt)}
|
||||
>
|
||||
<h1>{props.title}</h1>
|
||||
{children}
|
||||
</div>
|
||||
@@ -52,4 +68,10 @@ const AnchoredBox = ({ anchorPoint = 'center', className, children, ...props })=
|
||||
);
|
||||
};
|
||||
|
||||
const TriggerButton = forwardRef((props, ref)=>(
|
||||
<button ref={ref} {...props}>
|
||||
<i className='fas fa-gear' />
|
||||
</button>
|
||||
));
|
||||
|
||||
export default AnchoredBox;
|
||||
|
||||
@@ -93,13 +93,13 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages, onStyleC
|
||||
return deltaZoom;
|
||||
};
|
||||
|
||||
const setBookMode = ()=>{
|
||||
const nextMode = modes[(modes.indexOf(arrangement) + 1) % modes.length];
|
||||
setArrangement(nextMode);
|
||||
const setBookMode = (view)=>{
|
||||
// const nextMode = modes[(modes.indexOf(arrangement) + 1) % modes.length];
|
||||
setArrangement(view);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`toolBar ${toolsVisible ? 'visible' : 'hidden'}`}>
|
||||
<div 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>
|
||||
{/*v=====----------------------< Zoom Controls >---------------------=====v*/}
|
||||
<div className='group'>
|
||||
@@ -153,13 +153,27 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages, onStyleC
|
||||
|
||||
{/*v=====----------------------< Page Controls >---------------------=====v*/}
|
||||
<div className='group'>
|
||||
<button
|
||||
id='book-mode'
|
||||
className='tool'
|
||||
onClick={()=>setBookMode()}
|
||||
>
|
||||
{arrangement}
|
||||
</button>
|
||||
<div className='radio-group' role='group'>
|
||||
<button role='radio'
|
||||
id='single-view'
|
||||
className={`tool${arrangement === 'single' && ' active'}`}
|
||||
title='Single Page'
|
||||
onClick={()=>setBookMode('single')}
|
||||
><i className='fac single-view-alt' /></button>
|
||||
<button role='radio'
|
||||
id='facing-view'
|
||||
className={`tool${arrangement === 'facing' && ' active'}`}
|
||||
title='Facing Pages'
|
||||
onClick={()=>setBookMode('facing')}
|
||||
><i className='fac facing-view-alt' /></button>
|
||||
<button role='radio'
|
||||
id='flow-view'
|
||||
className={`tool${arrangement === 'flow' && ' active'}`}
|
||||
title='Flow Pages'
|
||||
onClick={()=>setBookMode('flow')}
|
||||
><i className='fac flow-view-alt' /></button>
|
||||
|
||||
</div>
|
||||
<AnchoredBox id='view-mode-options' className='tool' title='Options'>
|
||||
<label title='Modify the horizontal space between pages.'>Column gap<input type='range' min={0} max={200} defaultValue={10} className='range-input' onChange={(evt)=>onStyleChange({ '.pages': { columnGap: `${evt.target.value}px` }})} /></label>
|
||||
<label title='Modify the vertical space between rows of pages.'>Row gap<input type='range' min={0} max={200} defaultValue={10} className='range-input' onChange={(evt)=>onStyleChange({ '.pages': { rowGap: `${evt.target.value}px` } })} /></label>
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
align-items : center;
|
||||
}
|
||||
|
||||
.active {
|
||||
background-color: #444;
|
||||
}
|
||||
|
||||
.anchored-box {
|
||||
color: #CCCCCC;
|
||||
input[type='number']{
|
||||
@@ -41,6 +45,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
.radio-group:has(button[role='radio']){
|
||||
display: flex;
|
||||
border: 1px solid #333;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
input {
|
||||
position : relative;
|
||||
height : 1.5em;
|
||||
@@ -90,7 +100,7 @@
|
||||
}
|
||||
|
||||
button {
|
||||
box-sizing : content-box;
|
||||
box-sizing : border-box;
|
||||
display : flex;
|
||||
align-items : center;
|
||||
justify-content : center;
|
||||
@@ -107,7 +117,7 @@
|
||||
}
|
||||
|
||||
&:hover { background-color : #444444; }
|
||||
&:focus { outline : 1px solid #D3D3D3; }
|
||||
&:focus { border : 1px solid #D3D3D3;outline: none;}
|
||||
&:disabled {
|
||||
color : #777777;
|
||||
background-color : unset !important;
|
||||
|
||||
10
client/icons/FacingView-alt.svg
Normal file
10
client/icons/FacingView-alt.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(0.979101,0,0,0.919064,-29.0748,1.98095)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.979101,0,0,0.919064,23.058,1.98095)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
10
client/icons/FacingView.svg
Normal file
10
client/icons/FacingView.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(0.599577,0,0,0.562812,1.57652,20.5943)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.599577,0,0,0.562812,33.5014,20.5943)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
24
client/icons/FlowView-alt.svg
Normal file
24
client/icons/FlowView-alt.svg
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(1.0781,0,0,1.0781,-3.90545,-3.90502)">
|
||||
<g transform="matrix(0.590052,0,0,0.553871,-13.8993,-2.19227)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.590052,0,0,0.553871,-13.8993,44.3152)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.590052,0,0,0.553871,17.5184,-2.19227)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.590052,0,0,0.553871,50.0095,-2.19227)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.590052,0,0,0.553871,17.5184,44.3152)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.590052,0,0,0.553871,50.0095,44.3152)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
24
client/icons/FlowView.svg
Normal file
24
client/icons/FlowView.svg
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(1.0781,0,0,1.0781,-3.90545,-3.90502)">
|
||||
<g transform="matrix(0.556142,0,0,0.522041,-10.2271,0.807124)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.556142,0,0,0.522041,-10.2271,44.6419)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.556142,0,0,0.522041,19.3851,0.807124)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.556142,0,0,0.522041,50.0089,0.807124)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.556142,0,0,0.522041,19.3851,44.6419)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
<g transform="matrix(0.556142,0,0,0.522041,50.0089,44.6419)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
7
client/icons/SingleView-alt.svg
Normal file
7
client/icons/SingleView-alt.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(1.41826,0,0,1.3313,-26.7845,-19.5573)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 777 B |
7
client/icons/SingleView.svg
Normal file
7
client/icons/SingleView.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(0.599577,0,0,0.562812,17.539,20.5943)">
|
||||
<path d="M78.584,16.13C78.584,15.335 78.164,14.69 77.647,14.69L30.632,14.69C30.115,14.69 29.695,15.335 29.695,16.13L29.695,88.365C29.695,89.16 30.115,89.805 30.632,89.805L77.647,89.805C78.164,89.805 78.584,89.16 78.584,88.365L78.584,16.13Z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 777 B |
@@ -73,3 +73,21 @@
|
||||
.fit-width {
|
||||
mask-image: url('../icons/fit-width.svg');
|
||||
}
|
||||
.single-view {
|
||||
mask-image: url('../icons/SingleView.svg');
|
||||
}
|
||||
.facing-view {
|
||||
mask-image: url('../icons/FacingView.svg');
|
||||
}
|
||||
.flow-view {
|
||||
mask-image: url('../icons/FlowView.svg');
|
||||
}
|
||||
.single-view-alt {
|
||||
mask-image: url('../icons/SingleView-alt.svg');
|
||||
}
|
||||
.facing-view-alt {
|
||||
mask-image: url('../icons/FacingView-alt.svg');
|
||||
}
|
||||
.flow-view-alt {
|
||||
mask-image: url('../icons/FlowView-alt.svg');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user