Skip to content

Commit

Permalink
Feat: Make survival progress show reverse order
Browse files Browse the repository at this point in the history
  • Loading branch information
whats2000 committed May 26, 2024
1 parent 2ac4be8 commit 692af16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ const HomePage = () => {

const createSections = (key: string, route: string) => {
const data = t(key, { returnObjects: true }) as IImageContent[];

if (route === 'survivalProgress') {
const sliceIndex = Math.max(data.length - 3, 0);
return data
.slice(sliceIndex)
.reverse()
.map((item, index) => ({
...item,
clickEvent: () => navigate(`/${route}?index=${index}`),
}));
}

const sliceIndex = Math.max(data.length - 3, 0);
return data.slice(sliceIndex).map((item, index) => ({
...item,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/SurvivalProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const SurvivalProgress = () => {
subHeaderContentArray={[t('survivalProgress.description')]}
/>
<Timeline
items={
items={(
t('survivalProgress.data', { returnObjects: true }) as IImageContent[]
}
).reverse()}
activeIndex={shareIndex}
/>
</>
Expand Down

0 comments on commit 692af16

Please sign in to comment.