From 331dedcb9dd24adaff95dba0a5cfe58662f27541 Mon Sep 17 00:00:00 2001 From: iCrawl Date: Tue, 23 Aug 2022 10:57:34 +0200 Subject: [PATCH] refactor: front page --- packages/website/src/pages/index.tsx | 76 +++++++++++++++++----------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/packages/website/src/pages/index.tsx b/packages/website/src/pages/index.tsx index 8ab76c9f5..f66e51764 100644 --- a/packages/website/src/pages/index.tsx +++ b/packages/website/src/pages/index.tsx @@ -1,18 +1,30 @@ import { createStyles, Container, Title, Button, Group, Text, Center, Box } from '@mantine/core'; import Image from 'next/future/image'; import Link from 'next/link'; -import codeSample from '../assets/code-sample.png'; +import { FiExternalLink } from 'react-icons/fi'; +import { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter'; +import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism'; const useStyles = createStyles((theme) => ({ + outer: { + display: 'flex', + flexDirection: 'column', + height: '100%', + justifyContent: 'center', + gap: 50, + padding: 32, + + [theme.fn.smallerThan('md')]: { + height: 'unset', + }, + }, + inner: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', - paddingTop: theme.spacing.xl * 6, - paddingBottom: theme.spacing.xl * 2, [theme.fn.smallerThan('md')]: { - paddingTop: theme.spacing.xl * 2, flexDirection: 'column', gap: 50, }, @@ -20,7 +32,7 @@ const useStyles = createStyles((theme) => ({ content: { maxWidth: 480, - marginRight: theme.spacing.xl * 3, + marginRight: theme.spacing.xl, [theme.fn.smallerThan('md')]: { marginRight: 0, @@ -44,33 +56,13 @@ const useStyles = createStyles((theme) => ({ borderRadius: theme.radius.sm, padding: '4px 12px', }, - - control: { - [theme.fn.smallerThan('xs')]: { - flex: 1, - }, - }, - - image: { - flex: 1, - height: '100%', - maxWidth: 550, - - [theme.fn.smallerThan('xs')]: { - maxWidth: 350, - }, - }, - - vercel: { - paddingBottom: theme.spacing.xl * 4, - }, })); export default function IndexRoute() { const { classes } = useStyles(); return ( - + @@ -84,18 +76,43 @@ export default function IndexRoute() { <Group mt={30}> <Link href="/docs" passHref> - <Button component="a" radius="sm" size="md" className={classes.control}> + <Button component="a" radius="sm" size="md"> Docs </Button> </Link> <Link href="https://discordjs.guide" passHref> - <Button component="a" variant="default" radius="sm" size="md" className={classes.control}> + <Button component="a" variant="default" radius="sm" size="md" rightIcon={<FiExternalLink />}> Guide </Button> </Link> </Group> </Box> - <Image src={codeSample} className={classes.image} /> + <Box pb="xs"> + <SyntaxHighlighter + wrapLongLines + language="typescript" + style={vscDarkPlus} + codeTagProps={{ style: { fontFamily: 'JetBrains Mono' } }} + > + {`import { Client, GatewayIntentBits } from 'discord.js'; + +const client = new Client({ intents: [GatewayIntentBits.Guilds] }); + +client.on('ready', () => { + console.log(\`Logged in as \${client.user.tag}!\`); +}); + +client.on('interactionCreate', async (interaction) => { + if (!interaction.isChatInputCommand()) return; + + if (interaction.commandName === 'ping') { + await interaction.reply('Pong!'); + } +}); + +await client.login('token');`} + </SyntaxHighlighter> + </Box> </Box> <Center> <Link href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"> @@ -106,7 +123,6 @@ export default function IndexRoute() { width={0} height={0} style={{ height: '100%', width: '100%', maxWidth: 250 }} - className={classes.vercel} /> </a> </Link>