add carousel

master
gman 3 years ago
parent 6502ae47c3
commit 5bbe02ac94

939
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -11,9 +11,11 @@
}, },
"dependencies": { "dependencies": {
"@emotion/react": "^11.11.1", "@emotion/react": "^11.11.1",
"@mantine/core": "^6.0.17", "@mantine/carousel": "^6.0.21",
"@mantine/hooks": "^6.0.17", "@mantine/core": "^6.0.21",
"@mantine/hooks": "^6.0.21",
"@tabler/icons-react": "^2.28.0", "@tabler/icons-react": "^2.28.0",
"embla-carousel-react": "^7.0.0",
"fuse.js": "^6.6.2", "fuse.js": "^6.6.2",
"maplibre-gl": "^3.2.0", "maplibre-gl": "^3.2.0",
"react": "^18.2.0", "react": "^18.2.0",

@ -1,47 +1,58 @@
import { Title, Text, Container, rem, createStyles, TypographyStylesProvider } from '@mantine/core'; import { Title, Container, rem, createStyles, TypographyStylesProvider, Image } from '@mantine/core';
import { Carousel } from '@mantine/carousel';
import { useLoaderData } from 'react-router-dom'; import { useLoaderData } from 'react-router-dom';
import Markdown from 'react-markdown'; import Markdown from 'react-markdown';
const useStyles = createStyles((theme) => ({ const useStyles = createStyles((theme) => ({
content: { content: {
padding: rem(30) padding: rem(30)
}, },
title: { title: {
fontSize: rem(55), fontSize: rem(55),
lineHeight: 1.2, lineHeight: 1.2,
fontWeight: 900, fontWeight: 900,
paddingBottom: rem(20), paddingBottom: rem(20),
[theme.fn.smallerThan('xs')]: { [theme.fn.smallerThan('xs')]: {
fontSize: rem(28), fontSize: rem(28),
},
}, },
},
heading2: { heading2: {
color: theme.colorScheme === 'dark' ? theme.white : theme.black, color: theme.colorScheme === 'dark' ? theme.white : theme.black,
paddingTop: rem(11) paddingTop: rem(11)
} }
})); }));
export function Article() { export function Article() {
const articleData = useLoaderData(); const articleData = useLoaderData();
const { classes } = useStyles(); const { classes } = useStyles();
const article = articleData.data[0].attributes const article = articleData.data[0].attributes
console.log(articleData)
return (
<Container className={classes.content}> const generateCarousel = () => {
<Title order={1} className={classes.title}> if (articleData.data[0].attributes.carousel.data) {
{article.title} return (
</Title> <Carousel slideSize="70%" height={500} slideGap="md" loop>
<Text> {articleData.data[0].attributes.carousel.data.map(image => <Carousel.Slide><Image fit='fill' height={500} mx="auto" radius="md" src={`http://strapi.wg.gateway.ts${image.attributes.url}`} alt="Random image" /></Carousel.Slide>)}
<TypographyStylesProvider> </Carousel>
<Markdown>{article.content}</Markdown> )
</TypographyStylesProvider> }
</Text>
</Container>
);
} }
return (
<Container className={classes.content}>
<Title order={1} className={classes.title}>
{article.title}
</Title>
<TypographyStylesProvider>
<Markdown>{article.content}</Markdown>
</TypographyStylesProvider>
{generateCarousel()}
</Container>
);
}

Loading…
Cancel
Save