💄 Small UI qol update

Module download now has a different look and can be toggled on and off
This commit is contained in:
ajnart
2022-06-08 18:41:22 +02:00
parent f75da289c2
commit d631865f71
5 changed files with 36 additions and 21 deletions

View File

@@ -15,8 +15,9 @@ import { useLocalStorage } from '@mantine/hooks';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { SortableAppShelfItem, AppShelfItem } from './AppShelfItem'; import { SortableAppShelfItem, AppShelfItem } from './AppShelfItem';
import { ModuleWrapper } from '../modules/moduleWrapper'; import { ModuleMenu, ModuleWrapper } from '../modules/moduleWrapper';
import { DownloadsModule } from '../modules'; import { DownloadsModule } from '../modules';
import DownloadComponent from '../modules/downloads/DownloadsModule';
const useStyles = createStyles((theme, _params) => ({ const useStyles = createStyles((theme, _params) => ({
item: { item: {
@@ -137,6 +138,7 @@ const AppShelf = (props: any) => {
// Return one item for each category // Return one item for each category
<Group grow direction="column"> <Group grow direction="column">
<Accordion <Accordion
disableIconRotation
classNames={classes} classNames={classes}
order={2} order={2}
iconPosition="right" iconPosition="right"
@@ -160,8 +162,11 @@ const AppShelf = (props: any) => {
{item()} {item()}
</Accordion.Item> </Accordion.Item>
) : null} ) : null}
<Accordion.Item key="Downloads" label="Your downloads">
<ModuleMenu module={DownloadsModule} />
<DownloadComponent />
</Accordion.Item>
</Accordion> </Accordion>
<ModuleWrapper mt="xl" module={DownloadsModule} />
</Group> </Group>
); );
} }

View File

@@ -26,7 +26,10 @@ export default function ConfigChanger() {
label="Config loader" label="Config loader"
onChange={(e) => { onChange={(e) => {
loadConfig(e ?? 'default'); loadConfig(e ?? 'default');
setCookies('config-name', e ?? 'default', { maxAge: 60 * 60 * 24 * 30, sameSite: 'strict' }); setCookies('config-name', e ?? 'default', {
maxAge: 60 * 60 * 24 * 30,
sameSite: 'strict',
});
}} }}
data={ data={
// If config list is empty, return the current config // If config list is empty, return the current config

View File

@@ -1,11 +1,4 @@
import { import { ActionIcon, Group, Text, SegmentedControl, TextInput, Anchor } from '@mantine/core';
ActionIcon,
Group,
Text,
SegmentedControl,
TextInput,
Anchor,
} from '@mantine/core';
import { useState } from 'react'; import { useState } from 'react';
import { IconBrandGithub as BrandGithub } from '@tabler/icons'; import { IconBrandGithub as BrandGithub } from '@tabler/icons';
import { CURRENT_VERSION } from '../../../data/constants'; import { CURRENT_VERSION } from '../../../data/constants';

View File

@@ -136,8 +136,7 @@ export default function DownloadComponent() {
</Center> </Center>
); );
return ( return (
<Group noWrap grow direction="column"> <Group noWrap grow direction="column" mt="xl">
<Title order={4}>Your torrents</Title>
<ScrollArea sx={{ height: 300 }}> <ScrollArea sx={{ height: 300 }}>
{rows.length > 0 ? ( {rows.length > 0 ? (
<Table highlightOnHover> <Table highlightOnHover>

View File

@@ -1,4 +1,4 @@
import { Button, Card, Group, Menu, Switch, TextInput, useMantineTheme } from '@mantine/core'; import { Button, Card, Group, Menu, Switch, TextInput } from '@mantine/core';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { IModule } from './modules'; import { IModule } from './modules';
@@ -95,14 +95,32 @@ export function ModuleWrapper(props: any) {
const enabledModules = config.modules ?? {}; const enabledModules = config.modules ?? {};
// Remove 'Module' from enabled modules titles // Remove 'Module' from enabled modules titles
const isShown = enabledModules[module.title]?.enabled ?? false; const isShown = enabledModules[module.title]?.enabled ?? false;
const theme = useMantineTheme();
const items: JSX.Element[] = getItems(module);
if (!isShown) { if (!isShown) {
return null; return null;
} }
return ( return (
<Card {...props} hidden={!isShown} withBorder radius="lg" shadow="sm"> <Card {...props} hidden={!isShown} withBorder radius="lg" shadow="sm">
<ModuleMenu
module={module}
styles={{
root: {
position: 'absolute',
top: 15,
right: 15,
},
}}
/>
<module.component />
</Card>
);
}
export function ModuleMenu(props: any) {
const { module, styles } = props;
const items: JSX.Element[] = getItems(module);
return (
<>
{module.options && ( {module.options && (
<Menu <Menu
size="lg" size="lg"
@@ -112,9 +130,7 @@ export function ModuleWrapper(props: any) {
position="left" position="left"
styles={{ styles={{
root: { root: {
position: 'absolute', ...props?.styles?.root,
top: 15,
right: 15,
}, },
body: { body: {
// Add shadow and elevation to the body // Add shadow and elevation to the body
@@ -128,7 +144,6 @@ export function ModuleWrapper(props: any) {
))} ))}
</Menu> </Menu>
)} )}
<module.component /> </>
</Card>
); );
} }