Skip to content

Full Toolkit for Next-Level Domain Analysis

Add landing page with lookup form 🛬

Felix Wotschofsky1f958fc72568
diff --git a/pages/index.tsx b/pages/index.tsx
index 08145bb..f8e3b09 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -1,69 +1,122 @@
-import Head from 'next/head'
-import Image from 'next/image'
-import styles from '../styles/Home.module.css'
+import Head from 'next/head';
+import { FormEvent, ChangeEvent, useState } from 'react';
+import {
+ Stack,
+ FormControl,
+ Input,
+ Button,
+ useColorModeValue,
+ Heading,
+ Text,
+ Container,
+ Flex,
+} from '@chakra-ui/react';
+import { useRouter } from 'next/router';
+
+enum FormStates {
+ Initial,
+ Submitting,
+ Success,
+}
+
+const domainRegex = new RegExp(
+ /^((?:(?:(?:\w[\.\-\+]?)*)\w)+)((?:(?:(?:\w[\.\-\+]?){0,62})\w)+)\.(\w{2,6})$/
+);
+
+// Based on simple newsletter template from https://chakra-templates.dev
+
+const Home = () => {
+ const router = useRouter();
+ const [domain, setDomain] = useState('');
+ const [state, setState] = useState<FormStates>(FormStates.Initial);
+ const [error, setError] = useState(false);
-export default function Home() {
return (
- <div className={styles.container}>
+ <>
<Head>
- <title>Create Next App</title>
- <meta name="description" content="Generated by create next app" />
- <link rel="icon" href="/favicon.ico" />
+ <title>Domain Digger</title>
</Head>
- <main className={styles.main}>
- <h1 className={styles.title}>
- Welcome to <a href="https://nextjs.org">Next.js!</a>
- </h1>
-
- <p className={styles.description}>
- Get started by editing{' '}
- <code className={styles.code}>pages/index.js</code>
- </p>
-
- <div className={styles.grid}>
- <a href="https://nextjs.org/docs" className={styles.card}>
- <h2>Documentation &rarr;</h2>
- <p>Find in-depth information about Next.js features and API.</p>
- </a>
+ <Flex
+ minH="100vh"
+ align="center"
+ justify="center"
+ bg={useColorModeValue('gray.50', 'gray.800')}
+ >
+ <Container
+ maxW="lg"
+ bg={useColorModeValue('white', 'whiteAlpha.100')}
+ boxShadow="xl"
+ rounded="lg"
+ p={6}
+ direction="column"
+ >
+ <Heading
+ as="h2"
+ fontSize={{ base: 'xl', sm: '2xl' }}
+ textAlign="center"
+ mb={5}
+ >
+ Get details about any Domain
+ </Heading>
+ <Stack
+ direction={{ base: 'column', md: 'row' }}
+ as="form"
+ spacing="12px"
+ onSubmit={(event: FormEvent) => {
+ event.preventDefault();
+ setError(false);
+ setState(FormStates.Submitting);
- <a href="https://nextjs.org/learn" className={styles.card}>
- <h2>Learn &rarr;</h2>
- <p>Learn about Next.js in an interactive course with quizzes!</p>
- </a>
+ if (!domain.match(domainRegex)) {
+ setError(true);
+ setState(FormStates.Initial);
+ return;
+ }
- <a
- href="https://github.com/vercel/next.js/tree/master/examples"
- className={styles.card}
+ router.push(`/lookup/${domain}`);
+ }}
>
- <h2>Examples &rarr;</h2>
- <p>Discover and deploy boilerplate example Next.js projects.</p>
- </a>
+ <FormControl>
+ <Input
+ borderWidth={1}
+ id="email"
+ type="text"
+ required
+ placeholder="example.com"
+ aria-label="Domain"
+ value={domain}
+ disabled={state !== FormStates.Initial}
+ onChange={(event: ChangeEvent<HTMLInputElement>) =>
+ setDomain(event.target.value)
+ }
+ />
+ </FormControl>
+ <FormControl w={{ base: '100%', md: '40%' }}>
+ <Button
+ colorScheme="blue"
+ isLoading={state === FormStates.Submitting}
+ w="100%"
+ type="submit"
+ >
+ Lookup
+ </Button>
+ </FormControl>
+ </Stack>
- <a
- href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
- className={styles.card}
+ <Text
+ mt={2}
+ textAlign="center"
+ color={error ? 'red.500' : 'gray.500'}
>
- <h2>Deploy &rarr;</h2>
- <p>
- Instantly deploy your Next.js site to a public URL with Vercel.
- </p>
- </a>
- </div>
- </main>
+ {error
+ ? 'An error occured! Please check your input or try again later.'
+ : 'It can be anything! An apex or subdomain.'}
+ </Text>
+ </Container>
+ </Flex>
+ </>
+ );
+};
- <footer className={styles.footer}>
- <a
- href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
- target="_blank"
- rel="noopener noreferrer"
- >
- Powered by{' '}
- <span className={styles.logo}>
- <Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
- </span>
- </a>
- </footer>
- </div>
- )
-}
+export default Home;