0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 23:02:45 +00:00

Merge pull request #4080 from naturalcrit/fix-vault-pagination

Vault fixes
This commit is contained in:
Trevor Buckner
2025-03-10 19:38:06 -04:00
committed by GitHub
4 changed files with 41 additions and 30 deletions

View File

@@ -114,6 +114,9 @@ Fixes issue [#1729](https://github.com/naturalcrit/homebrewery/issues/1729)
##### 5e-Cleric ##### 5e-Cleric
* [x] Style fixes for covers art and logos on A4 size pages * [x] Style fixes for covers art and logos on A4 size pages
* [x] Fix crash when trying to open brews that don't exist * [x] Fix crash when trying to open brews that don't exist
* [x] Tweaks and style update styling on {{openSans **VAULT** :fas_dungeon:}} page.
Fixes issue [#4079](https://github.com/naturalcrit/homebrewery/issues/4079)
##### Calculuschild ##### Calculuschild
* [x] `` now produces `<br>` instead of a `<div>` * [x] `` now produces `<br>` instead of a `<div>`

View File

@@ -99,14 +99,14 @@ const VaultPage = (props)=>{
setSearching(true); setSearching(true);
setError(null); setError(null);
const title = titleRef.current.value || ''; const title = titleRef.current.value || '';
const author = authorRef.current.value || ''; const author = authorRef.current.value || '';
const count = countRef.current.value || 10; const count = countRef.current.value || 10;
const v3 = v3Ref.current.checked != false; const v3 = v3Ref.current.checked != false;
const legacy = legacyRef.current.checked != false; const legacy = legacyRef.current.checked != false;
const sortOption = sort || 'title'; const sortOption = sort || 'title';
const dirOption = dir || 'asc'; const dirOption = dir || 'asc';
const pageProp = page || 1; const pageProp = page || 1;
setSort(sortOption); setSort(sortOption);
setdir(dirOption); setdir(dirOption);
@@ -247,7 +247,7 @@ const VaultPage = (props)=>{
</li> </li>
<li> <li>
Some common words like "a", "after", "through", "itself", "here", etc., Some common words like "a", "after", "through", "itself", "here", etc.,
are ignored in searches. The full list can be found &nbsp; are ignored in searches. The full list can be found&nbsp;
<a href='https://github.com/mongodb/mongo/blob/0e3b3ca8480ddddf5d0105d11a94bd4698335312/src/mongo/db/fts/stop_words_english.txt'> <a href='https://github.com/mongodb/mongo/blob/0e3b3ca8480ddddf5d0105d11a94bd4698335312/src/mongo/db/fts/stop_words_english.txt'>
here here
</a> </a>
@@ -286,9 +286,9 @@ const VaultPage = (props)=>{
}; };
const renderPaginationControls = ()=>{ const renderPaginationControls = ()=>{
if(!totalBrews) return null; if(!totalBrews || totalBrews < 10) return null;
const countInt = parseInt(props.query.count || 20); const countInt = parseInt(brewCollection.length || 20);
const totalPages = Math.ceil(totalBrews / countInt); const totalPages = Math.ceil(totalBrews / countInt);
let startPage, endPage; let startPage, endPage;
@@ -355,7 +355,7 @@ const VaultPage = (props)=>{
}; };
const renderFoundBrews = ()=>{ const renderFoundBrews = ()=>{
if(searching) { if(searching && !brewCollection) {
return ( return (
<div className='foundBrews searching'> <div className='foundBrews searching'>
<h3 className='searchAnim'>Searching</h3> <h3 className='searchAnim'>Searching</h3>
@@ -395,6 +395,7 @@ const VaultPage = (props)=>{
{`Brews found: `} {`Brews found: `}
<span>{totalBrews}</span> <span>{totalBrews}</span>
</span> </span>
{brewCollection.length > 10 && renderPaginationControls()}
{brewCollection.map((brew, index)=>{ {brewCollection.map((brew, index)=>{
return ( return (
<BrewItem <BrewItem
@@ -415,14 +416,14 @@ const VaultPage = (props)=>{
<link href='/themes/V3/Blank/style.css' rel='stylesheet' /> <link href='/themes/V3/Blank/style.css' rel='stylesheet' />
<link href='/themes/V3/5ePHB/style.css' rel='stylesheet' /> <link href='/themes/V3/5ePHB/style.css' rel='stylesheet' />
{renderNavItems()} {renderNavItems()}
<div className="content"> <div className='content'>
<SplitPane showDividerButtons={false}> <SplitPane showDividerButtons={false}>
<div className='form dataGroup'>{renderForm()}</div> <div className='form dataGroup'>{renderForm()}</div>
<div className='resultsContainer dataGroup'> <div className='resultsContainer dataGroup'>
{renderSortBar()} {renderSortBar()}
{renderFoundBrews()} {renderFoundBrews()}
</div> </div>
</SplitPane> </SplitPane>
</div> </div>
</div> </div>
); );

View File

@@ -5,7 +5,7 @@
*:not(input) { user-select : none; } *:not(input) { user-select : none; }
.content .dataGroup { :where(.content .dataGroup) {
width : 100%; width : 100%;
height : 100%; height : 100%;
background : white; background : white;
@@ -169,9 +169,10 @@
width : 100%; width : 100%;
height : 100%; height : 100%;
max-height : 100%; max-height : 100%;
padding : 50px 50px 70px 50px; padding : 70px 50px;
overflow-y : scroll; overflow-y : scroll;
background-color : #2C3E50; background-color : #2C3E50;
container-type : inline-size;
h3 { font-size : 25px; } h3 { font-size : 25px; }
@@ -236,6 +237,7 @@
margin-right : 40px; margin-right : 40px;
color : black; color : black;
isolation : isolate; isolation : isolate;
transition : width 0.5s;
&::after { &::after {
position : absolute; position : absolute;
@@ -269,8 +271,8 @@
.links { z-index : 2; } .links { z-index : 2; }
hr { hr {
margin : 0px;
visibility : hidden; visibility : hidden;
margin : 0px;
} }
.thumbnail { z-index : -1; } .thumbnail { z-index : -1; }
@@ -278,30 +280,37 @@
.paginationControls { .paginationControls {
position : absolute; position : absolute;
top : 35px;
left : 50%; left : 50%;
display : grid; display : grid;
grid-template-areas : 'previousPage currentPage nextPage'; grid-template-areas : 'previousPage currentPage nextPage';
grid-template-columns : 50px 1fr 50px; grid-template-columns : 50px 1fr 50px;
gap : 20px;
place-items : center; place-items : center;
width : auto; width : auto;
font-size : 15px;
translate : -50%; translate : -50%;
&:last-child { top : unset; }
.pages { .pages {
display : flex; display : flex;
grid-area : currentPage; grid-area : currentPage;
gap : 1em;
justify-content : space-evenly; justify-content : space-evenly;
width : 100%; width : 100%;
height : 100%; height : 100%;
padding : 5px 8px;
text-align : center; text-align : center;
.pageNumber { .pageNumber {
margin-inline : 1vw; place-content : center;
width : fit-content;
min-width : 2em;
font-family : 'Open Sans'; font-family : 'Open Sans';
font-weight : 900; font-weight : 900;
color : white; color : white;
text-underline-position : under;
text-wrap : nowrap; text-wrap : nowrap;
text-underline-position : under;
cursor : pointer; cursor : pointer;
&.currentPage { &.currentPage {
@@ -329,7 +338,6 @@
} }
} }
} }
} }
@keyframes trailingDots { @keyframes trailingDots {
@@ -344,8 +352,7 @@
100% { content : ' ...'; } 100% { content : ' ...'; }
} }
// media query for when the page is smaller than 1079 px in width @container (width < 670px) {
@media screen and (max-width : 1079px) {
.vaultPage { .vaultPage {
.dataGroup.form .brewLookup { padding : 1px 20px 20px 10px; } .dataGroup.form .brewLookup { padding : 1px 20px 20px 10px; }

View File

@@ -1,6 +1,6 @@
import express from 'express'; import express from 'express';
import asyncHandler from 'express-async-handler'; import asyncHandler from 'express-async-handler';
import {model as HomebrewModel } from './homebrew.model.js'; import { model as HomebrewModel } from './homebrew.model.js';
const router = express.Router(); const router = express.Router();
@@ -29,7 +29,7 @@ const rendererConditions = (legacy, v3)=>{
return {}; // If all renderers selected, renderer field not needed in query for speed return {}; // If all renderers selected, renderer field not needed in query for speed
}; };
const sortConditions = (sort, dir) => { const sortConditions = (sort, dir)=>{
return { [sort]: dir === 'asc' ? 1 : -1 }; return { [sort]: dir === 'asc' ? 1 : -1 };
}; };