From 24c128d6498af15775f965c9ed3433f9071efaf4 Mon Sep 17 00:00:00 2001 From: iCrawl Date: Mon, 22 Aug 2022 19:44:56 +0200 Subject: [PATCH] feat: experiment with spotlight --- packages/website/src/pages/_app.tsx | 67 ++++++++++++++++++- .../pages/docs/packages/[package]/index.tsx | 7 +- .../website/src/pages/docs/packages/index.tsx | 9 ++- 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/packages/website/src/pages/_app.tsx b/packages/website/src/pages/_app.tsx index 8dfea9725..889440d76 100644 --- a/packages/website/src/pages/_app.tsx +++ b/packages/website/src/pages/_app.tsx @@ -1,13 +1,74 @@ import { ColorScheme, ColorSchemeProvider, MantineProvider } from '@mantine/core'; import { useColorScheme } from '@mantine/hooks'; +import { SpotlightAction, SpotlightProvider } from '@mantine/spotlight'; import type { AppProps } from 'next/app'; import Head from 'next/head'; +import { type NextRouter, useRouter } from 'next/router'; import { useEffect, useState } from 'react'; +import { VscPackage } from 'react-icons/vsc'; import { RouterTransition } from '~/components/RouterTransition'; import '../styles/unocss.css'; import '../styles/main.css'; +const actions: (router: NextRouter) => SpotlightAction[] = (router: NextRouter) => [ + { + title: 'Home', + description: 'Go to landing page', + onTrigger: () => void router.push('/'), + icon: , + }, + { + title: 'Packages', + description: 'Go to the package selection', + onTrigger: () => void router.push('/docs/packages'), + icon: , + }, + { + id: 'packages-builders', + title: 'Builders', + description: 'Go to the @discordjs/builders documentation', + onTrigger: () => void router.push('/docs/packages/builders'), + icon: , + }, + { + id: 'packages-collection', + title: 'Collection', + description: 'Go to the @discordjs/collection documentation', + onTrigger: () => void router.push('/docs/packages/collection'), + icon: , + }, + { + id: 'packages-proxy', + title: 'Proxy', + description: 'Go to the @discordjs/proxy documentation', + onTrigger: () => void router.push('/docs/packages/proxy'), + icon: , + }, + { + id: 'packages-rest', + title: 'REST', + description: 'Go to the @discordjs/rest documentation', + onTrigger: () => void router.push('/docs/packages/voice'), + icon: , + }, + { + id: 'packages-voice', + title: 'Voice', + description: 'Go to the @discordjs/voice documentation', + onTrigger: () => void router.push('/docs/packages/ws'), + icon: , + }, + { + id: 'packages-ws', + title: 'WS', + description: 'Go to the @discordjs/ws documentation', + onTrigger: () => void router.push('/docs'), + icon: , + }, +]; + export default function MyApp({ Component, pageProps }: AppProps) { + const router = useRouter(); const preferredColorScheme = useColorScheme('dark', { getInitialValueInEffect: true }); const [colorScheme, setColorScheme] = useState(preferredColorScheme); const toggleColorScheme = (value?: ColorScheme) => @@ -52,8 +113,10 @@ export default function MyApp({ Component, pageProps }: AppProps) { withNormalizeCSS withGlobalStyles > - - + + + + diff --git a/packages/website/src/pages/docs/packages/[package]/index.tsx b/packages/website/src/pages/docs/packages/[package]/index.tsx index 171030cf5..9d1dfbf0f 100644 --- a/packages/website/src/pages/docs/packages/[package]/index.tsx +++ b/packages/website/src/pages/docs/packages/[package]/index.tsx @@ -1,4 +1,4 @@ -import { Container, UnstyledButton, createStyles, Group, ThemeIcon, Text, Stack, Box } from '@mantine/core'; +import { Container, UnstyledButton, createStyles, Group, ThemeIcon, Text, Stack, Box, Title } from '@mantine/core'; import Link from 'next/link'; import type { GetStaticPaths, GetStaticProps } from 'next/types'; import { VscArrowRight, VscPackage } from 'react-icons/vsc'; @@ -66,13 +66,16 @@ export default function VersionsRoute(props: Partial & { error?: s ) : ( + + Select a version: + {props.data?.versions.map((version) => ( - + {version} diff --git a/packages/website/src/pages/docs/packages/index.tsx b/packages/website/src/pages/docs/packages/index.tsx index 4b5ae8eae..3eb5f886d 100644 --- a/packages/website/src/pages/docs/packages/index.tsx +++ b/packages/website/src/pages/docs/packages/index.tsx @@ -1,4 +1,4 @@ -import { Container, UnstyledButton, createStyles, Group, ThemeIcon, Text, Stack } from '@mantine/core'; +import { Container, UnstyledButton, createStyles, Group, ThemeIcon, Text, Stack, Title } from '@mantine/core'; import Link from 'next/link'; import { VscArrowRight, VscPackage } from 'react-icons/vsc'; @@ -21,13 +21,16 @@ export default function PackagesRoute() { return ( + + Select a package: + {packages.map((pkg) => ( - + - + {pkg}