2022-05-12 21:38:21 +02:00
|
|
|
import React, { useState } from 'react';
|
2022-04-25 23:33:32 +02:00
|
|
|
import { motion } from 'framer-motion';
|
2022-05-14 10:10:58 +02:00
|
|
|
import { Text, AspectRatio, SimpleGrid, Card, Center, Image, useMantineTheme } from '@mantine/core';
|
2022-05-02 15:09:39 +02:00
|
|
|
import { useConfig } from '../../tools/state';
|
2022-05-04 07:30:06 +02:00
|
|
|
import { serviceItem } from '../../tools/types';
|
2022-05-10 19:02:16 +02:00
|
|
|
import { AppShelfItemWrapper } from './AppShelfItemWrapper';
|
|
|
|
|
import AppShelfMenu from './AppShelfMenu';
|
2022-04-25 00:11:32 +02:00
|
|
|
|
2022-05-12 21:38:21 +02:00
|
|
|
const AppShelf = () => {
|
|
|
|
|
const { config } = useConfig();
|
2022-04-25 23:33:32 +02:00
|
|
|
|
2022-04-25 00:11:32 +02:00
|
|
|
return (
|
2022-05-14 10:10:58 +02:00
|
|
|
<SimpleGrid
|
|
|
|
|
cols={5}
|
|
|
|
|
spacing="xl"
|
|
|
|
|
breakpoints={[
|
|
|
|
|
{ maxWidth: 'xl', cols: 4, spacing: 'lg' },
|
|
|
|
|
{ maxWidth: 800, cols: 3, spacing: 'md' },
|
|
|
|
|
{ maxWidth: 400, cols: 3, spacing: 'sm' },
|
|
|
|
|
{ maxWidth: 400, cols: 2, spacing: 'sm' },
|
|
|
|
|
]}
|
|
|
|
|
>
|
2022-05-12 21:38:21 +02:00
|
|
|
{config.services.map((service) => (
|
2022-05-04 10:33:08 +02:00
|
|
|
<AppShelfItem key={service.name} service={service} />
|
2022-05-04 07:12:22 +02:00
|
|
|
))}
|
|
|
|
|
</SimpleGrid>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function AppShelfItem(props: any) {
|
|
|
|
|
const { service }: { service: serviceItem } = props;
|
|
|
|
|
const [hovering, setHovering] = useState(false);
|
2022-05-14 10:10:58 +02:00
|
|
|
const theme = useMantineTheme();
|
2022-05-04 07:12:22 +02:00
|
|
|
return (
|
|
|
|
|
<motion.div
|
2022-05-04 07:49:29 +02:00
|
|
|
key={service.name}
|
2022-05-12 21:38:21 +02:00
|
|
|
onHoverStart={() => {
|
2022-05-04 07:12:22 +02:00
|
|
|
setHovering(true);
|
|
|
|
|
}}
|
2022-05-12 21:38:21 +02:00
|
|
|
onHoverEnd={() => {
|
2022-05-04 07:12:22 +02:00
|
|
|
setHovering(false);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-05-14 10:10:58 +02:00
|
|
|
<Card
|
|
|
|
|
style={{
|
|
|
|
|
boxShadow: hovering ? '0px 0px 3px rgba(0, 0, 0, 0.5)' : '0px 0px 1px rgba(0, 0, 0, 0.5)',
|
|
|
|
|
backgroundColor:
|
|
|
|
|
theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.colors.gray[1],
|
|
|
|
|
}}
|
|
|
|
|
radius="md"
|
|
|
|
|
>
|
2022-05-04 07:12:22 +02:00
|
|
|
<Card.Section>
|
2022-05-14 10:10:58 +02:00
|
|
|
<Text mt="sm" align="center" lineClamp={1} weight={500}>
|
2022-05-04 07:12:22 +02:00
|
|
|
{service.name}
|
|
|
|
|
</Text>
|
2022-05-14 10:10:58 +02:00
|
|
|
<motion.div
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
top: 5,
|
|
|
|
|
right: 5,
|
|
|
|
|
alignSelf: 'flex-end',
|
|
|
|
|
}}
|
|
|
|
|
animate={{
|
|
|
|
|
opacity: hovering ? 1 : 0,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<AppShelfMenu service={service} />
|
|
|
|
|
</motion.div>
|
2022-05-04 07:12:22 +02:00
|
|
|
</Card.Section>
|
|
|
|
|
<Card.Section>
|
|
|
|
|
<AspectRatio ratio={5 / 3} m="xl">
|
|
|
|
|
<motion.i
|
|
|
|
|
whileHover={{
|
|
|
|
|
cursor: 'pointer',
|
|
|
|
|
scale: 1.1,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Image
|
|
|
|
|
onClick={() => {
|
|
|
|
|
window.open(service.url);
|
|
|
|
|
}}
|
|
|
|
|
src={service.icon}
|
|
|
|
|
/>
|
|
|
|
|
</motion.i>
|
|
|
|
|
</AspectRatio>
|
|
|
|
|
</Card.Section>
|
2022-05-14 10:10:58 +02:00
|
|
|
</Card>
|
2022-05-04 07:12:22 +02:00
|
|
|
</motion.div>
|
2022-04-25 00:11:32 +02:00
|
|
|
);
|
2022-05-04 07:12:22 +02:00
|
|
|
}
|
2022-04-25 00:11:32 +02:00
|
|
|
|
2022-04-27 03:11:35 +02:00
|
|
|
export default AppShelf;
|