Rework appshell and include calendar to the main page

This commit is contained in:
Thomas "ajnart" Camlong
2022-05-02 18:10:56 +02:00
parent 8c1dce68b7
commit 71d18a5aa6
6 changed files with 142 additions and 124 deletions

View File

@@ -103,8 +103,13 @@ export default function AddItemShelfItem(props: any) {
</Group> </Group>
</form> </form>
</Modal> </Modal>
<Grid.Col span={4} lg={2} sm={3}> <AspectRatio
<AspectRatio ratio={4 / 3}> style={{
minHeight: 120,
minWidth: 120,
}}
ratio={4 / 3}
>
<Box <Box
sx={{ sx={{
backgroundColor: backgroundColor:
@@ -126,7 +131,6 @@ export default function AddItemShelfItem(props: any) {
</Group> </Group>
</Box> </Box>
</AspectRatio> </AspectRatio>
</Grid.Col>
</> </>
); );
} }

View File

@@ -10,6 +10,9 @@ import {
AspectRatio, AspectRatio,
createStyles, createStyles,
Center, Center,
Container,
SimpleGrid,
Space,
} from '@mantine/core'; } from '@mantine/core';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import { AlertCircle, Cross, X } from 'tabler-icons-react'; import { AlertCircle, Cross, X } from 'tabler-icons-react';
@@ -24,7 +27,9 @@ const useStyles = createStyles((theme) => ({
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1], backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],
textAlign: 'center', textAlign: 'center',
padding: theme.spacing.xl, padding: theme.spacing.xl,
borderRadius: theme.radius.md, borderRadius: theme.radius.sm,
width: 200,
height: 180,
'&:hover': { '&:hover': {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[2], backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[2],
@@ -53,10 +58,8 @@ const AppShelf = (props: any) => {
} }
return ( return (
<Grid m="xl" gutter="xl"> <SimpleGrid m="xl" cols={4} spacing="xl">
{config.services {config.services.map((service, i) => (
? config.services.map((service, i) => (
<Grid.Col lg={2} sm={3} key={i}>
<motion.div <motion.div
onHoverStart={(e) => { onHoverStart={(e) => {
setHovering(service.name); setHovering(service.name);
@@ -65,27 +68,32 @@ const AppShelf = (props: any) => {
setHovering('none'); setHovering('none');
}} }}
> >
<AspectRatio ratio={4 / 3}>
<Box className={classes.main}> <Box className={classes.main}>
<Group position="center">
<Space />
<Text>{service.name}</Text>
<motion.div animate={{ opacity: hovering == service.name ? 1 : 0 }}> <motion.div animate={{ opacity: hovering == service.name ? 1 : 0 }}>
<AppShelfMenu removeitem={removeService} name={service.name} /> <AppShelfMenu removeitem={removeService} name={service.name} />
</motion.div> </motion.div>
</Group>
<Group direction="column" position="center"> <Group direction="column" position="center">
<Anchor href={service.url} target="_blank"> <Anchor href={service.url} target="_blank">
<motion.div whileHover={{ scale: 1.2 }}> <motion.div whileHover={{ scale: 1.2 }}>
<Image style={{ maxWidth: 60 }} src={service.icon} alt={service.name} /> <Image
style={{
maxWidth: 100,
}}
fit="cover"
src={service.icon}
alt={service.name}
/>
</motion.div> </motion.div>
</Anchor> </Anchor>
<Text>{service.name}</Text>
</Group> </Group>
</Box> </Box>
</AspectRatio>
</motion.div> </motion.div>
</Grid.Col> ))}
)) </SimpleGrid>
: null}
<AddItemShelfItem additem={addService} />
</Grid>
); );
}; };

View File

@@ -5,7 +5,7 @@ import { Check, Edit, Trash } from 'tabler-icons-react';
export default function AppShelfMenu(props: any) { export default function AppShelfMenu(props: any) {
const { name, removeitem: removeItem } = props; const { name, removeitem: removeItem } = props;
return ( return (
<Menu sx={{ position: 'absolute', top: 3, right: 3 }}> <Menu position='right'>
<Menu.Label>Settings</Menu.Label> <Menu.Label>Settings</Menu.Label>
<Menu.Item <Menu.Item
color="primary" color="primary"

View File

@@ -6,6 +6,7 @@ import {
useMantineTheme, useMantineTheme,
Center, Center,
Popover, Popover,
Box,
} from '@mantine/core'; } from '@mantine/core';
import { useForm } from '@mantine/hooks'; import { useForm } from '@mantine/hooks';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
@@ -39,6 +40,11 @@ export default function SearchBar(props: any) {
} }
return ( return (
<Box
style={{
width: '100%',
}}
>
<form <form
onChange={() => { onChange={() => {
// If querry contains !yt or !t add "Searching on YouTube" or "Searching torrent" // If querry contains !yt or !t add "Searching on YouTube" or "Searching torrent"
@@ -46,11 +52,11 @@ export default function SearchBar(props: any) {
const isYoutube = querry.startsWith('!yt'); const isYoutube = querry.startsWith('!yt');
const isTorrent = querry.startsWith('!t'); const isTorrent = querry.startsWith('!t');
if (isYoutube) { if (isYoutube) {
setIcon(<BrandYoutube />); setIcon(<BrandYoutube size={22} />);
} else if (isTorrent) { } else if (isTorrent) {
setIcon(<Download />); setIcon(<Download size={22} />);
} else { } else {
setIcon(<Search />); setIcon(<Search size={22} />);
} }
}} }}
onSubmit={form.onSubmit((values) => { onSubmit={form.onSubmit((values) => {
@@ -83,9 +89,8 @@ export default function SearchBar(props: any) {
<TextInput <TextInput
variant="filled" variant="filled"
color="blue" color="blue"
icon={<Search size={18} />} icon={icon}
radius="md" radius="md"
rightSection={icon}
size="md" size="md"
placeholder="Search the web" placeholder="Search the web"
{...props} {...props}
@@ -94,10 +99,11 @@ export default function SearchBar(props: any) {
} }
> >
<Text> <Text>
tip: You can prefix your querry with <b>!yt</b> or <b>!t</b> to research on youtube or for tip: You can prefix your querry with <b>!yt</b> or <b>!t</b> to research on youtube or
a torrent for a torrent
</Text> </Text>
</Popover> </Popover>
</form> </form>
</Box>
); );
} }

View File

@@ -1,4 +1,4 @@
import { Group, Indicator, Popover, Box, Container, Text, Avatar } from '@mantine/core'; import { Group, Indicator, Popover, Box, Container, Text, Avatar, ActionIcon } from '@mantine/core';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Calendar } from '@mantine/dates'; import { Calendar } from '@mantine/dates';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
@@ -27,7 +27,6 @@ export default function CalendarComponent(props: any) {
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
// const [medias, setMedias] = useState(); // const [medias, setMedias] = useState();
const dates = medias.map((media) => media.inCinemas); const dates = medias.map((media) => media.inCinemas);
const [value, setValue] = useState(null);
const parsedDates = dates.map((date) => dayjs(date)); const parsedDates = dates.map((date) => dayjs(date));
console.log(parsedDates); console.log(parsedDates);
@@ -64,10 +63,7 @@ export default function CalendarComponent(props: any) {
return ( return (
<Calendar <Calendar
value={value} onChange={(day: any) => {}}
onChange={(day: any) => {
setValue(day);
}}
renderDay={(renderdate) => <DayComponent renderdate={renderdate} parsedDates={parsedDates} />} renderDay={(renderdate) => <DayComponent renderdate={renderdate} parsedDates={parsedDates} />}
/> />
); );
@@ -82,13 +78,13 @@ function DayComponent(props: any) {
if (match > -1) { if (match > -1) {
return ( return (
<Avatar <ActionIcon
onClick={() => { onClick={() => {
setOpened(true); setOpened(true);
console.log(); console.log();
}} }}
radius="xl"
color="teal" color="teal"
variant="light"
> >
<Popover <Popover
position="right" position="right"
@@ -98,7 +94,7 @@ function DayComponent(props: any) {
target={day} target={day}
children={<MediaDisplay media={medias[match]} />} children={<MediaDisplay media={medias[match]} />}
/> />
</Avatar> </ActionIcon>
); );
} }
return <div>{day}</div>; return <div>{day}</div>;

View File

@@ -1,5 +1,6 @@
import { Notification } from '@mantine/core'; import { Group, Notification } from '@mantine/core';
import AppShelf from '../components/AppShelf/AppShelf'; import AppShelf from '../components/AppShelf/AppShelf';
import CalendarComponent from '../components/calendar/CalendarComponent';
import LoadConfigComponent from '../components/Config/LoadConfig'; import LoadConfigComponent from '../components/Config/LoadConfig';
import SearchBar from '../components/SearchBar/SearchBar'; import SearchBar from '../components/SearchBar/SearchBar';
@@ -7,7 +8,10 @@ export default function HomePage() {
return ( return (
<> <>
<SearchBar /> <SearchBar />
<Group align={"start"} position="apart" noWrap>
<AppShelf /> <AppShelf />
<CalendarComponent />
</Group>
<LoadConfigComponent /> <LoadConfigComponent />
</> </>
); );