mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-30 21:52:43 +00:00
restructure html, eliminate .tool divs
Treat each input and button as a direct child of the `.group` class, removing the intermediate div and reassign the `tool` classname to those inputs and buttons. One item, the current / total page "set", is wrapped in a .tool div because they should be considered one item (even within the .group container). And then a bunch of CSS adjustments to match the new structure.
This commit is contained in:
@@ -44,77 +44,77 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
|
||||
return (
|
||||
<div className='toolBar'>
|
||||
<div className='group'>
|
||||
<div className='tool'>
|
||||
<button
|
||||
onClick={()=>handleZoomChange(-20)}
|
||||
disabled={zoomLevel <= MIN_ZOOM}
|
||||
>
|
||||
<i className='fas fa-magnifying-glass-minus' />
|
||||
</button>
|
||||
</div>
|
||||
<div className='tool'>
|
||||
<input
|
||||
className='slider'
|
||||
type='range'
|
||||
name='zoom'
|
||||
list='zoomLevels'
|
||||
min={MIN_ZOOM}
|
||||
max={MAX_ZOOM}
|
||||
step='1'
|
||||
value={zoomLevel}
|
||||
onChange={(e)=>{setZoomLevel(parseInt(e.target.value));}}
|
||||
/>
|
||||
<datalist id='zoomLevels'>
|
||||
<option value='100' />
|
||||
</datalist>
|
||||
</div>
|
||||
<button
|
||||
id='zoom-out'
|
||||
className='tool'
|
||||
onClick={()=>handleZoomChange(-20)}
|
||||
disabled={zoomLevel <= MIN_ZOOM}
|
||||
>
|
||||
<i className='fas fa-magnifying-glass-minus' />
|
||||
</button>
|
||||
<input
|
||||
id='zoom-slider'
|
||||
className='range-input tool'
|
||||
type='range'
|
||||
name='zoom'
|
||||
list='zoomLevels'
|
||||
min={MIN_ZOOM}
|
||||
max={MAX_ZOOM}
|
||||
step='1'
|
||||
value={zoomLevel}
|
||||
onChange={(e)=>{setZoomLevel(parseInt(e.target.value));}}
|
||||
/>
|
||||
<datalist id='zoomLevels'>
|
||||
<option value='100' />
|
||||
</datalist>
|
||||
|
||||
<div className='tool'>
|
||||
<button
|
||||
onClick={()=>handleZoomChange(20)}
|
||||
disabled={zoomLevel >= MAX_ZOOM}
|
||||
>
|
||||
<i className='fas fa-magnifying-glass-plus' />
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
id='zoom-in'
|
||||
className='tool'
|
||||
onClick={()=>handleZoomChange(20)}
|
||||
disabled={zoomLevel >= MAX_ZOOM}
|
||||
>
|
||||
<i className='fas fa-magnifying-glass-plus' />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className='group'>
|
||||
<div className='tool'>
|
||||
<button
|
||||
className='previousPage'
|
||||
onClick={()=>scrollToPage(pageInput - 1)}
|
||||
disabled={pageInput <= 1}
|
||||
>
|
||||
<i className='fas fa-arrow-left'></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<input
|
||||
type='text'
|
||||
name='page'
|
||||
inputMode='numeric'
|
||||
pattern='[0-9]'
|
||||
id='pageInput'
|
||||
value={pageInput}
|
||||
onChange={(e)=>{
|
||||
handlePageChange(e.target.value == false ? e.target.value : parseInt(e.target.value));}}
|
||||
onBlur={()=>scrollToPage(pageInput)}
|
||||
onKeyDown={(e)=>{e.key == 'Enter' ? scrollToPage(pageInput) : null;}}
|
||||
/>
|
||||
|
||||
<span id='page-count'>/ {totalPages}</span>
|
||||
<button
|
||||
id='previous-page'
|
||||
className='previousPage tool'
|
||||
onClick={()=>scrollToPage(pageInput - 1)}
|
||||
disabled={pageInput <= 1}
|
||||
>
|
||||
<i className='fas fa-arrow-left'></i>
|
||||
</button>
|
||||
|
||||
<div className='tool'>
|
||||
<button
|
||||
className='nextPage'
|
||||
// onClick={()=>{setPageInput((pageInput)=>parseInt(pageInput) + 1)}}
|
||||
onClick={()=>scrollToPage(pageInput + 1)}
|
||||
disabled={pageInput >= totalPages}
|
||||
>
|
||||
<i className='fas fa-arrow-right'></i>
|
||||
</button>
|
||||
<input
|
||||
id='page-input'
|
||||
class='text-input'
|
||||
type='text'
|
||||
name='page'
|
||||
inputMode='numeric'
|
||||
pattern='[0-9]'
|
||||
value={pageInput}
|
||||
onChange={(e)=>{
|
||||
handlePageChange(e.target.value == false ? e.target.value : parseInt(e.target.value));}}
|
||||
onBlur={()=>scrollToPage(pageInput)}
|
||||
onKeyDown={(e)=>{e.key == 'Enter' ? scrollToPage(pageInput) : null;}}
|
||||
/>
|
||||
|
||||
<span id='page-count'>/ {totalPages}</span>
|
||||
</div>
|
||||
|
||||
|
||||
<button
|
||||
id='next-page'
|
||||
className='tool'
|
||||
onClick={()=>scrollToPage(pageInput + 1)}
|
||||
disabled={pageInput >= totalPages}
|
||||
>
|
||||
<i className='fas fa-arrow-right'></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -16,12 +16,18 @@
|
||||
|
||||
.group {
|
||||
display : flex;
|
||||
gap: 0 3px;
|
||||
align-items : center;
|
||||
justify-content : center;
|
||||
box-sizing : border-box;
|
||||
height: 28px;
|
||||
|
||||
}
|
||||
|
||||
.tool {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
input {
|
||||
position : relative;
|
||||
height : 1.5em;
|
||||
@@ -32,7 +38,8 @@
|
||||
border : 1px solid gray;
|
||||
&:focus { outline : 1px solid #d3d3d3; }
|
||||
|
||||
&.slider {
|
||||
// `.range-input` if generic to all range inputs, or `#zoom-input` if only for zoom slider
|
||||
&.range-input {
|
||||
color: #D3D3D3;
|
||||
accent-color: #d3d3d3;
|
||||
padding: 2px 0;
|
||||
@@ -61,40 +68,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
&#pageInput {
|
||||
// `.text-input` if generic to all range inputs, or `#page-input` if only for current page input
|
||||
&#page-input {
|
||||
width: 4ch;
|
||||
text-align: center;
|
||||
margin-right: 1ch;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.tool {
|
||||
|
||||
button {
|
||||
display : flex;
|
||||
align-items : center;
|
||||
padding : 0;
|
||||
height: 100%;
|
||||
width: auto;
|
||||
justify-content: center;
|
||||
height : 100%;
|
||||
width : auto;
|
||||
min-width : 46px;
|
||||
padding : 0 0px;
|
||||
font-weight : unset;
|
||||
color : inherit;
|
||||
background-color : unset;
|
||||
box-sizing: content-box;
|
||||
|
||||
&:hover { background-color : #444444; }
|
||||
|
||||
button {
|
||||
height : 100%;
|
||||
width : auto;
|
||||
min-width : 46px;
|
||||
padding : 0 0px;
|
||||
font-weight : unset;
|
||||
color : inherit;
|
||||
background-color : unset;
|
||||
&:focus { outline : 1px solid #d3d3d3; }
|
||||
|
||||
&:focus { outline : 1px solid #d3d3d3; }
|
||||
|
||||
&:disabled {
|
||||
color : #777777;
|
||||
background-color : unset !important;
|
||||
}
|
||||
&:disabled {
|
||||
color : #777777;
|
||||
background-color : unset !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user