Skip to content

Commit c107cbf

Browse files
committed
Add affix to homePage
1 parent 18b61e1 commit c107cbf

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/meridian/generic/affix.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { ArrowUp } from 'tabler-icons-react';
3+
import { ActionIcon, Affix, Transition } from '@mantine/core';
4+
import { useWindowScroll } from '@mantine/hooks';
5+
6+
const AppAffix = () => {
7+
const [scroll, scrollTo] = useWindowScroll();
8+
return (
9+
<Affix position={{ bottom: 20, right: 20 }}>
10+
<Transition transition='slide-up' mounted={scroll.y > 0}>
11+
{transitionStyles => (
12+
<ActionIcon
13+
style={transitionStyles}
14+
onClick={() => scrollTo({ y: 0 })}
15+
variant='filled'
16+
color='blue'
17+
size='xl'
18+
radius='xl'
19+
>
20+
<ArrowUp />
21+
</ActionIcon>
22+
)}
23+
</Transition>
24+
</Affix>
25+
);
26+
};
27+
28+
export default AppAffix;

src/meridian/generic/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export {
88
SegmentedColorSchemeToggle,
99
} from './colorSchemeToggle';
1010
export { default as useWindowSize } from './useWindowSize';
11+
export { default as Affix } from './affix';
1112
export type { ContextMenuItem } from './contextMenu';

src/meridian/home/homePage.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import { ActionIcon, Box, createStyles, Pagination } from '@mantine/core';
1313
import { t } from '@lingui/macro';
1414
import { TorrentCard, useAddTorrentsModal } from 'meridian/torrent';
1515
import { TorrentInfo } from 'meridian/models';
16-
import { ContextMenu, ContextMenuItem, DrawerPage } from 'meridian/generic';
16+
import {
17+
Affix,
18+
ContextMenu,
19+
ContextMenuItem,
20+
DrawerPage,
21+
} from 'meridian/generic';
1722
import { selectSettings, useSettingsModal } from 'meridian/settings';
1823
import { usePreferencesModal } from 'meridian/preferences';
1924
import { useCategoriesModal } from 'meridian/categories';
@@ -114,6 +119,7 @@ const HomePage = () => {
114119
total={numberOfPages}
115120
/>
116121
) : null}
122+
<Affix />
117123
</DrawerPage>
118124
);
119125
};

0 commit comments

Comments
 (0)