diff --git a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less index aa7625301..4b3751ca3 100644 --- a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less +++ b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.less @@ -335,7 +335,7 @@ } //these media queries are just for the list layout and could be moved inside it, not sure it is a good idea -@media screen and (max-width : 1400px) { +@container (max-width : 1400px) { .brewCollection .brewGroup.list { .brewItem:not(.detailsOpen) { .info { @@ -361,7 +361,7 @@ } } } -@media screen and (max-width : 1200px) { +@container (max-width : 1200px) { .brewCollection .brewGroup.list { .brewItem:not(.detailsOpen) { grid-template-columns : 35% 3fr 150px; @@ -388,7 +388,7 @@ } } } -@media screen and (max-width : 800px) { +@container (max-width : 800px) { .brewCollection .brewGroup.list { .brewItem:not(.detailsOpen) { .info { @@ -443,7 +443,7 @@ } } } -@media screen and (max-width : 650px) { +@container (max-width : 650px) { .brewCollection .brewGroup.list { .brewItem:not(.detailsOpen) { grid-template-columns : 3fr 2fr; diff --git a/client/homebrew/pages/basePages/listPage/listPage.less b/client/homebrew/pages/basePages/listPage/listPage.less index 389c83abf..7a9286914 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.less +++ b/client/homebrew/pages/basePages/listPage/listPage.less @@ -21,15 +21,16 @@ .sitePage.listPage { --bg-clr : white; + container-type: inline-size; .content { - padding : clamp(20px, 5vh, 200px) clamp(20px, 20vw, 200px); + padding : clamp(20px, 5vh, 200px) clamp(20px, 20cqi, 200px); overflow-y : scroll; scrollbar-gutter : stable; - @media screen and (max-width : 1200px) { - padding : clamp(20px, 5vh, 200px) clamp(20px, 10vw, 200px); + @container (max-width : 1200px) { + padding : clamp(20px, 5vh, 200px) clamp(20px, 10cqi, 200px); } - @media screen and (max-width : 800px) { - padding : clamp(20px, 5vh, 200px) clamp(20px, 5vw, 200px); + @container (max-width : 800px) { + padding : clamp(20px, 5vh, 200px) clamp(20px, 5cqi, 200px); } &::-webkit-scrollbar { @@ -53,6 +54,7 @@ color : white; } .brewCollection { + h1 { width : fit-content; margin-bottom : 20px; @@ -97,9 +99,9 @@ gap : 20px; justify-items : center; - @media screen and (max-width : 1700px) {--columns : 3;} - @media screen and (max-width : 1400px) {--columns : 2;} - @media screen and (max-width : 900px) {--columns : 1;} + @container (max-width : 1700px) {--columns : 3;} + @container (max-width : 1400px) {--columns : 2;} + @container (max-width : 900px) {--columns : 1;} h1 { position : absolute; } &:not(:has(.brewItem:last-child:nth-child(3n))) { diff --git a/client/homebrew/pages/vaultPage/vaultPage.jsx b/client/homebrew/pages/vaultPage/vaultPage.jsx index c76505c7b..b64517083 100644 --- a/client/homebrew/pages/vaultPage/vaultPage.jsx +++ b/client/homebrew/pages/vaultPage/vaultPage.jsx @@ -16,6 +16,13 @@ import ErrorIndex from '../errorPage/errors/errorIndex.js'; import request from '../../utils/request-middleware.js'; +const DEFAULT_SORT_TYPE = 'alpha'; +const DEFAULT_SORT_DIR = 'asc'; +const DEFAULT_LAYOUT_MODE = 'grid'; +const DEFAULT_THEME_MODE = 'light'; +const USERPAGE_LAYOUT_MODE = 'HB_listPage_layout_mode'; +const USERPAGE_THEME_MODE = 'HB_listPage_theme_mode'; + const VaultPage = (props)=>{ const [pageState, setPageState] = useState(parseInt(props.query.page) || 1); @@ -27,6 +34,8 @@ const VaultPage = (props)=>{ const [totalBrews, setTotalBrews] = useState(null); const [searching, setSearching] = useState(false); const [error, setError] = useState(null); + const [layoutMode, setLayoutMode] = useState(DEFAULT_LAYOUT_MODE); + const [themeMode, setThemeMode] = useState(DEFAULT_THEME_MODE); const titleRef = useRef(null); const authorRef = useRef(null); @@ -37,6 +46,13 @@ const VaultPage = (props)=>{ useEffect(()=>{ disableSubmitIfFormInvalid(); + + const newLayoutMode = localStorage.getItem(USERPAGE_LAYOUT_MODE) || DEFAULT_LAYOUT_MODE; + const newThemeMode = localStorage.getItem(USERPAGE_THEME_MODE) || DEFAULT_THEME_MODE; + + setLayoutMode(newLayoutMode); + setThemeMode(newThemeMode); + loadPage(pageState, true, props.query.sort, props.query.dir); }, []); @@ -83,7 +99,8 @@ const VaultPage = (props)=>{ const response = await request.get(`/api/vault/total?title=${title}&author=${author}&v3=${v3}&legacy=${legacy}`) .catch((error)=>{ - console.log('error at loadTotal: ', error); + console.log('error at loadTotal: '); + console.error(error); setError(error); updateStateWithBrews([], 1); }); @@ -261,7 +278,7 @@ const VaultPage = (props)=>{ const oppositeDir = dirState === 'asc' ? 'desc' : 'asc'; return ( -