💄 DnsHole controls cosmetic changes for smaller footprint

This commit is contained in:
Tagaishi
2023-07-13 22:43:14 +02:00
parent 8c3190ce46
commit 24e645b029

View File

@@ -1,4 +1,5 @@
import { Badge, Box, Button, Card, Group, Image, Stack, Text } from '@mantine/core';
import { Badge, Box, Button, Card, Group, Image, Stack, Text, SimpleGrid, Space } from '@mantine/core';
import { useElementSize } from '@mantine/hooks';
import { useTranslation } from 'next-i18next';
import { IconDeviceGamepad, IconPlayerPlay, IconPlayerStop } from '@tabler/icons-react';
import { useConfigContext } from '../../config/provider';
@@ -15,8 +16,8 @@ const definition = defineWidget({
icon: IconDeviceGamepad,
options: {},
gridstack: {
minWidth: 3,
minHeight: 2,
minWidth: 2,
minHeight: 1,
maxWidth: 12,
maxHeight: 12,
},
@@ -32,6 +33,7 @@ interface DnsHoleControlsWidgetProps {
function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) {
const { isInitialLoading, data } = useDnsHoleSummeryQuery();
const { mutateAsync } = useDnsHoleControlMutation();
const { width, ref } = useElementSize();
const { t } = useTranslation('common');
const { name: configName, config } = useConfigContext();
@@ -41,8 +43,8 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) {
}
return (
<Stack>
<Group grow>
<Stack justify="space-between" h={"100%"} style={{ gap:"0.25rem", }}>
<SimpleGrid ref={ref} cols={ (width > 275)? 2 : 1 } verticalSpacing="0.25rem" spacing="0.25rem">
<Button
onClick={async () => {
await mutateAsync({
@@ -54,6 +56,9 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) {
leftIcon={<IconPlayerPlay size={20} />}
variant="light"
color="green"
style={{
height:"2rem",
}}
>
{t('enableAll')}
</Button>
@@ -68,11 +73,15 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) {
leftIcon={<IconPlayerStop size={20} />}
variant="light"
color="red"
style={{
height:"2rem",
}}
>
{t('disableAll')}
</Button>
</Group>
</SimpleGrid>
<Stack style={{ gap:"0.25rem", }}>
{data.status.map((status, index) => {
const app = config?.apps.find((x) => x.id === status.appId);
@@ -81,8 +90,7 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) {
}
return (
<Card withBorder key={index} p="xs">
<Group position="apart">
<Card withBorder={true} key={index} p="xs">
<Group>
<Box
sx={(theme) => ({
@@ -93,17 +101,18 @@ function DnsHoleControlsWidgetTile({ widget }: DnsHoleControlsWidgetProps) {
borderRadius: theme.radius.md,
})}
>
<Image src={app.appearance.iconUrl} width={25} height={25} fit="contain" />
<Image src={app.appearance.iconUrl} width={40} height={40} fit="contain" />
</Box>
<Stack style={{ gap: "0rem", }}>
<Text>{app.name}</Text>
</Group>
<StatusBadge status={status.status} />
</Stack>
</Group>
</Card>
);
})}
</Stack>
</Stack>
);
}