🐛 wrong absolute position of torrent options menu

This commit is contained in:
Manuel Ruwe
2022-10-15 23:45:46 +02:00
committed by Manuel
parent 096dd4c156
commit f951bcd750
5 changed files with 34 additions and 11 deletions

View File

@@ -1,7 +1,9 @@
{ {
"accordions": { "accordions": {
"downloads": { "downloads": {
"text": "Your downloads" "text": "Your downloads",
"torrents": "Your Torrent downloads",
"usenet": "Your Usenet downloads"
}, },
"others": { "others": {
"text": "Others" "text": "Others"

View File

@@ -5,6 +5,7 @@ import {
Grid, Grid,
Paper, Paper,
Stack, Stack,
Text,
Title, Title,
useMantineColorScheme, useMantineColorScheme,
} from '@mantine/core'; } from '@mantine/core';
@@ -200,17 +201,18 @@ const AppShelf = (props: any) => {
> >
<Accordion.Control>{t('accordions.downloads.text')}</Accordion.Control> <Accordion.Control>{t('accordions.downloads.text')}</Accordion.Control>
<Accordion.Panel> <Accordion.Panel>
<Paper radius="lg"> <Paper radius="lg" style={{ position: 'relative' }}>
{torrentEnabled && ( {torrentEnabled && (
<> <>
<ModuleMenu module={TorrentsModule} /> <Text>{t('accordions.downloads.torrents')}</Text>
<ModuleMenu module={TorrentsModule} hovered />
<TorrentsComponent /> <TorrentsComponent />
</> </>
)} )}
{usenetEnabled && ( {usenetEnabled && (
<> <>
{torrentEnabled && <Divider my="sm" />} <Text mt="md">{t('accordions.downloads.usenet')}</Text>
<ModuleMenu module={UsenetModule} /> <ModuleMenu module={UsenetModule} hovered />
<UsenetComponent /> <UsenetComponent />
</> </>
)} )}

View File

@@ -11,6 +11,15 @@ export interface IModule {
icon: TablerIcon; icon: TablerIcon;
component: React.ComponentType; component: React.ComponentType;
options?: Option; options?: Option;
padding?: PaddingOptions = {
right: 15,
top: 15,
},
}
interface PaddingOptions {
top: number;
right: number;
} }
interface Option { interface Option {

View File

@@ -186,8 +186,13 @@ export function ModuleWrapper(props: any) {
); );
} }
export function ModuleMenu(props: any) { interface ModuleMenuProps {
const { module, styles, hovered } = props; hovered: boolean;
module: IModule;
}
export function ModuleMenu(props: ModuleMenuProps) {
const { module, hovered } = props;
const items: JSX.Element[] = getItems(module); const items: JSX.Element[] = getItems(module);
const { t } = useTranslation('modules/common'); const { t } = useTranslation('modules/common');
return ( return (
@@ -207,12 +212,13 @@ export function ModuleMenu(props: any) {
<motion.div <motion.div
style={{ style={{
position: 'absolute', position: 'absolute',
top: 15, top: module.padding?.top ?? 15,
right: 15, right: module.padding?.right ?? 15,
alignSelf: 'flex-end', alignSelf: 'flex-end',
zIndex: 10,
}} }}
animate={{ animate={{
opacity: hovered === true ? 1 : 0, opacity: hovered ? 1 : 0,
}} }}
> >
<ActionIcon> <ActionIcon>

View File

@@ -34,6 +34,10 @@ export const TorrentsModule: IModule = {
value: false, value: false,
}, },
}, },
padding: {
right: 0,
top: -10,
},
}; };
export default function TorrentsComponent() { export default function TorrentsComponent() {