From 9c865ac0354084b68c2a23fcd21b0713ac5b3712 Mon Sep 17 00:00:00 2001 From: dragoni7 Date: Sun, 15 Sep 2024 19:45:59 -0700 Subject: [PATCH 1/2] Improved grid layout for dashboard. Added dynamic resizing to number boxes. --- src/app/routes/Dashboard.tsx | 107 ++++++++---------- src/components/RefreshCharacters.tsx | 8 +- .../armor-optimization/NumberBoxes.tsx | 19 ++-- .../armor-optimization/StatsTable.tsx | 25 +++- 4 files changed, 87 insertions(+), 72 deletions(-) diff --git a/src/app/routes/Dashboard.tsx b/src/app/routes/Dashboard.tsx index e1ff5e1..fa7aa78 100644 --- a/src/app/routes/Dashboard.tsx +++ b/src/app/routes/Dashboard.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState, useMemo } from 'react'; -import { Box, Container, styled } from '@mui/system'; +import { Box, styled } from '@mui/system'; import { useDispatch, useSelector } from 'react-redux'; import { AppDispatch, RootState, store } from '../../store'; import { generatePermutations } from '../../features/armor-optimization/generate-permutations'; @@ -16,7 +16,6 @@ import { Character, CharacterClass, DecodedLoadoutData, - DestinyArmor, FilteredPermutation, FragmentStatModifications, StatName, @@ -44,53 +43,28 @@ import { decodeLoadout } from '../../features/loadouts/util/loadout-encoder'; import { resetDashboard, updateSelectedCharacter, - updateSelectedExoticClassCombo, updateSelectedExoticItemHash, } from '../../store/DashboardReducer'; import StatModifications from '../../features/subclass/StatModifications'; -import { Grid, Paper } from '@mui/material'; +import { Grid } from '@mui/material'; import { ManifestArmorStatMod, ManifestExoticArmor } from '../../types/manifest-types'; import { SharedLoadoutDto } from '../../features/loadouts/types'; import { updateProfileCharacters } from '../../store/ProfileReducer'; import { getProfileData } from '../../util/profile-characters'; import RefreshCharacters from '../../components/RefreshCharacters'; -const PageContainer = styled(Box)(({ theme }) => ({ - display: 'flex', - flexDirection: 'column', - height: '100vh', - overflow: 'hidden', -})); - -const ContentContainer = styled(Box)(({ theme }) => ({ - flex: 1, - width: '100vw', - overflowY: 'auto', +const DashboardContent = styled(Grid)(({ theme }) => ({ backgroundImage: `url(${greyBackground})`, backgroundSize: 'cover', backgroundPosition: 'center', - padding: theme.spacing(3), - paddingTop: '200px', })); -const HeaderWrapper = styled(Box)({ - position: 'fixed', - top: 0, - left: 0, - right: 0, - zIndex: 1100, -}); - const NumberBoxesContainer = styled(Box)(({ theme }) => ({ marginTop: theme.spacing(4), marginLeft: theme.spacing(25), backgroundColor: 'rgba(0, 0, 0, 0.1)', backdropFilter: 'blur(5px)', borderRadius: 0, - padding: theme.spacing(2), - alignSelf: 'flex-start', - width: 'auto', - maxWidth: '100%', })); export const Dashboard: React.FC = () => { @@ -430,7 +404,7 @@ export const Dashboard: React.FC = () => { }; return ( - + <> {showAbilitiesModification && customizingSubclass ? ( setShowAbilitiesModification(false)} @@ -448,43 +422,56 @@ export const Dashboard: React.FC = () => { /> ) : sharedLoadoutDto === undefined && selectedSubclass ? ( <> + - - - - - - - - - - + + + + + + + + + + + - - - + + - + - + {generatingPermutations ? (

Loading...

) : filteredPermutations ? ( @@ -496,13 +483,13 @@ export const Dashboard: React.FC = () => {

Loading....

)}
-
-
+ + ) : (
loading...
)} -
+ ); }; diff --git a/src/components/RefreshCharacters.tsx b/src/components/RefreshCharacters.tsx index e897c82..bc3ce35 100644 --- a/src/components/RefreshCharacters.tsx +++ b/src/components/RefreshCharacters.tsx @@ -16,7 +16,13 @@ export default function RefreshCharacters() { return ( {refreshing ? ( diff --git a/src/features/armor-optimization/NumberBoxes.tsx b/src/features/armor-optimization/NumberBoxes.tsx index 62dc5c6..4a9530f 100644 --- a/src/features/armor-optimization/NumberBoxes.tsx +++ b/src/features/armor-optimization/NumberBoxes.tsx @@ -22,25 +22,28 @@ interface NumberBoxProps { const NumberBox = styled(ButtonBase, { shouldForwardProp: (prop) => prop !== 'isSelected', -})(({ isSelected }) => ({ - width: 32, // Increased size - height: 32, // Increased size - lineHeight: '32px', +})(({ isSelected, theme }) => ({ + width: '30px', + height: '30px', + [theme.breakpoints.between('lg', 'xl')]: { + width: '50px', + height: '50px', + }, textAlign: 'center', border: `1px solid ${isSelected ? '#bdab6d' : 'rgba(255, 255, 255, 0.5)'}`, - margin: '0 2px', // Increased margin between boxes + margin: '0 2px', backgroundColor: isSelected ? 'rgba(189, 171, 109, 0.2)' : 'transparent', color: isSelected ? '#bdab6d' : 'white', cursor: 'pointer', - fontSize: 14, // Increased font size + fontSize: 16, '&:hover': { backgroundColor: 'rgba(255, 255, 255, 0.1)', }, })); const StatIcon = styled('img')({ - width: 24, - height: 24, + width: '50%', + height: '50%', marginRight: 12, }); diff --git a/src/features/armor-optimization/StatsTable.tsx b/src/features/armor-optimization/StatsTable.tsx index ae5f7be..23f3b8c 100644 --- a/src/features/armor-optimization/StatsTable.tsx +++ b/src/features/armor-optimization/StatsTable.tsx @@ -1,6 +1,15 @@ import React, { useMemo, useState, useEffect } from 'react'; import { styled } from '@mui/material/styles'; -import { Box, Card, Grid, Typography, IconButton, Tooltip } from '@mui/material'; +import { + Box, + Card, + Grid, + Typography, + IconButton, + Tooltip, + useMediaQuery, + useTheme, +} from '@mui/material'; import ChevronLeftIcon from '@mui/icons-material/ChevronLeft'; import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import { FilteredPermutation, DestinyArmor, StatName } from '../../types/d2l-types'; @@ -115,7 +124,9 @@ const TableFooter = styled(Typography)(({ theme }) => ({ const StatsTable: React.FC = ({ permutations, onPermutationClick }) => { const [currentPage, setCurrentPage] = useState(0); - const itemsPerPage = 4; + const theme = useTheme(); + const large = useMediaQuery(theme.breakpoints.between('lg', 'xl')); + const [itemsPerPage, setItemsPerPage] = useState(4); const subclassConfig = useSelector( (state: RootState) => state.loadoutConfig.loadout.subclassConfig @@ -143,11 +154,19 @@ const StatsTable: React.FC = ({ permutations, onPermutationClic return modifications; }, [subclassConfig.fragments]); + useEffect(() => { + if (large) { + setItemsPerPage(6); + } else { + setItemsPerPage(4); + } + }, [large]); + const paginatedData = useMemo(() => { const start = currentPage * itemsPerPage; const end = start + itemsPerPage; return permutations.slice(start, end); - }, [currentPage, permutations]); + }, [currentPage, permutations, itemsPerPage]); const calculateTotal = (perm: FilteredPermutation, stat: StatName) => { const baseSum = perm.permutation.reduce((sum, item) => sum + (item[stat] || 0), 0); From aca8b3bc34e28f2f4c88eb913b21fecaba416248 Mon Sep 17 00:00:00 2001 From: dragoni7 Date: Sun, 15 Sep 2024 20:03:14 -0700 Subject: [PATCH 2/2] Fixed loadout customization layout --- src/app/routes/Dashboard.tsx | 2 +- src/components/LoadoutCustomization.tsx | 9 +++------ src/features/armor-optimization/StatsTable.tsx | 2 +- src/features/loadouts/components/SaveLoadout.tsx | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/app/routes/Dashboard.tsx b/src/app/routes/Dashboard.tsx index fa7aa78..bbf2ec8 100644 --- a/src/app/routes/Dashboard.tsx +++ b/src/app/routes/Dashboard.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState, useMemo } from 'react'; import { Box, styled } from '@mui/system'; import { useDispatch, useSelector } from 'react-redux'; -import { AppDispatch, RootState, store } from '../../store'; +import { AppDispatch, RootState } from '../../store'; import { generatePermutations } from '../../features/armor-optimization/generate-permutations'; import { filterFromSharedLoadout, diff --git a/src/components/LoadoutCustomization.tsx b/src/components/LoadoutCustomization.tsx index 3445534..40daea6 100644 --- a/src/components/LoadoutCustomization.tsx +++ b/src/components/LoadoutCustomization.tsx @@ -7,7 +7,6 @@ import EquipLoadout from '../features/loadouts/components/EquipLoadout'; import AbilitiesModification from '../features/subclass/AbilitiesModification'; import ShareLoadout from '../features/loadouts/components/ShareLoadout'; import { SubclassConfig } from '../types/d2l-types'; -import SaveLoadout from '../features/loadouts/components/SaveLoadout'; import TotalStatsDisplay from '../features/subclass/TotalStatsDisplay'; interface LoadoutCustomizationProps { @@ -38,9 +37,7 @@ const LoadoutCustomization: React.FC = ({ = ({ }} /> - + = ({ > - + diff --git a/src/features/armor-optimization/StatsTable.tsx b/src/features/armor-optimization/StatsTable.tsx index 23f3b8c..e22dbd1 100644 --- a/src/features/armor-optimization/StatsTable.tsx +++ b/src/features/armor-optimization/StatsTable.tsx @@ -156,7 +156,7 @@ const StatsTable: React.FC = ({ permutations, onPermutationClic useEffect(() => { if (large) { - setItemsPerPage(6); + setItemsPerPage(5); } else { setItemsPerPage(4); } diff --git a/src/features/loadouts/components/SaveLoadout.tsx b/src/features/loadouts/components/SaveLoadout.tsx index d87647f..ced5ac1 100644 --- a/src/features/loadouts/components/SaveLoadout.tsx +++ b/src/features/loadouts/components/SaveLoadout.tsx @@ -191,7 +191,7 @@ export default function SaveLoadout() { <> - + {identifiersSet ? SelectLoadoutSlotDrawer : SetIdentifiersDrawer}